Skip to main content

Module config_ops

Module config_ops 

Source
Expand description

gw config command implementation.

Surface (intentionally small):

  • gw config list — merged view + scope annotation
  • gw config get <key> — resolved value (single line)
  • gw config set <key> <value> — write to global, --repo to override
  • gw 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§

ConfigKey
Every key gw exposes through gw config get/set.
Scope

Functions§

get_cmd
gw config get <key> — print the resolved value (repo > global > default). Exits non-zero with no output when nothing is set, matching git 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 ConfigKey in a serialized config tree. Returns None when any segment along the path is missing or null.
parse_value_for
Parse a user-typed string into the JSON value ConfigKey expects.
read_json_or_empty
Read a JSON file as a Value, returning Value::Object({}) when the file does not exist. Parse errors propagate.
repo_path
Resolve the repo-local .cwconfig.json path for the given cwd. Returns Err when cwd is not inside a git repository — --repo is 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 key to value inside root, 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 key from root. No-op if the path doesn’t exist. Empty parent objects are NOT pruned — we want a stable file shape and serde fills missing fields with defaults on load anyway.
write_json
Write value to path pretty-printed, creating parent directories.