FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(cli): accept --json flag in batch command as no-op by carlos-alm · Pull Request #1563 · optave/ops-codegraph-tool · GitHub

fix(cli): accept --json flag in batch command as no-op - #1563

Merged
carlos-alm merged 1 commit into
mainfrom
fix/batch-json-flag-1561
Jun 16, 2026
Merged

fix(cli): accept --json flag in batch command as no-op#1563
carlos-alm merged 1 commit into
mainfrom
fix/batch-json-flag-1561

Conversation

Copy link
Copy Markdown
Contributor

Summary

  • The batch command was rejecting --json / -j flags with "error: unknown option '--json'"
  • Every other codegraph command that outputs JSON accepts these flags
  • Since batch always outputs JSON, the flag is added as an accepted no-op to prevent script errors

Changes

  • src/cli/commands/batch.ts: Added ['-j, --json', 'Accepted for script compatibility (batch always outputs JSON)'] to the options array
  • tests/integration/batch.test.ts: Added two CLI smoke tests verifying --json and -j flags are accepted without error

Test plan

  • node_modules/.bin/vitest run tests/integration/batch.test.ts — all 26 tests pass (including 2 new ones covering --json and -j flag acceptance)
  • biome check src/ tests/ — no lint issues

Closes #1561

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds -j/--json as accepted no-op flags on the batch command so scripts that pass these flags (consistent with every other codegraph command) no longer get rejected with "unknown option". Because batch always outputs JSON, the flag is intentionally parsed but never consumed.

  • src/cli/commands/batch.ts: One-line addition to the options array; the option is a declared no-op and is not referenced in validate or execute, which is correct.
  • tests/integration/batch.test.ts: Two integration smoke tests confirm both the long (--json) and short (-j) forms are accepted and that the output remains valid JSON with the expected fields.

Confidence Score: 5/5

Safe to merge — adds a harmless no-op flag declaration and two matching integration tests with no behavioral changes to existing logic.

The change is a one-line option declaration that is never consumed by validate or execute, perfectly matching the always-JSON contract already documented in the command description. The two new integration tests cover both the long and short flag forms, and the existing 24 tests remain unaffected.

No files require special attention.

Important Files Changed

Filename Overview
src/cli/commands/batch.ts Adds -j/--json as an accepted no-op option so scripts passing the flag no longer receive "unknown option" errors; the option is declared but intentionally unused in execute/validate.
tests/integration/batch.test.ts Adds two smoke tests confirming --json and -j flags are accepted and that the output remains valid JSON with the expected shape.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[CLI invocation: batch <cmd> <targets>] --> B{flags present?}
    B -- "--json / -j (new)" --> C[Commander parses flag\nopts.json = true]
    B -- "other flags" --> D[Commander parses normally]
    C --> E[validate: kind check only\nopts.json ignored]
    D --> E
    E --> F[execute: load targets\nfrom args / file / stdin]
    F --> G[batchQuery\nopts.json never referenced]
    G --> H[Output: always JSON]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[CLI invocation: batch <cmd> <targets>] --> B{flags present?}
    B -- "--json / -j (new)" --> C[Commander parses flag\nopts.json = true]
    B -- "other flags" --> D[Commander parses normally]
    C --> E[validate: kind check only\nopts.json ignored]
    D --> E
    E --> F[execute: load targets\nfrom args / file / stdin]
    F --> G[batchQuery\nopts.json never referenced]
    G --> H[Output: always JSON]
Loading

Reviews (1): Last reviewed commit: "fix(cli): accept --json flag in batch co..." | Re-trigger Greptile

carlos-alm merged commit 1b81e31 into main Jun 16, 2026
24 checks passed
carlos-alm deleted the fix/batch-json-flag-1561 branch June 16, 2026 21:16
github-actions Bot locked and limited conversation to collaborators Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: batch command rejects --json flag with error instead of accepting it silently

1 participant


Back | FazBrowse Home | New Git URL