feat: surface active TOML config path in --help (issue #213)#224
Merged
Conversation
… subcommand Resolves a discoverability gap reported by an external user: `all-smi --help` did not reveal where the TOML config file lives, and the only pointer (`--config <PATH>`'s flag doc) redirected to `config init`, a side-effecting command that writes a file. Changes: * `src/cli.rs` — compose `after_help` at runtime via `build_command_with_runtime_help()` so the resolved per-user config path (honouring `$HOME` / `$XDG_CONFIG_HOME` / `%APPDATA%`) can be injected into `--help`. New `config_help_block()` renders a short "Configuration file" section with the active path plus an `(active)` / `(not found)` marker. Reword `--config <PATH>` doc to point at the read-only discovery path instead of `config init`. * `src/main.rs` — parse via `Cli::from_arg_matches` so the runtime help surface reaches `--help` / `-h`. * `src/cli_config.rs` — add `ConfigAction::Path(ConfigPathArgs)` with `--json` for scripts. * `src/config_cmd/path.rs` — new strictly-read-only runner. Prints the active path and ordered search list; supports `--json` with a stable schema (`active`, `exists`, `overridden`, `search_order`). Honours `--config <PATH>` by reporting the override and suppressing the candidate list. Never opens a file for write — regression-guarded by a unit test. * `src/common/paths.rs` — shared `format_path_with_existence()` helper used by both the help block and the `config path` runner so the marker vocabulary stays consistent. Degrades gracefully when no home directory is resolvable. * `docs/man/all-smi.1` — add `config` subcommand to COMMANDS, enumerate per-platform `config.toml` paths in FILES, and point ENERGY ACCOUNTING at the new `config path` rather than `config init`. * `README.md` — add `config path` to the helpers list and tighten the `--config` flag wording to mention the read-only discovery surface. * `tests/config_path_help_test.rs` + inline unit tests — assert the Configuration file block renders in `--help`, the Energy Session block survives the runtime composition, the existence marker is present, the `--config` flag help no longer only redirects to a side-effecting command, and the new `config path` subcommand (including `--json`) parses cleanly through the runtime-composed command tree. Acceptance criteria (issue #213): - `--help` / `-h` show the active config path with an existence marker - The displayed path matches `paths::default_config_path()` - The block points to `config init`, `config print`, and `--config` - `all-smi config path` is read-only and never creates a file - Man page `FILES` documents per-platform `config.toml` locations - No-home-directory case degrades gracefully with a clear message - Tests cover the help block and the new command; `cargo fmt --check` and `cargo clippy --lib --tests -- -D warnings` pass Closes #213
inureyes
added a commit
that referenced
this pull request
May 24, 2026
Refs #221, #222, #224, #225, #226, #227. Align config path active discovery with the implicit loader's first-existing-candidate semantics, correct record output help and resolver docs against the binary default, and make the swap-color regression test derive crossterm's current Red SGR sequence instead of hard-coding older encodings.
inureyes
added a commit
that referenced
this pull request
May 24, 2026
Refs #221, #222, #224, #225, #226, #227. Align config path active discovery with the implicit loader's first-existing-candidate semantics, correct record output help and resolver docs against the binary default, and make the swap-color regression test derive crossterm's current Red SGR sequence instead of hard-coding older encodings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #213.
Adds the resolved TOML config file location to
all-smi --help, introduces a strictly read-onlyall-smi config pathsubcommand for scripting/discovery, and fills the config-path gap in the man pageFILESsection.Before
all-smi --helpdid not reveal where the config file lives. The only pointer was the--config <PATH>flag description, which redirected toall-smi config init— a command that writes a file as a side effect. A new user had no way, from-h/--helpalone, to know a config file even existed or where it would go.After
all-smi --helpandall-smi -hshow a new "Configuration file" section with the resolved per-user path ($HOME/$XDG_CONFIG_HOME/%APPDATA%aware) plus an(active)/(not found)marker.all-smi config path [--json]prints the active path + ordered candidate search list with no file writes. The JSON form has a stable schema (active,exists,overridden,search_order).--config <PATH>is honoured byconfig path(reports the override + suppresses the search list).FILESenumerates per-platformconfig.tomlpaths and points at the new discovery surface.config pathto the helpers list and tightens the--configflag wording.Implementation notes
after_helpis composed at runtime incli::build_command_with_runtime_help()because the resolved path embeds the user's$HOME/$XDG_CONFIG_HOME, which a static#[command(after_help = ...)]cannot do.main.rsparses viaCli::from_arg_matchesso the runtime composition reaches--help.paths::format_path_with_existence()keeps the existence marker vocabulary consistent between--helpandconfig path.config pathis regression-tested (run_path_does_not_create_file).(no config path resolvable — set $HOME or $XDG_CONFIG_HOME)).Files changed
src/cli.rs— dynamicafter_helpbuilder; reworded--configdoc.src/cli_config.rs— newConfigAction::Path(ConfigPathArgs).src/config_cmd/mod.rs+src/config_cmd/path.rs— read-only runner with text + JSON output.src/common/paths.rs— shared existence-marker formatter.src/main.rs— parse viaCli::from_arg_matchesafter runtime composition.docs/man/all-smi.1—configsubcommand in COMMANDS; per-platform paths in FILES; ENERGY ACCOUNTING points atconfig path.README.md—config pathhelper entry; tightened--configwording.tests/config_path_help_test.rs(integration) + inline unit tests inpaths.rs,cli.rs,config_cmd/path.rs.Test plan
cargo fmt --checkcargo clippy --lib --tests -- -D warningscargo test --test config_path_help_test(7 new integration tests)cargo test --lib common::paths::tests(3 new + 7 existing pass)cargo test --bin all-smi config_cmd::path(6 new tests pass)cargo test --bin all-smi cli::tests(3 new + 5 existing pass)cargo test --bin all-smi config_cmd(existing render tests still pass)cargo test --test config_file_integration_test(existing 14 tests still pass)./target/debug/all-smi --helpshows Configuration file + Energy Session blocks./target/debug/all-smi config pathprints active path + search order./target/debug/all-smi config path --jsonemits stable JSON schemaconfig pathdoes NOT create the file (no~/.config/all-smi/after invocation; no/tmp/explicit_nope.tomlafter--configoverride)groff -Tutf8 -man docs/man/all-smi.1renders cleanly; new FILES entries display correctly