Description
When running codegate scan with a URL target, certain combinations of flags and stdout piping produce an intermittent error: too many arguments for 'scan'. Expected 1 argument but got 2. error from Commander.js.
Steps to Reproduce
# This works:
codegate scan "https://github.com/owner/repo" --deep --force --format json --no-tui --output /tmp/report.json
# This intermittently fails:
codegate scan "https://github.com/owner/repo" --deep --force --format json --no-tui | tee /tmp/report.json
The error does not reproduce when:
- Using
--output <file> instead of piping stdout
- Running without
tee or other pipe consumers
- Running with fewer flags (e.g.,
--deep alone or --force alone works)
Investigation Notes
- Commander.js argument parsing is correct — a minimal reproduction with
createCli() and overridden action handler parses all arguments correctly (target, --deep, --force, --format json, --no-tui).
- The error seems related to stdout piping changing
process.stdout.isTTY from true to false, which may affect code paths downstream of argument parsing.
- The
--no-tui option uses Commander's --no-* negation pattern, which creates an implicit --tui boolean. This could interact unexpectedly with TTY detection.
Where to Look
src/cli.ts — addScanCommand() function (~line 383), specifically the .command("scan [target]") definition and how isNoTuiEnabled() interacts with the action handler
- The interplay between
--no-tui, deps.isTTY(), and Commander's argument parsing when stdout is not a TTY
Workaround
Use the --output <path> flag to write reports to a file instead of piping stdout:
codegate scan "https://github.com/owner/repo" --deep --force --format json --no-tui --output /tmp/report.json
Description
When running
codegate scanwith a URL target, certain combinations of flags and stdout piping produce an intermittenterror: too many arguments for 'scan'. Expected 1 argument but got 2.error from Commander.js.Steps to Reproduce
The error does not reproduce when:
--output <file>instead of piping stdoutteeor other pipe consumers--deepalone or--forcealone works)Investigation Notes
createCli()and overridden action handler parses all arguments correctly (target,--deep,--force,--format json,--no-tui).process.stdout.isTTYfromtruetofalse, which may affect code paths downstream of argument parsing.--no-tuioption uses Commander's--no-*negation pattern, which creates an implicit--tuiboolean. This could interact unexpectedly with TTY detection.Where to Look
src/cli.ts—addScanCommand()function (~line 383), specifically the.command("scan [target]")definition and howisNoTuiEnabled()interacts with the action handler--no-tui,deps.isTTY(), and Commander's argument parsing when stdout is not a TTYWorkaround
Use the
--output <path>flag to write reports to a file instead of piping stdout:codegate scan "https://github.com/owner/repo" --deep --force --format json --no-tui --output /tmp/report.json