Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ pub(crate) enum Subcommand {
#[structopt(name = "pull")]
Pull {},

/// Emit information about volumes
#[structopt(name = "volumes")]
Volume {},

/// Generate shell completions to stdout.
#[structopt(name = "completion")]
Completion {
Expand Down
21 changes: 21 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ fn run_floki_from_args(args: &Cli) -> Result<(), Error> {
Ok(Cli::clap().gen_completions_to("floki", *shell, &mut std::io::stdout()))
}

Some(Subcommand::Volume {}) => {
list_volumes(&environ, &config);
Ok(())
}

// Launch an interactive floki shell (the default)
None => {
let inner_command = config.shell.inner_shell().to_string();
Expand All @@ -86,6 +91,22 @@ fn run_floki_container(
interpret::run_container(&environ, &config, &inner_command)
}

/// Print the volumes used in the current configuration
fn list_volumes(environ: &environment::Environment, config: &FlokiConfig) {
println!("{:20} {:20} {}", "NAME", "MOUNT", "HOSTPATH");
for (name, volume) in config.volumes.iter() {
let hostpath =
volumes::cache_path(&environ.floki_workspace, &environ.config_file, name, volume);
let mount = &volume.mount;
println!(
"{:20} {:20} {}",
name,
mount.to_string_lossy(),
hostpath.to_string_lossy()
);
}
}

/// Configure the logger
fn configure_logging(verbosity: u8) -> Result<(), Error> {
let level = match verbosity {
Expand Down
2 changes: 1 addition & 1 deletion src/volumes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) fn resolve_volume_mounts<'a>(
.collect()
}

fn cache_path(
pub(crate) fn cache_path(
work_path: &path::PathBuf,
config_filepath: &path::PathBuf,
name: &str,
Expand Down