-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Summary
When passing --file multiple times (e.g. codegraph complexity --file a.js --file b.js --file c.js), Commander.js silently keeps only the last value. The other files are ignored without any warning, producing unexpectedly empty results.
Reproduction
# Returns results (paginate.js has functions with complexity data):
codegraph complexity --file src/shared/paginate.js -j
# → functions: [printNdjson, paginate, paginateResult]
# Returns empty — Commander only sees the last value (kinds.js has no functions):
codegraph complexity --file src/shared/paginate.js --file src/shared/errors.js --file src/shared/kinds.js -j
# → functions: []Root cause
All 17 commands that accept --file define it as a single-value option:
['-f, --file <path>', 'Scope to file (partial match)']Commander.js treats repeated single-value options as "last wins" — no error, no warning. Users naturally expect multiple --file flags to scope across all specified files.
Affected commands
ast, audit, batch, cfg, check, children, complexity, context, dataflow, flow, fn-impact, owners, query, roles, search, sequence, triage, where
Proposed fix
Two options (not mutually exclusive):
-
Make
--filevariadic — change to<path...>so Commander collects all values into an array. Update query layers to acceptstring | string[]and buildn.file LIKE ? OR n.file LIKE ?clauses. -
Warn on repeated single-value options — detect when Commander overwrites a value and emit a warning. This is harder since Commander doesn't expose a hook for this.
Option 1 is the cleaner fix. The LIKE filter in complexityData (and similar in other query functions) would change from a single AND n.file LIKE ? to AND (n.file LIKE ? OR n.file LIKE ? ...).