Add --config flag and WARD_CONFIG env for explicit config path #38

Closed
opened 2026-06-03 22:33:03 +00:00 by coilysiren · 0 comments
Owner

Scope

Sub-issue of #4. Add explicit config-path resolution to ward so consumers can point at a specific .ward/ward.yaml without relying on the cwd walk-up.

What

  • Persistent --config <path> flag on the root ward command.
  • WARD_CONFIG environment variable as the env-var equivalent.
  • Resolution order: --config > $WARD_CONFIG > existing walk-up discoverConfig(cwd).
  • Explicit paths bypass the walk-up entirely — if the file is missing or unreadable, ward fails with a clear error rather than silently falling back.
  • All commands that today call loadDefault() / discoverConfig(cwd) pick this up: exec, lint, future doctor.

Wrinkle

execCommand() builds its sub-command tree at app-construction time (before app.Run parses flags). The implementation pre-parses --config from os.Args and WARD_CONFIG from the environment before cli.Command construction, then registers --config as a real top-level flag so help and the urfave parser stay consistent.

Acceptance

  • ward --config /abs/path/ward.yaml exec build runs the verb from that file.
  • WARD_CONFIG=/abs/path/ward.yaml ward exec build same.
  • --config wins over WARD_CONFIG.
  • Missing explicit path returns a non-zero exit with the path quoted in the error.
  • Walk-up behavior unchanged when neither flag nor env is set.
  • docs/config-discovery.md documents the new resolution order.
  • Tests cover: flag-only, env-only, flag-over-env, explicit-missing, fallback-to-walk-up.

Out of scope

  • security: schema (separate sub-issue of #4).
  • doctor security (separate sub-issue of #4).
  • Hook wiring for protected binaries (separate sub-issue of #4).
## Scope Sub-issue of #4. Add explicit config-path resolution to ward so consumers can point at a specific `.ward/ward.yaml` without relying on the cwd walk-up. ## What - Persistent `--config <path>` flag on the root `ward` command. - `WARD_CONFIG` environment variable as the env-var equivalent. - Resolution order: `--config` > `$WARD_CONFIG` > existing walk-up `discoverConfig(cwd)`. - Explicit paths bypass the walk-up entirely — if the file is missing or unreadable, ward fails with a clear error rather than silently falling back. - All commands that today call `loadDefault()` / `discoverConfig(cwd)` pick this up: `exec`, `lint`, future `doctor`. ## Wrinkle `execCommand()` builds its sub-command tree at app-construction time (before `app.Run` parses flags). The implementation pre-parses `--config` from `os.Args` and `WARD_CONFIG` from the environment before `cli.Command` construction, then registers `--config` as a real top-level flag so help and the urfave parser stay consistent. ## Acceptance - `ward --config /abs/path/ward.yaml exec build` runs the verb from that file. - `WARD_CONFIG=/abs/path/ward.yaml ward exec build` same. - `--config` wins over `WARD_CONFIG`. - Missing explicit path returns a non-zero exit with the path quoted in the error. - Walk-up behavior unchanged when neither flag nor env is set. - `docs/config-discovery.md` documents the new resolution order. - Tests cover: flag-only, env-only, flag-over-env, explicit-missing, fallback-to-walk-up. ## Out of scope - `security:` schema (separate sub-issue of #4). - `doctor security` (separate sub-issue of #4). - Hook wiring for protected binaries (separate sub-issue of #4).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
coilyco-flight-deck/ward#38
No description provided.