Skip to content

fix(cli): --viewport <name> silently ignored when config has no [viewports] #119

Description

@aram-devdocs

Found during the e2e test pass for issue #2.

Symptom

When config.viewports is empty (e.g. running without plumb.toml, or with one that has no [viewports.*]), the CLI silently discards any --viewport argument and falls back to a single 1280x800 desktop viewport.

Reproduction

No plumb.toml in CWD:

$ ./target/release/plumb lint plumb-fake://hello --viewport mobile --format json
[ ...one violation, viewport: \"desktop\", rect 1280x800... ]
$ echo $?
3

$ ./target/release/plumb lint plumb-fake://hello --viewport bogus --format json
[ ...one violation, viewport: \"desktop\", rect 1280x800... ]
$ echo $?
3

I asked for mobile (and separately bogus) and got desktop either way, with no warning. The behavior is documented in crates/plumb-cli/src/commands/lint.rs:87 ("Any viewports_arg is ignored — the user can't ask us to inflate viewports they never declared"), but the silent-discard UX is surprising.

When config.viewports is non-empty, --viewport bogus correctly errors with unknown viewport(s): bogus. configured viewports: ... (commands/lint.rs:30). So the inconsistency is only on the no-config path.

Why this matters

Phase 1 ticket #16 acceptance criterion: "`plumb lint --viewport mobile --viewport desktop` runs against exactly those two viewports." Without a config, that criterion silently fails — and the user has no signal that anything is wrong.

Suggested fix

Pick one:

  1. Error explicitly when viewports_arg is non-empty and config.viewports is empty: "no [viewports] configured in plumb.toml — cannot honor --viewport flag."
  2. Treat user-supplied viewport names as default-sized viewports when no config is present (e.g. --viewport mobile → mobile at the canonical 375×667 of common defaults). This is more user-friendly but introduces magic.
  3. Print a stderr warning ("--viewport ignored: no [viewports] in config; falling back to default desktop") and exit 0/3 as today. Cheapest fix.

Parent

Refs #2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliplumb-cli crate — the binarykind:bugSomething brokenphase-1V0 Phase 1 — real CDP driver + foundational rules

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions