Skip to content

Fix root CLI behavior to allow --help and other lightweight flags without requiring config #114

@ephur

Description

@ephur

Currently, some commands (including --help) fail or behave unexpectedly if a config file is missing. This is due to logic in the root command eagerly loading config or performing work before Click has a chance to dispatch subcommands.

Problem

The root command appears to evaluate configuration at startup, preventing Click from lazily handling flags like --help, --version, etc. When the config is missing, even introspection commands fail — which is not expected behavior for CLI tools.

Solution

Refactor the CLI architecture so that:

  • The root command does not load or validate config directly
  • Any work that depends on config is pushed down into subcommands
  • Add a decorator or helper (e.g. @with_config(optional=True)) to selectively load config only when needed
  • Use click.Context.obj to store config state if needed across commands

This ensures:

  • --help, --version, etc., work regardless of the filesystem
  • Config validation only happens where relevant
  • Cleaner separation of command responsibility

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliCommand-line interface and usabilitydeveloper-experienceDX, tooling, and ergonomicstriagedIssue has received an initial AI or manual triage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions