Skip to content

feat(edit): add --global flag for editing the global config file#9953

Merged
jdx merged 1 commit into
jdx:mainfrom
fru1tworld:feat/edit-global-flag
May 18, 2026
Merged

feat(edit): add --global flag for editing the global config file#9953
jdx merged 1 commit into
jdx:mainfrom
fru1tworld:feat/edit-global-flag

Conversation

@fru1tworld

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • mise run lint-fix
  • cargo test --bin mise
  • bash e2e/run_test e2e/cli/test_edit_global
  • mise run render

@greptile-apps

greptile-apps Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds --global/-g to mise edit (and mise generate config) to open ~/.config/mise/config.toml (or $MISE_GLOBAL_CONFIG_FILE), bringing it in line with other mise commands that accept --global. All issues flagged in previous review rounds have been addressed.

  • Path-priority logic lives entirely in run() via an if let Some(path) chain, so a positional path always wins over --global regardless of CLI argument order — the e2e test now covers both orderings explicitly.
  • tool_versions() was updated to accept the resolved path instead of hardcoding MISE_DEFAULT_CONFIG_FILENAME, fixing the previously flagged merge-target bug.
  • generate/config.rs was refactored from #[clap(flatten)] to forwarding through Edit::new(), and its own help text was corrected from mise edit examples to mise generate config examples.

Confidence Score: 5/5

Safe 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

Filename Overview
src/cli/edit.rs Adds --global/-g flag; path-priority logic in run() is correct; tool_versions() now receives the resolved path instead of hardcoding the default
src/cli/generate/config.rs Refactored from #[clap(flatten)] edit: Edit to its own fields forwarded via Edit::new(); corrected example strings from mise edit to mise generate config
e2e/cli/test_edit_global New e2e test covers both flag orderings, regression guard for default path, and the --tool-versions merge-target fix
docs/cli/edit.md Usage line updated to [FLAGS]; new -g --global flag documented with example
docs/cli/generate/config.md Examples corrected from mise edit to mise generate config; new -g flag documented
mise.usage.kdl KDL spec updated with -g --global flag for both edit and generate config commands
xtasks/fig/src/mise.ts Fig completions updated with --global option for edit and generate config

Reviews (3): Last reviewed commit: "feat(edit): add --global flag for editin..." | Re-trigger Greptile

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/cli/edit.rs
Comment on lines +150 to +156
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)
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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).

Suggested change
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)
}
});

Comment thread mise.usage.kdl Outdated
}
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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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"

Comment thread mise.usage.kdl Outdated
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)"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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)"

Comment thread src/cli/edit.rs Outdated
Comment thread docs/cli/generate/config.md Outdated
@fru1tworld fru1tworld marked this pull request as draft May 18, 2026 05:05
@fru1tworld fru1tworld force-pushed the feat/edit-global-flag branch from 14332a1 to 1fc23e3 Compare May 18, 2026 05:35
@fru1tworld fru1tworld marked this pull request as ready for review May 18, 2026 05:36
@jdx jdx merged commit c1f76ac into jdx:main May 18, 2026
33 checks passed
mise-en-dev added a commit that referenced this pull request May 19, 2026
### 🚀 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants