Expand description
gw config command implementation.
Surface (intentionally small):
gw config list— merged view + scope annotationgw config get <key>— resolved value (single line)gw config set <key> <value>— write to global,--repoto overridegw config edit— TUI editor switching global ↔ repo
Scope model:
- global:
~/.config/git-worktree-manager/config.json - repo:
<repo-root>/.cwconfig.json
Resolved value follows the same precedence as runtime
load_effective_config: defaults < global < repo.
The settable surface is the ConfigKey enum — clap derives the value
parser from it, so gw config set <key> auto-completes / errors against
the same list of keys the code understands. New keys go here and become
settable everywhere at once.
Enums§
Functions§
- get_cmd
gw config get <key>— print the resolved value (repo > global > default). Exits non-zero with no output when nothing is set, matchinggit config’s convention for script consumers.- global_
path - Where the global config file lives (delegates to
crate::config). - list_
cmd gw config list— render every known key with its resolved value and the scope that supplied it.- lookup_
value - Look up a
ConfigKeyin a serialized config tree. ReturnsNonewhen any segment along the path is missing or null. - parse_
value_ for - Parse a user-typed string into the JSON value
ConfigKeyexpects. - read_
json_ or_ empty - Read a JSON file as a
Value, returningValue::Object({})when the file does not exist. Parse errors propagate. - repo_
path - Resolve the repo-local
.cwconfig.jsonpath for the given cwd. ReturnsErrwhen cwd is not inside a git repository —--repois a no-op outside one and we surface that as an error rather than silently writing under the user’s home. - set_cmd
gw config set <key> <value> [--repo].- set_
value - Set
keytovalueinsideroot, creating intermediate objects as needed. Errors only if an intermediate path collides with a non-object (the only way this can happen is if the file was hand-edited). - unset_
value - Remove
keyfromroot. No-op if the path doesn’t exist. Empty parent objects are NOT pruned — we want a stable file shape andserdefills missing fields with defaults on load anyway. - write_
json - Write
valuetopathpretty-printed, creating parent directories.