feat(cli): add --all-sources flag to list command#8019
Conversation
AI-assisted: code generated with opencode with GPT-5.2 Codex and reviewed by author
Summary of ChangesHello @TylerHillery, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR adds a new --all-sources flag to the mise ls command that displays all tracked configuration sources for each tool, showing where each version is specified across different config files.
Changes:
- Added
--all-sourcesflag with appropriate CLI conflicts to prevent incompatible flag combinations - Implemented logic to collect and display multiple config sources per tool version
- Updated JSON output to include a
sourcesarray when the flag is used
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/cli/ls.rs | Core implementation of the --all-sources flag including source collection, display logic, and JSON serialization |
| src/ui/table.rs | Fixed table formatting by removing leading space before applying regex replacements |
| mise.usage.kdl | Added --all-sources flag documentation and usage example |
| docs/cli/ls.md | Updated documentation with --all-sources flag description and example |
| e2e/cli/test_ls_all_sources | Added end-to-end test for the new --all-sources functionality |
Comments suppressed due to low confidence (1)
src/cli/ls.rs:1
- The variable
lineis shadowed twice in consecutive lines. Consider using different variable names (e.g.,trimmed_lineandformatted_line) to improve readability and make the transformation steps clearer.
use comfy_table::{Attribute, Cell, Color};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -342,10 +458,56 @@ impl Row { | |||
| } | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
This helper function lacks documentation. Add a doc comment explaining what the tuple represents (e.g., backend short name and tool version pathname) and when this key format is used.
| /// Returns the key used in `SourcesMap` to uniquely identify a tool version. | |
| /// | |
| /// The tuple consists of: | |
| /// - the backend's short name, and | |
| /// - the tool version pathname. | |
| /// | |
| /// This key format is used whenever we need to group or look up source | |
| /// information for a specific tool version across backends. |
| fn source_key(tv: &ToolVersion) -> (String, String) { | ||
| (tv.ba().short.to_string(), tv.tv_pathname()) | ||
| } | ||
|
|
There was a problem hiding this comment.
Missing documentation for this function. Add a doc comment explaining that it collects all config sources for each tool version in the toolset and returns a mapping keyed by (backend, pathname).
| /// Collects all config sources for each tool version in the toolset and | |
| /// returns a mapping keyed by `(backend, pathname)`. |
| async fn version_status_from_sources( | ||
| config: &Arc<Config>, | ||
| (ls, p, tv, has_sources): (&Ls, &dyn Backend, &ToolVersion, bool), | ||
| ) -> VersionStatus { |
There was a problem hiding this comment.
This function lacks documentation. Add a doc comment explaining how it differs from version_status_from (specifically that it determines status based on whether sources exist rather than a specific source).
There was a problem hiding this comment.
Code Review
This pull request introduces the --all-sources flag to the ls command, which is a great feature for visibility into tool configurations. The implementation is well-structured, including documentation and end-to-end tests.
I've found a critical issue where the new functionality might not show all sources correctly due to premature deduplication of tool versions. I've left a comment with a suggested fix.
Additionally, I've noticed some code duplication between the new logic and the existing ls implementation. I've included a suggestion for refactoring this to improve maintainability.
Overall, this is a solid contribution, especially for someone new to Rust. Addressing these points will make it even better.
src/cli/ls.rs
Outdated
| .list_all_versions(config) | ||
| .await? |
There was a problem hiding this comment.
list_all_versions() uses unique_by() which removes tool versions with the same version string, even if they come from different sources. This will cause --all-sources to miss some sources if they specify the same tool version.
To fix this, you should use list_current_versions() instead, which returns all resolved versions from the toolset without deduplication. This also has the benefit of not including installed-but-not-requested versions, which is the correct behavior for --all-sources.
| .list_all_versions(config) | |
| .await? | |
| .list_current_versions() |
| async fn get_all_sources_runtime_list( | ||
| &self, | ||
| config: &Arc<Config>, | ||
| ) -> Result<(Vec<RuntimeRow<'_>>, SourcesMap)> { | ||
| let mut trs = ToolRequestSet::new(); | ||
| for cf in config.get_tracked_config_files().await?.values() { | ||
| let cf_trs = cf.to_tool_request_set()?; | ||
| for (_ba, tool_requests, _source) in cf_trs.into_iter() { | ||
| for tr in tool_requests { | ||
| trs.add_version(tr.clone(), tr.source()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| let mut ts = Toolset::from(trs); | ||
| ts.resolve(config).await?; | ||
| let sources_map = collect_sources(&ts); | ||
|
|
||
| let rvs: Vec<RuntimeRow<'_>> = ts | ||
| .list_all_versions(config) | ||
| .await? | ||
| .into_iter() | ||
| .map(|(b, tv)| ((b, tv.version.clone()), tv)) | ||
| .filter(|((b, _), _)| match &self.installed_tool { | ||
| Some(p) => p.contains(b.ba()), | ||
| None => true, | ||
| }) | ||
| .sorted_by_cached_key(|((plugin_name, version), _)| { | ||
| ( | ||
| plugin_name.clone(), | ||
| Versioning::new(version), | ||
| version.clone(), | ||
| ) | ||
| }) | ||
| .map(|(k, tv)| (self, k.0, tv.clone(), tv.request.source().clone())) | ||
| // if it isn't installed and it's not specified, don't show it | ||
| .filter(|(_ls, p, tv, source)| { | ||
| !source.is_unknown() || p.is_version_installed(config, tv, true) | ||
| }) | ||
| .filter(|(_ls, p, _, _)| match &self.installed_tool { | ||
| Some(backend) => backend.contains(p.ba()), | ||
| None => true, | ||
| }) | ||
| .collect(); | ||
|
|
||
| Ok((rvs, sources_map)) | ||
| } |
There was a problem hiding this comment.
There is significant code duplication between this function (get_all_sources_runtime_list) and get_runtime_list (lines 267-325). The logic for filtering and sorting the runtime versions from a Toolset is identical in both.
To improve maintainability, you could extract this common logic into a helper function. This would reduce code duplication and make future changes easier.
For example, you could create a function build_runtime_rows within impl Ls that takes a Vec<(Arc<dyn Backend>, ToolVersion)> and returns Vec<RuntimeRow<'_>>. Then you can call this helper from both get_runtime_list and get_all_sources_runtime_list.
|
I think |
### 🚀 Features - **(env)** add shell-style variable expansion in env values by @jdx in [#8029](#8029) - **(list)** add --all-sources flag to list command by @TylerHillery in [#8019](#8019) ### 🐛 Bug Fixes - **(gem)** Windows support for gem backend by @my1e5 in [#8031](#8031) - **(gem)** revert gem.rs script newline change by @my1e5 in [#8034](#8034) - **(lock)** write tools to lockfile matching their source config by @jdx in [#8012](#8012) - **(ls)** sort sources deterministically in --all-sources output by @jdx in [#8037](#8037) - **(task)** auto-install tools from mise.toml for file tasks by @jdx in [#8030](#8030) ### 📚 Documentation - fix wrong positions of `mise run` flags by @muzimuzhi in [#8036](#8036) ### 📦️ Dependency Updates - update ghcr.io/jdx/mise:copr docker digest to 3e00d7d by @renovate[bot] in [#8023](#8023) - update ghcr.io/jdx/mise:alpine docker digest to 0ced1b3 by @renovate[bot] in [#8022](#8022) ### 📦 Registry - add tirith ([github:sheeki03/tirith](https://github.com/sheeki03/tirith)) by @sheeki03 in [#8024](#8024) - add mas by @TyceHerrman in [#8032](#8032) ### Security - **(deps)** update time crate to 0.3.47 to fix RUSTSEC-2026-0009 by @jdx in [#8026](#8026) ### New Contributors - @sheeki03 made their first contribution in [#8024](#8024) - @TylerHillery made their first contribution in [#8019](#8019) ## 📦 Aqua Registry Updates #### New Packages (1) - [`kubernetes-sigs/kubectl-validate`](https://github.com/kubernetes-sigs/kubectl-validate) #### Updated Packages (6) - [`flux-iac/tofu-controller/tfctl`](https://github.com/flux-iac/tofu-controller/tfctl) - [`gogs/gogs`](https://github.com/gogs/gogs) - [`j178/prek`](https://github.com/j178/prek) - [`syncthing/syncthing`](https://github.com/syncthing/syncthing) - [`tuist/tuist`](https://github.com/tuist/tuist) - [`yaml/yamlscript`](https://github.com/yaml/yamlscript)
## Summary - Add `mise ls --all-sources` to show all tracked configs for each tool. ## Context Implements the UX discussed in jdx#7810 and shown in the screen recording. I’m new to Rust and used AI to generate the implementation. While I reviewed the code at a high level, I’m not yet confident in Rust idioms or correctness. I'm open to feedback. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: jdx <216188+jdx@users.noreply.github.com>
### 🚀 Features - **(env)** add shell-style variable expansion in env values by @jdx in [jdx#8029](jdx#8029) - **(list)** add --all-sources flag to list command by @TylerHillery in [jdx#8019](jdx#8019) ### 🐛 Bug Fixes - **(gem)** Windows support for gem backend by @my1e5 in [jdx#8031](jdx#8031) - **(gem)** revert gem.rs script newline change by @my1e5 in [jdx#8034](jdx#8034) - **(lock)** write tools to lockfile matching their source config by @jdx in [jdx#8012](jdx#8012) - **(ls)** sort sources deterministically in --all-sources output by @jdx in [jdx#8037](jdx#8037) - **(task)** auto-install tools from mise.toml for file tasks by @jdx in [jdx#8030](jdx#8030) ### 📚 Documentation - fix wrong positions of `mise run` flags by @muzimuzhi in [jdx#8036](jdx#8036) ### 📦️ Dependency Updates - update ghcr.io/jdx/mise:copr docker digest to 3e00d7d by @renovate[bot] in [jdx#8023](jdx#8023) - update ghcr.io/jdx/mise:alpine docker digest to 0ced1b3 by @renovate[bot] in [jdx#8022](jdx#8022) ### 📦 Registry - add tirith ([github:sheeki03/tirith](https://github.com/sheeki03/tirith)) by @sheeki03 in [jdx#8024](jdx#8024) - add mas by @TyceHerrman in [jdx#8032](jdx#8032) ### Security - **(deps)** update time crate to 0.3.47 to fix RUSTSEC-2026-0009 by @jdx in [jdx#8026](jdx#8026) ### New Contributors - @sheeki03 made their first contribution in [jdx#8024](jdx#8024) - @TylerHillery made their first contribution in [jdx#8019](jdx#8019) ## 📦 Aqua Registry Updates #### New Packages (1) - [`kubernetes-sigs/kubectl-validate`](https://github.com/kubernetes-sigs/kubectl-validate) #### Updated Packages (6) - [`flux-iac/tofu-controller/tfctl`](https://github.com/flux-iac/tofu-controller/tfctl) - [`gogs/gogs`](https://github.com/gogs/gogs) - [`j178/prek`](https://github.com/j178/prek) - [`syncthing/syncthing`](https://github.com/syncthing/syncthing) - [`tuist/tuist`](https://github.com/tuist/tuist) - [`yaml/yamlscript`](https://github.com/yaml/yamlscript)
Summary
mise ls --all-sourcesto show all tracked configs for each tool.Context
Implements the UX discussed in #7810 and shown in the screen recording. I’m new to Rust and used AI to generate the implementation. While I reviewed the code at a high level, I’m not yet confident in Rust idioms or correctness. I'm open to feedback.