Skip to content

fix(cli): reject --json combined with --mermaid#19

Merged
ozgurcd merged 1 commit into
ozgurcd:mainfrom
Arvuno:fix/cli-format-flag-validation
Jun 5, 2026
Merged

fix(cli): reject --json combined with --mermaid#19
ozgurcd merged 1 commit into
ozgurcd:mainfrom
Arvuno:fix/cli-format-flag-validation

Conversation

@Arvuno
Copy link
Copy Markdown
Contributor

@Arvuno Arvuno commented Jun 5, 2026

fix(cli): reject --json combined with --mermaid

--json emits a single {"ok":true,...} JSON envelope and --mermaid
emits a Mermaid diagram. The flag-parsing loop in internal/cli/cli.go
set each flag independently, so passing both was accepted: the
downstream code paths then raced for output shape, with whichever the
consumer reached last silently winning. This broke piping and gave
surprising results to anyone who tried gograph ... --json --mermaid
or --mermaid --json.

After the flag scan, if both are set, print a one-line error to stderr
and exit 1 instead of letting the request through. The error message
names both flags so a user can re-run with the right one.

`--json` emits a single `{"ok":true,...}` JSON envelope and `--mermaid`
emits a Mermaid diagram. The flag-parsing loop in `internal/cli/cli.go`
set each flag independently, so passing both was accepted: the
downstream code paths then raced for output shape, with whichever the
consumer reached last silently winning. This broke piping and gave
surprising results to anyone who tried `gograph ... --json --mermaid`
or `--mermaid --json`.

After the flag scan, if both are set, print a one-line error to stderr
and exit 1 instead of letting the request through. The error message
names both flags so a user can re-run with the right one.
Copy link
Copy Markdown
Owner

@ozgurcd ozgurcd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is needed.

@ozgurcd ozgurcd merged commit 990fff2 into ozgurcd:main Jun 5, 2026
1 check passed
@ozgurcd
Copy link
Copy Markdown
Owner

ozgurcd commented Jun 5, 2026

Thank you

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.

2 participants