Skip to content
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
16 changes: 16 additions & 0 deletions e2e/cli/test_config_target_aliases
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,19 @@ mise unuse --no-prune --file subdir dummy@1
assert_not_contains "cat subdir/mise.toml" "dummy"
mise unset --path subdir SUBDIR_VAR
assert_not_contains "cat subdir/mise.toml" "SUBDIR_VAR"

# the commands that write to a config under `--path` take --file too. `brew tap`/`untap` only
# edit `[bootstrap.brew.taps]` — they do not touch a Homebrew installation — so they are the
# cheap way to exercise this end to end; the rest are covered by the clap assertions in
# src/cli/mod.rs, since running them installs or applies something.
mise bootstrap packages brew tap acme/tools --file tap-alias.toml
assert_contains "cat tap-alias.toml" "acme/tools"

mise bootstrap packages brew untap acme/tools --file tap-alias.toml
assert_not_contains "cat tap-alias.toml" "acme/tools"

# and the canonical name is unaffected
mise bootstrap packages brew tap acme/tools --path tap-alias.toml
assert_contains "cat tap-alias.toml" "acme/tools"
mise bootstrap packages brew untap acme/tools --path tap-alias.toml
assert_not_contains "cat tap-alias.toml" "acme/tools"
10 changes: 5 additions & 5 deletions man/man1/mise.1
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ Print the config/source updates without writing anything
\fB\-\-no\-apply\fR
Add the entry without applying it
.TP
\fB\-p, \-\-path\fR \fI<PATH>\fR
\fB\-p, \-\-path, \-\-file\fR \fI<PATH>\fR
Write to this config file or directory
.TP
\fB\-s, \-\-source\fR \fI<PATH>\fR
Expand Down Expand Up @@ -1189,7 +1189,7 @@ Write to the local config instead of the global config
\fB\-n, \-\-dry\-run\fR
Print the config change without writing it
.TP
\fB\-p, \-\-path\fR \fI<PATH>\fR
\fB\-p, \-\-path, \-\-file\fR \fI<PATH>\fR
Write to this config file or directory
\fBArguments:\fR
.PP
Expand All @@ -1213,7 +1213,7 @@ Write to the local config instead of the global config
\fB\-n, \-\-dry\-run\fR
Print the config change without writing it
.TP
\fB\-p, \-\-path\fR \fI<PATH>\fR
\fB\-p, \-\-path, \-\-file\fR \fI<PATH>\fR
Write to this config file or directory
\fBArguments:\fR
.PP
Expand Down Expand Up @@ -1250,7 +1250,7 @@ Import every linked formula, including dependencies
\fB\-n, \-\-dry\-run\fR
Print the config change without writing config
.TP
\fB\-p, \-\-path\fR \fI<PATH>\fR
\fB\-p, \-\-path, \-\-file\fR \fI<PATH>\fR
Write to this config file or directory
.SH "MISE BOOTSTRAP PACKAGES PRUNE"
Prune installed system packages no longer declared in `[bootstrap.packages]`
Expand Down Expand Up @@ -1346,7 +1346,7 @@ Write to the global config (~/.config/mise/config.toml) instead of the local one
\fB\-n, \-\-dry\-run\fR
Print the commands that would run without writing config or installing
.TP
\fB\-p, \-\-path\fR \fI<PATH>\fR
\fB\-p, \-\-path, \-\-file\fR \fI<PATH>\fR
Write to this config file or directory
.TP
\fB\-y, \-\-yes\fR
Expand Down
12 changes: 6 additions & 6 deletions mise.usage.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ Examples:
}
flag "-n --dry-run" help="Print the config/source updates without writing anything"
flag --no-apply help="Add the entry without applying it"
flag "-p --path" help="Write to this config file or directory" {
flag "-p --path --file" help="Write to this config file or directory" {
arg <PATH>
}
flag "-s --source" help="Source path to use for a single target" {
Expand Down Expand Up @@ -598,7 +598,7 @@ Examples:
"""#
flag "-l --local" help="Write to the local config instead of the global config"
flag "-n --dry-run" help="Print the config change without writing it"
flag "-p --path" help="Write to this config file or directory" {
flag "-p --path --file" help="Write to this config file or directory" {
arg <PATH>
}
arg <TAP> help="Tap name, e.g. `owner/repo`"
Expand All @@ -614,7 +614,7 @@ Examples:
"""#
flag "-l --local" help="Write to the local config instead of the global config"
flag "-n --dry-run" help="Print the config change without writing it"
flag "-p --path" help="Write to this config file or directory" {
flag "-p --path --file" help="Write to this config file or directory" {
arg <PATH>
}
arg <TAPS>… help="Tap name(s), e.g. `owner/repo`" var=#true
Expand Down Expand Up @@ -648,7 +648,7 @@ Examples:
}
flag --all help="Import every linked formula, including dependencies"
flag "-n --dry-run" help="Print the config change without writing config"
flag "-p --path" help="Write to this config file or directory" {
flag "-p --path --file" help="Write to this config file or directory" {
arg <PATH>
}
}
Expand Down Expand Up @@ -750,7 +750,7 @@ Examples:
}
flag "-g --global" help="Write to the global config (~/.config/mise/config.toml) instead of the local one"
flag "-n --dry-run" help="Print the commands that would run without writing config or installing"
flag "-p --path" help="Write to this config file or directory" {
flag "-p --path --file" help="Write to this config file or directory" {
arg <PATH>
}
flag "-y --yes" help="Skip the confirmation prompt"
Expand Down Expand Up @@ -1075,7 +1075,7 @@ Examples:
}
flag "-n --dry-run" help="Print the config/source updates without writing anything"
flag --no-apply help="Add the entry without applying it"
flag "-p --path" help="Write to this config file or directory" {
flag "-p --path --file" help="Write to this config file or directory" {
arg <PATH>
}
flag "-s --source" help="Source path to use for a single target" {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/dotfiles/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub struct DotfilesAdd {
pub(super) no_apply: bool,

/// Write to this config file or directory
#[clap(long, short, value_name = "PATH", conflicts_with_all = ["global", "local"])]
#[clap(long, short, visible_alias = "file", value_name = "PATH", conflicts_with_all = ["global", "local"])]
pub(super) path: Option<PathBuf>,

/// Source path to use for a single target
Expand Down
57 changes: 57 additions & 0 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,63 @@ mod tests {
}
}

/// Commands that name a config file to write to accept both spellings, so it
/// does not matter which one you remember. See
/// <https://github.com/jdx/mise/discussions/4881>.
///
/// Asserted through clap rather than end-to-end because several of these
/// commands install or apply something when actually run.
#[test]
fn test_config_target_options_accept_both_names() {
// (command path, argument id, expected alias, available on this platform)
let cases: &[(&[&str], &str, &str, bool)] = &[
(&["use"], "path", "file", true),
(&["unuse"], "path", "file", true),
(&["set"], "file", "path", true),
(&["unset"], "file", "path", true),
(&["dotfiles", "add"], "path", "file", true),
(&["bootstrap", "packages", "use"], "path", "file", true),
(&["bootstrap", "packages", "import"], "path", "file", true),
// the brew manager is not registered on Windows
(
&["bootstrap", "packages", "brew", "tap"],
"path",
"file",
cfg!(not(windows)),
),
(
&["bootstrap", "packages", "brew", "untap"],
"path",
"file",
cfg!(not(windows)),
),
];
let root = Cli::command();

for (path, arg_name, alias, available) in cases {
if !available {
continue;
}
let command = path.iter().fold(&root, |command, name| {
command
.get_subcommands()
.find(|subcommand| subcommand.get_name() == *name)
.unwrap_or_else(|| panic!("missing command path {}", path.join(" ")))
});
let arg = command
.get_arguments()
.find(|arg| arg.get_id() == *arg_name)
.unwrap_or_else(|| panic!("missing --{arg_name} on {}", path.join(" ")));

assert!(
arg.get_visible_aliases()
.is_some_and(|aliases| aliases.contains(alias)),
"missing visible --{alias} alias for --{arg_name} on {}",
path.join(" ")
);
}
}

#[test]
fn test_escape_task_args_preserves_task_separator_tail() {
let cmd = Cli::command();
Expand Down
8 changes: 7 additions & 1 deletion src/cli/system/brew/tap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ pub struct SystemBrewTap {
dry_run: bool,

/// Write to this config file or directory
#[clap(long, short, value_name = "PATH", conflicts_with = "local")]
#[clap(
long,
short,
visible_alias = "file",
value_name = "PATH",
conflicts_with = "local"
)]
path: Option<PathBuf>,
}

Expand Down
8 changes: 7 additions & 1 deletion src/cli/system/brew/untap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ pub struct SystemBrewUntap {
dry_run: bool,

/// Write to this config file or directory
#[clap(long, short, value_name = "PATH", conflicts_with = "local")]
#[clap(
long,
short,
visible_alias = "file",
value_name = "PATH",
conflicts_with = "local"
)]
path: Option<PathBuf>,
}

Expand Down
8 changes: 7 additions & 1 deletion src/cli/system/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ pub struct SystemImport {
dry_run: bool,

/// Write to this config file or directory
#[clap(long, short, value_name = "PATH", conflicts_with = "global")]
#[clap(
long,
short,
visible_alias = "file",
value_name = "PATH",
conflicts_with = "global"
)]
path: Option<PathBuf>,
}

Expand Down
8 changes: 7 additions & 1 deletion src/cli/system/use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ pub struct SystemUse {
dry_run: bool,

/// Write to this config file or directory
#[clap(long, short, value_name = "PATH", conflicts_with = "global")]
#[clap(
long,
short,
visible_alias = "file",
value_name = "PATH",
conflicts_with = "global"
)]
path: Option<PathBuf>,

/// Skip the confirmation prompt
Expand Down