Skip to content

Commit f8acc4a

Browse files
committed
Subcommand to list volumes and their paths
Signed-off-by: Richard Lupton <[email protected]>
1 parent 5676aff commit f8acc4a

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/cli.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ pub(crate) enum Subcommand {
1313
#[structopt(name = "pull")]
1414
Pull {},
1515

16+
/// Emit information about volumes
17+
#[structopt(name = "volumes")]
18+
Volume {},
19+
1620
/// Generate shell completions to stdout.
1721
#[structopt(name = "completion")]
1822
Completion {

src/main.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ fn run_floki_from_args(args: &Cli) -> Result<(), Error> {
6868
Ok(Cli::clap().gen_completions_to("floki", *shell, &mut std::io::stdout()))
6969
}
7070

71+
Some(Subcommand::Volume {}) => {
72+
list_volumes(&environ, &config);
73+
Ok(())
74+
}
75+
7176
// Launch an interactive floki shell (the default)
7277
None => {
7378
let inner_command = config.shell.inner_shell().to_string();
@@ -86,6 +91,17 @@ fn run_floki_container(
8691
interpret::run_container(&environ, &config, &inner_command)
8792
}
8893

94+
/// Print the volumes used in the current configuration
95+
fn list_volumes(environ: &environment::Environment, config: &FlokiConfig) {
96+
println!("{:20} {:20} {}", "NAME", "MOUNT", "HOSTPATH");
97+
for (name, volume) in config.volumes.iter() {
98+
let hostpath =
99+
volumes::cache_path(&environ.floki_workspace, &environ.config_file, name, volume);
100+
let mount = &volume.mount;
101+
println!("{:20} {:20} {}", name, mount.to_string_lossy(), hostpath.to_string_lossy());
102+
}
103+
}
104+
89105
/// Configure the logger
90106
fn configure_logging(verbosity: u8) -> Result<(), Error> {
91107
let level = match verbosity {

src/volumes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(crate) fn resolve_volume_mounts<'a>(
2424
.collect()
2525
}
2626

27-
fn cache_path(
27+
pub(crate) fn cache_path(
2828
work_path: &path::PathBuf,
2929
config_filepath: &path::PathBuf,
3030
name: &str,

0 commit comments

Comments
 (0)