Skip to content

Fix json mode#124

Merged
joshi4 merged 2 commits into
mainfrom
shantanu/eng-1709-sf-contracts-ls-json-doesnt-output-well-formed-json
Apr 17, 2025
Merged

Fix json mode#124
joshi4 merged 2 commits into
mainfrom
shantanu/eng-1709-sf-contracts-ls-json-doesnt-output-well-formed-json

Conversation

@joshi4
Copy link
Copy Markdown
Contributor

@joshi4 joshi4 commented Apr 17, 2025

  • fix(contracts): output well formed json from --json flag
  • feat(cli): if json flag is specified do not display app banner or nudge users to upgrade

@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented Apr 17, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  src/index.ts  50% smaller
  src/lib/contracts/index.tsx  0% smaller

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR improves JSON output handling in the CLI by ensuring clean, well-formed JSON for the contracts list --json command and suppressing non-JSON output when using the --json flag.

  • Modified src/lib/contracts/index.tsx to properly format JSON output using JSON.stringify with formatting parameters
  • Added conditional check in src/index.ts to skip app banner and version check when --json flag is present
  • Optimized listContracts function call to avoid duplicate execution
  • Ensures machine-readable output suitable for programmatic consumption

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Copy Markdown
Member

@sigmachirality sigmachirality left a comment

Choose a reason for hiding this comment

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

can you run deno fmt rq? other lgtm

we may want to spend some time thinking about how to handle more cases of printing to output that we don't want to print in --json mode in a nice way in the future (like, a logger class/closure/object?)

@joshi4 joshi4 force-pushed the shantanu/eng-1709-sf-contracts-ls-json-doesnt-output-well-formed-json branch from a73945a to 5baa77b Compare April 17, 2025 18:57
@joshi4 joshi4 changed the title shantanu/eng 1709 sf contracts ls json doesnt output well formed json Fix json mode Apr 17, 2025
@joshi4 joshi4 merged commit beaf3a9 into main Apr 17, 2025
1 check passed
@joshi4 joshi4 deleted the shantanu/eng-1709-sf-contracts-ls-json-doesnt-output-well-formed-json branch April 17, 2025 19:00
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