Skip to content

fix: resolve --format option conflict between global and export subcommand#1

Open
ppetru wants to merge 1 commit into
ianpatrickhines:masterfrom
ppetru:fix/export-format-option-conflict
Open

fix: resolve --format option conflict between global and export subcommand#1
ppetru wants to merge 1 commit into
ianpatrickhines:masterfrom
ppetru:fix/export-format-option-conflict

Conversation

@ppetru

@ppetru ppetru commented Feb 7, 2026

Copy link
Copy Markdown

Problem

gwcli drive export <file-id> --format csv fails with:

error: required option '--format <fmt>' not specified

The global --format option (json/table/text output formatting) defined on the root program shadows the export subcommand's --format option (csv/xlsx/pdf export format). Commander.js consumes the flag at the root level, leaving the export command's required --format unsatisfied.

Fix

Enable positionalOptions on the root program and passThroughOptions on the drive command group. This tells Commander.js to stop parsing parent-level options once it encounters a subcommand, allowing each subcommand to define its own options without conflicts.

  • program.enablePositionalOptions() — root stops consuming options after a subcommand name
  • drive.enablePositionalOptions().passThroughOptions() — drive passes unrecognized options through to its subcommands

Testing

Before fix:

$ gwcli drive export <file-id> --format csv
error: required option '--format <fmt>' not specified

After fix:

$ gwcli drive export <file-id> --format csv
Exported to: MAP.csv

$ gwcli --format json drive search "name contains 'test'"
[...]  # global --format json still works

…mmand

The global --format option (json/table/text output formatting) shadows the
export subcommand's --format option (csv/xlsx/pdf export format), causing
Commander.js to consume the flag at the root level and leaving the export
command's required --format unsatisfied.

Fix by enabling positional options on the root program and pass-through
options on the drive command group, so Commander.js stops parsing parent
options once it encounters a subcommand name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant