Skip to content

Top-level args (--project / --schemas) aren't globalrivet validate --project X errors instead of working in any position #500

@avrabe

Description

@avrabe

Friction (hit while implementing #488)

--project / -p (and --schemas) are declared on the top-level Cli struct without global = true, so they only parse before the subcommand:

  • rivet --project /path validate
  • rivet validate --project /path → clap error, and with --format json the run produces empty stdout (the error goes to stderr), which is a confusing failure mode for anything shelling out to rivet.

This cost me a debug cycle in the --new-since feature (#488): a subprocess rivet validate --format json --project <dir> returned empty JSON → EOF while parsing a value, with no hint that the arg position was the problem. Many users (and tools) reasonably expect rivet <subcommand> --project X to work, since --project reads as a global option.

Suggested fix

Mark the top-level path args global = true:

#[arg(short, long, default_value = ".", global = true)]
project: PathBuf,
#[arg(long, global = true)]
schemas_dir: Option<PathBuf>,  // (or whatever the schemas arg is)

Then --project/--schemas work in any position. Low-risk (additive — the pre-subcommand form still works); worth a quick check that global args with a default_value behave as expected in clap derive.

(Workaround that finally helped: put --project before the subcommand.)

Found in the hourly dogfooding loop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions