diff --git a/docs/cli/bin-paths.md b/docs/cli/bin-paths.md index 9bdc2f3b72..41a9da484d 100644 --- a/docs/cli/bin-paths.md +++ b/docs/cli/bin-paths.md @@ -1,6 +1,13 @@ # `mise bin-paths` -- **Usage**: `mise bin-paths` +- **Usage**: `mise bin-paths [TOOL@VERSION]...` - **Source code**: [`src/cli/bin-paths.rs`](https://github.com/jdx/mise/blob/main/src/cli/bin-paths.rs) List all the active runtime bin paths + +## Arguments + +### `[TOOL@VERSION]...` + +Tool(s) to look up +e.g.: ruby@3 diff --git a/docs/cli/index.md b/docs/cli/index.md index f496ddf3de..d942d165db 100644 --- a/docs/cli/index.md +++ b/docs/cli/index.md @@ -52,7 +52,7 @@ Answer yes to all confirmation prompts - [`mise alias unset `](/cli/alias/unset.md) - [`mise backends `](/cli/backends.md) - [`mise backends ls`](/cli/backends/ls.md) -- [`mise bin-paths`](/cli/bin-paths.md) +- [`mise bin-paths [TOOL@VERSION]...`](/cli/bin-paths.md) - [`mise cache `](/cli/cache.md) - [`mise cache clear [PLUGIN]...`](/cli/cache/clear.md) - [`mise cache prune [--dry-run] [-v --verbose...] [PLUGIN]...`](/cli/cache/prune.md) diff --git a/e2e/cli/test_bin_paths b/e2e/cli/test_bin_paths index 268a921dee..b7072d4f6f 100644 --- a/e2e/cli/test_bin_paths +++ b/e2e/cli/test_bin_paths @@ -1,4 +1,7 @@ #!/usr/bin/env bash -mise use dummy@latest -assert "mise bin-paths" "$MISE_DATA_DIR/installs/dummy/2.0.0/bin" +mise use dummy@latest tiny@latest +assert "mise bin-paths dummy" "$MISE_DATA_DIR/installs/dummy/2.0.0/bin" +assert "mise bin-paths tiny" "$MISE_DATA_DIR/installs/tiny/3.1.0/bin" +assert "mise bin-paths" "$MISE_DATA_DIR/installs/dummy/2.0.0/bin +$MISE_DATA_DIR/installs/tiny/3.1.0/bin" diff --git a/mise.usage.kdl b/mise.usage.kdl index f8992ff76a..b58d575d06 100644 --- a/mise.usage.kdl +++ b/mise.usage.kdl @@ -178,7 +178,9 @@ cmd "backends" help="Manage backends" { " } } -cmd "bin-paths" help="List all the active runtime bin paths" +cmd "bin-paths" help="List all the active runtime bin paths" { + arg "[TOOL@VERSION]..." help="Tool(s) to look up\ne.g.: ruby@3" var=true +} cmd "cache" help="Manage the mise cache" { long_help r"Manage the mise cache diff --git a/src/cli/bin_paths.rs b/src/cli/bin_paths.rs index fc3beb738e..832d8541bc 100644 --- a/src/cli/bin_paths.rs +++ b/src/cli/bin_paths.rs @@ -1,17 +1,29 @@ -use eyre::Result; - +use crate::cli::args::ToolArg; use crate::config::Config; use crate::toolset::ToolsetBuilder; +use eyre::Result; /// List all the active runtime bin paths #[derive(Debug, clap::Args)] #[clap(verbatim_doc_comment)] -pub struct BinPaths {} +pub struct BinPaths { + /// Tool(s) to look up + /// e.g.: ruby@3 + #[clap(value_name = "TOOL@VERSION", verbatim_doc_comment)] + tool: Option>, +} impl BinPaths { pub fn run(self) -> Result<()> { let config = Config::try_get()?; - let ts = ToolsetBuilder::new().build(&config)?; + let mut tsb = ToolsetBuilder::new(); + if let Some(tool) = &self.tool { + tsb = tsb.with_args(tool); + } + let mut ts = tsb.build(&config)?; + if let Some(tool) = &self.tool { + ts.versions.retain(|k, _| tool.iter().any(|t| t.ba == *k)); + } ts.notify_if_versions_missing(); for p in ts.list_paths() { miseprintln!("{}", p.display()); diff --git a/xtasks/fig/src/mise.ts b/xtasks/fig/src/mise.ts index 2144005276..cfa8c6103c 100644 --- a/xtasks/fig/src/mise.ts +++ b/xtasks/fig/src/mise.ts @@ -572,7 +572,16 @@ const completionSpec: Fig.Spec = { "name": [ "bin-paths" ], - "description": "List all the active runtime bin paths" + "description": "List all the active runtime bin paths", + "args": [ + { + "name": "tool@version", + "description": "Tool(s) to look up\ne.g.: ruby@3", + "isOptional": true, + "isVariadic": true, + "generators": toolVersionGenerator + } + ] }, { "name": [