diff --git a/docs/cli/index.md b/docs/cli/index.md index 2d626d02c9..1445a19b82 100644 --- a/docs/cli/index.md +++ b/docs/cli/index.md @@ -76,7 +76,7 @@ Answer yes to all confirmation prompts - [`mise run [FLAGS]`](/cli/run.md) - [`mise self-update [FLAGS] [VERSION]`](/cli/self-update.md) - [`mise set [--file ] [-g --global] [ENV_VARS]...`](/cli/set.md) -- [`mise settings [--names] `](/cli/settings.md) +- [`mise settings [--names] [SETTING] `](/cli/settings.md) - [`mise settings add `](/cli/settings/add.md) - [`mise settings get `](/cli/settings/get.md) - [`mise settings ls [--names] [KEY]`](/cli/settings/ls.md) diff --git a/docs/cli/settings.md b/docs/cli/settings.md index 7d3ffb8418..177980be42 100644 --- a/docs/cli/settings.md +++ b/docs/cli/settings.md @@ -1,10 +1,14 @@ # `mise settings` -- **Usage**: `mise settings [--names] ` +- **Usage**: `mise settings [--names] [SETTING] ` - **Source code**: [`src/cli/settings.rs`](https://github.com/jdx/mise/blob/main/src/cli/settings.rs) Manage settings +## Arguments + +### `[SETTING]` + ## Flags ### `--names` @@ -18,3 +22,13 @@ Only display key names for each setting - [`mise settings ls [--names] [KEY]`](/cli/settings/ls.md) - [`mise settings set `](/cli/settings/set.md) - [`mise settings unset `](/cli/settings/unset.md) + +Examples: + # list all settings + $ mise settings + + # get the value of the setting "always_keep_download" + $ mise settings always_keep_download + + # set the value of the setting "always_keep_download" to "true" + $ mise settings always_keep_download=true diff --git a/docs/cli/settings/set.md b/docs/cli/settings/set.md index ab541bf99a..0ee015a867 100644 --- a/docs/cli/settings/set.md +++ b/docs/cli/settings/set.md @@ -20,4 +20,4 @@ The value to set Examples: - mise settings set legacy_version_file true + mise settings legacy_version_file=true diff --git a/docs/configuration.md b/docs/configuration.md index 7a73fe6f30..a9e101fc68 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -263,7 +263,7 @@ in mise and nvm. Here are some of the supported legacy version files: | yarn | `.yarnrc` | In mise these are enabled by default. You can disable them -with `mise settings set legacy_version_file false`. +with `mise settings legacy_version_file=false`. There is a performance cost to having these when they're parsed as it's performed by the plugin in `bin/parse-version-file`. However these are [cached](/cache-behavior) so it's not a huge deal. You may not even notice. diff --git a/docs/configuration/settings.md b/docs/configuration/settings.md index 4ef24a7705..b6a492c404 100644 --- a/docs/configuration/settings.md +++ b/docs/configuration/settings.md @@ -4,7 +4,7 @@ import Settings from '/components/settings.vue'; -The following is a list of all of mise's settings. These can be set via `mise settings set`, +The following is a list of all of mise's settings. These can be set via `mise settings key=value`, by directly modifying `~/.config/mise/config.toml` or local config, or via environment variables. Some of them also can be set via global CLI flags. diff --git a/docs/dev-tools/backends/vfox.md b/docs/dev-tools/backends/vfox.md index ce293a3f6e..41c1457c9b 100644 --- a/docs/dev-tools/backends/vfox.md +++ b/docs/dev-tools/backends/vfox.md @@ -30,8 +30,8 @@ The version will be set in `~/.config/mise/config.toml` with the following forma If you'd like to use vfox plugins by default like on Windows, set the following settings: ```sh -mise settings set asdf false -mise settings set vfox true +mise settings asdf=false +mise settings vfox=true ``` Now you can list available plugins with `mise registry`: diff --git a/docs/lang/node.md b/docs/lang/node.md index 2300d64096..5cd63bf550 100644 --- a/docs/lang/node.md +++ b/docs/lang/node.md @@ -76,7 +76,7 @@ compiling from source for these platforms. To use, first set the mirror url to point to the unofficial builds: ```sh -mise settings set node.mirror_url https://unofficial-builds.nodejs.org/download/release/ +mise settings node.mirror_url=https://unofficial-builds.nodejs.org/download/release/ ``` If your goal is to simply support an alternative arch/os like linux-loong64 or linux-armv6l, this is @@ -86,6 +86,6 @@ than what the official binaries are built with). To use these, set `node.flavor`: ```sh -mise settings set node.flavor musl -mise settings set node.flavor glibc-217 +mise settings node.flavor=musl +mise settings node.flavor=glibc-217 ``` diff --git a/docs/lang/python.md b/docs/lang/python.md index f4c04ac9f6..bb2d74b5eb 100644 --- a/docs/lang/python.md +++ b/docs/lang/python.md @@ -66,7 +66,7 @@ That said, there are some [quirks](https://github.com/indygreg/python-build-standalone/blob/main/docs/quirks.rst) with the precompiled binaries to be aware of. -If you'd like to disable these binaries, set `mise settings set python.compile 1`. +If you'd like to disable these binaries, set `mise settings python.compile=1`. These binaries may not work on older CPUs however you may opt into binaries which are more compatible with older CPUs by setting `MISE_PYTHON_PRECOMPILED_ARCH` with diff --git a/docs/mise.usage.kdl b/docs/mise.usage.kdl index ff0cac5a69..9bd336bfe1 100644 --- a/docs/mise.usage.kdl +++ b/docs/mise.usage.kdl @@ -901,7 +901,7 @@ but managed separately with `mise aliases`" This modifies the contents of ~/.config/mise/config.toml" after_long_help r"Examples: - $ mise settings set legacy_version_file true + $ mise settings legacy_version_file=true " arg "" help="The setting to set" arg "" help="The value to set" diff --git a/docs/paranoid.md b/docs/paranoid.md index 609bcdbdcd..5bcf542830 100644 --- a/docs/paranoid.md +++ b/docs/paranoid.md @@ -8,7 +8,7 @@ restrictive for the benefits. Paranoid mode can be enabled with either `MISE_PARANOID=1` or a setting: ```sh -mise settings set paranoid 1 +mise settings paranoid=1 ``` ## Config files diff --git a/e2e/cli/test_settings_set b/e2e/cli/test_settings_set index 1e9b7fdd5b..0d60f4af73 100644 --- a/e2e/cli/test_settings_set +++ b/e2e/cli/test_settings_set @@ -13,3 +13,6 @@ assert_contains "mise settings" "all_compile = true" mise settings unset all_compile assert "mise settings get all_compile" "false" assert_fail "mise settings get abcdefg" "mise ERROR Unknown setting: abcdefg" +assert "mise settings all_compile" "false" +assert "mise settings all_compile=1" +assert "mise settings all_compile" "true" diff --git a/e2e/plugins/test_tiny b/e2e/plugins/test_tiny index df8fcb8661..693242adcd 100644 --- a/e2e/plugins/test_tiny +++ b/e2e/plugins/test_tiny @@ -24,7 +24,7 @@ mise local tiny@latest assert "mise current tiny" "3.1.0" # test outdated/upgrade -mise settings set experimental true +mise settings experimental=true rm -rf "$MISE_DATA_DIR/installs/tiny" mise use tiny@3 mv "$MISE_DATA_DIR/installs/tiny/"{3.1.0,3.0.0} diff --git a/man/man1/mise.1 b/man/man1/mise.1 index d58a89e106..db325e9702 100644 --- a/man/man1/mise.1 +++ b/man/man1/mise.1 @@ -187,7 +187,7 @@ Examples: $ mise watch build Run `build` tasks repeatedly when files change $ mise settings Show settings in use - $ mise settings set color 0 Disable color by modifying global config file + $ mise settings color=0 Disable color by modifying global config file .SH VERSION v2024.11.23 .SH AUTHORS diff --git a/mise.usage.kdl b/mise.usage.kdl index 7ae1c5c3ef..cdf4239680 100644 --- a/mise.usage.kdl +++ b/mise.usage.kdl @@ -990,7 +990,18 @@ By default, this command modifies `mise.toml` in the current directory." arg "[ENV_VARS]..." help="Environment variable(s) to set\ne.g.: NODE_ENV=production" var=true } cmd "settings" help="Manage settings" { + after_long_help r#"Examples: + # list all settings + $ mise settings + + # get the value of the setting "always_keep_download" + $ mise settings always_keep_download + + # set the value of the setting "always_keep_download" to "true" + $ mise settings always_keep_download=true +"# flag "--names" help="Only display key names for each setting" + arg "[SETTING]" cmd "add" help="Adds a setting to the configuration file" { long_help r"Adds a setting to the configuration file @@ -1045,7 +1056,7 @@ but managed separately with `mise aliases`" This modifies the contents of ~/.config/mise/config.toml" after_long_help r"Examples: - $ mise settings set legacy_version_file true + $ mise settings legacy_version_file=true " arg "" help="The setting to set" arg "" help="The value to set" diff --git a/src/cli/mod.rs b/src/cli/mod.rs index c3f2170a59..451a193987 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -291,7 +291,7 @@ static AFTER_LONG_HELP: &str = color_print::cstr!( $ mise watch build Run `build` tasks repeatedly when files change $ mise settings Show settings in use - $ mise settings set color 0 Disable color by modifying global config file + $ mise settings color=0 Disable color by modifying global config file "# ); diff --git a/src/cli/settings/mod.rs b/src/cli/settings/mod.rs index ec2a8a7755..70a1c4ca1f 100644 --- a/src/cli/settings/mod.rs +++ b/src/cli/settings/mod.rs @@ -8,7 +8,7 @@ mod set; mod unset; #[derive(Debug, clap::Args)] -#[clap(about = "Manage settings")] +#[clap(about = "Manage settings", after_long_help = AFTER_LONG_HELP)] pub struct Settings { #[clap(subcommand)] command: Option, @@ -16,6 +16,9 @@ pub struct Settings { /// Only display key names for each setting #[clap(long, verbatim_doc_comment, alias = "keys")] names: bool, + + #[clap(conflicts_with = "names")] + setting: Option, } #[derive(Debug, Subcommand)] @@ -41,11 +44,37 @@ impl Commands { impl Settings { pub fn run(self) -> Result<()> { - let cmd = self.command.unwrap_or(Commands::Ls(ls::SettingsLs { - key: None, - names: self.names, - })); + let cmd = self.command.unwrap_or_else(|| { + if let Some(setting) = self.setting { + if let Some((setting, value)) = setting.split_once('=') { + Commands::Set(set::SettingsSet { + setting: setting.to_string(), + value: value.to_string(), + }) + } else { + Commands::Get(get::SettingsGet { setting }) + } + } else { + Commands::Ls(ls::SettingsLs { + key: None, + names: self.names, + }) + } + }); cmd.run() } } + +static AFTER_LONG_HELP: &str = color_print::cstr!( + r#"Examples: + # list all settings + $ mise settings + + # get the value of the setting "always_keep_download" + $ mise settings always_keep_download + + # set the value of the setting "always_keep_download" to "true" + $ mise settings always_keep_download=true +"# +); diff --git a/src/cli/settings/set.rs b/src/cli/settings/set.rs index dc7cab0742..b7df414725 100644 --- a/src/cli/settings/set.rs +++ b/src/cli/settings/set.rs @@ -103,6 +103,6 @@ fn parse_duration(value: &str) -> Result { static AFTER_LONG_HELP: &str = color_print::cstr!( r#"Examples: - $ mise settings set legacy_version_file true + $ mise settings legacy_version_file=true "# ); diff --git a/src/config/settings.rs b/src/config/settings.rs index 006eb86201..d3f69e58f9 100644 --- a/src/config/settings.rs +++ b/src/config/settings.rs @@ -329,7 +329,7 @@ impl Settings { pub fn ensure_experimental(&self, what: &str) -> Result<()> { if !self.experimental { - bail!("{what} is experimental. Enable it with `mise settings set experimental true`"); + bail!("{what} is experimental. Enable it with `mise settings experimental=true`"); } Ok(()) } diff --git a/src/plugins/core/python.rs b/src/plugins/core/python.rs index bb4040cfd7..a491969667 100644 --- a/src/plugins/core/python.rs +++ b/src/plugins/core/python.rs @@ -146,7 +146,7 @@ impl PythonPlugin { hint!( "python_compile", "To compile python from source, run", - "mise settings set python.compile 1" + "mise settings python.compile=1" ); } let arch = python_arch(); @@ -168,7 +168,7 @@ impl PythonPlugin { "python_precompiled", "installing precompiled python from indygreg/python-build-standalone\n\ if you experience issues with this python (e.g.: running poetry), switch to python-build by running", - "mise settings set python.compile 1" + "mise settings python.compile=1" ); } @@ -268,7 +268,7 @@ impl PythonPlugin { if let Some(virtualenv) = tv.request.options().get("virtualenv") { if !SETTINGS.experimental { warn!( - "please enable experimental mode with `mise settings set experimental true` \ + "please enable experimental mode with `mise settings experimental=true` \ to use python virtualenv activation" ); } diff --git a/tasks/fig/src/mise.ts b/tasks/fig/src/mise.ts index 7e2a967174..4245fb2914 100644 --- a/tasks/fig/src/mise.ts +++ b/tasks/fig/src/mise.ts @@ -2006,6 +2006,14 @@ const completionSpec: Fig.Spec = { "description": "Only display key names for each setting", "isRepeatable": false } + ], + "args": [ + { + "name": "setting", + "isOptional": true, + "isVariadic": false, + "generators": settingsGenerator + } ] }, {