feat(edit): add --global flag for editing the global config file#9953
Conversation
Greptile SummaryThis PR adds
Confidence Score: 5/5Safe to merge — the flag resolves the target path correctly for all combinations of --global, positional path, and --tool-versions, and the e2e test validates both CLI orderings. All three previously flagged defects (order-dependent overrides_with, wrong tool_versions() merge base, and stale mise edit examples in generate config docs) are fully resolved. No new correctness issues were found in the implementation. No files require special attention. Important Files Changed
Reviews (3): Last reviewed commit: "feat(edit): add --global flag for editin..." | Re-trigger Greptile |
There was a problem hiding this comment.
Code Review
This pull request introduces a --global (or -g) flag to the mise edit and mise generate config commands, allowing users to interact with the global configuration file. The changes include updates to CLI arguments, path resolution logic in src/cli/edit.rs, comprehensive documentation updates across Markdown, man pages, and KDL usage specs, and a new end-to-end test. Feedback identifies a bug where tool version imports are hardcoded to mise.toml regardless of the target path, points out incorrect command names in the generate config examples, and notes that the --global flag implementation is missing for the generate config command despite being documented.
| let path = if let Some(path) = self.path.clone() { | ||
| path | ||
| } else if self.global { | ||
| global_config_path() | ||
| } else { | ||
| PathBuf::from(&*env::MISE_DEFAULT_CONFIG_FILENAME) | ||
| }; |
There was a problem hiding this comment.
The path resolution logic can be simplified by avoiding the clone() on self.path, as self is consumed by the run method.
Note: The path variable determined here should also be passed to self.tool_versions() (at line 160, though not visible in this diff hunk) to ensure that tool versions are imported into the correct file when using --global or an explicit path. Currently, tool_versions() (at line 259) hardcodes the target path to mise.toml, which would cause incorrect behavior when targeting the global config (it would read the local config, merge versions, and then write that result to the global path).
| let path = if let Some(path) = self.path.clone() { | |
| path | |
| } else if self.global { | |
| global_config_path() | |
| } else { | |
| PathBuf::from(&*env::MISE_DEFAULT_CONFIG_FILENAME) | |
| }; | |
| let path = self.path.unwrap_or_else(|| { | |
| if self.global { | |
| global_config_path() | |
| } else { | |
| PathBuf::from(&*env::MISE_DEFAULT_CONFIG_FILENAME) | |
| } | |
| }); |
| } | ||
| cmd config help="Generate a mise.toml file" { | ||
| after_long_help "Examples:\n\n $ mise edit # edit mise.toml interactively\n $ mise edit .mise.toml # edit a specific file\n $ mise edit -y # skip interactive editor\n $ mise edit -n # preview without writing\n" | ||
| after_long_help "Examples:\n\n $ mise edit # edit mise.toml interactively\n $ mise edit .mise.toml # edit a specific file\n $ mise edit -g # edit the global config file\n $ mise edit -y # skip interactive editor\n $ mise edit -n # preview without writing\n" |
There was a problem hiding this comment.
The examples for the generate config command incorrectly use the mise edit command. These should be updated to use mise generate config to provide accurate documentation for this subcommand.
after_long_help "Examples:\n\n $ mise generate config # generate mise.toml interactively\n $ mise generate config .mise.toml # generate a specific file\n $ mise generate config -g # generate the global config file\n $ mise generate config -y # skip interactive editor\n $ mise generate config -n # preview without writing\n"
| cmd config help="Generate a mise.toml file" { | ||
| after_long_help "Examples:\n\n $ mise edit # edit mise.toml interactively\n $ mise edit .mise.toml # edit a specific file\n $ mise edit -y # skip interactive editor\n $ mise edit -n # preview without writing\n" | ||
| after_long_help "Examples:\n\n $ mise edit # edit mise.toml interactively\n $ mise edit .mise.toml # edit a specific file\n $ mise edit -g # edit the global config file\n $ mise edit -y # skip interactive editor\n $ mise edit -n # preview without writing\n" | ||
| flag "-g --global" help="Edit the global config file (~/.config/mise/config.toml)" |
There was a problem hiding this comment.
The help text for the --global flag in the generate config command uses the word "Edit", which is inconsistent with the command's purpose of generating a configuration file. Additionally, the implementation for this flag seems to be missing from src/cli/generate/config.rs, which will result in the flag being documented but not functional.
flag "-g --global" help="Generate the global config file (~/.config/mise/config.toml)"
Addresses discussion jdx#9942.
14332a1 to
1fc23e3
Compare
### 🚀 Features - **(cli)** rename before flag to minimum release age by @risu729 in [#9768](#9768) - **(core)** deprecate default package files by @jdx in [#9970](#9970) - **(edit)** add --global flag for editing the global config file by @fru1tworld in [#9953](#9953) ### 🐛 Bug Fixes - **(aqua)** support cosign public-key bundles by @jdx in [#9972](#9972) - **(backend)** pass install_env to postinstall by @risu729 in [#9930](#9930) - **(backend)** apply install_env to install commands by @risu729 in [#9929](#9929) - **(cargo)** skip binstall for cargo install options by @risu729 in [#9928](#9928) - **(config)** restore MISE_ENV_FILE setting by @risu729 in [#9903](#9903) ### 🚜 Refactor - **(cli)** use tool wording in version env help by @risu729 in [#9906](#9906) - **(conda)** parse tool options locally by @risu729 in [#9960](#9960) - **(core)** parse plugin tool options locally by @risu729 in [#9963](#9963) - **(go)** parse tool options locally by @risu729 in [#9961](#9961) - **(http)** parse tool options locally by @risu729 in [#9870](#9870) ### 📦️ Dependency Updates - lock file maintenance by @renovate[bot] in [#9954](#9954) - lock file maintenance by @renovate[bot] in [#9957](#9957) ### 📦 Registry - use aqua backend for qsv by @risu729 in [#9910](#9910) ### Ci - build/publish snap package for arm64 by @jnsgruk in [#9948](#9948) ### New Contributors - @jnsgruk made their first contribution in [#9948](#9948) ## 📦 Aqua Registry Updates ### New Packages (2) - [`AOMediaCodec/libavif`](https://github.com/AOMediaCodec/libavif) - [`julian7/redact`](https://github.com/julian7/redact) ### Updated Packages (1) - [`apache/jena`](https://github.com/apache/jena)
Summary
--global/-gtomise editfor opening~/.config/mise/config.toml(orMISE_GLOBAL_CONFIG_FILE).mise editin line withmise use --global,mise settings set --global, etc.pathoverrides--global, matching the existing flag-override pattern.Test plan
mise run lint-fixcargo test --bin misebash e2e/run_test e2e/cli/test_edit_globalmise run render