Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow filtering mise bin-paths on tools #3367

Merged
merged 1 commit into from
Dec 5, 2024
Merged
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
9 changes: 8 additions & 1 deletion docs/cli/bin-paths.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion docs/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Answer yes to all confirmation prompts
- [`mise alias unset <PLUGIN> <ALIAS>`](/cli/alias/unset.md)
- [`mise backends <SUBCOMMAND>`](/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 <SUBCOMMAND>`](/cli/cache.md)
- [`mise cache clear [PLUGIN]...`](/cli/cache/clear.md)
- [`mise cache prune [--dry-run] [-v --verbose...] [PLUGIN]...`](/cli/cache/prune.md)
Expand Down
7 changes: 5 additions & 2 deletions e2e/cli/test_bin_paths
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 3 additions & 1 deletion mise.usage.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 16 additions & 4 deletions src/cli/bin_paths.rs
Original file line number Diff line number Diff line change
@@ -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<Vec<ToolArg>>,
}

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());
Expand Down
11 changes: 10 additions & 1 deletion xtasks/fig/src/mise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Loading