Skip to content

feat: default to pretty output, add --json and --jq flags#71

Open
Ramon Nogueira (ramon-langchain) wants to merge 1 commit into
mainfrom
ramon/pretty-default-jq
Open

feat: default to pretty output, add --json and --jq flags#71
Ramon Nogueira (ramon-langchain) wants to merge 1 commit into
mainfrom
ramon/pretty-default-jq

Conversation

@ramon-langchain
Copy link
Copy Markdown
Member

Summary

  • Change default output format from json to pretty (human-readable tables/trees)
  • Add --json flag as shorthand for --format json
  • Add --jq EXPR flag to apply jq expressions to JSON output (powered by gojq, implies --json)

Example usage:

langsmith project list                          # pretty table (new default)
langsmith project list --json                   # JSON output
langsmith project list --jq '.[].name'          # extract names via jq
langsmith project list --jq '[.[] | select(.run_count > 100)]'

Release Note

Default output is now human-readable; use --json or --jq for machine-readable output.

Test Plan

  • All existing tests pass with updated default expectations
  • New unit tests for applyJQ covering field access, array indexing, select, pipes, keys, length, nested access, invalid expressions, and nil input
  • Integration tests for OutputJSON with and without JQExpr
  • Flag wiring tests: --jq implies JSON format, --json flag, flag defaults

Change the default output format from JSON to pretty (human-readable
tables). Add --json as a shorthand for --format json, and --jq to apply
a jq expression to JSON output (powered by gojq, implies --json).
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

🐛 1 issue in files not directly in the diff

🐛 --json and --jq flags silently ignored by api ls and api info commands (internal/cmdutil/resolve.go:45-51)

The api ls and api info subcommands resolve their output format via cmdutil.ResolveFormat(cmd) (internal/cmdutil/resolve.go:45-51), which only reads the --format flag. The new --json and --jq persistent flags added to the root command are accepted by cobra (they're inherited persistent flags) but have no effect on these commands. For example, langsmith api ls --json will still render a pretty table because cmdutil.ResolveFormat returns "pretty" (the new default) without checking the --json or --jq flags. Meanwhile, all other subcommands use cmd.GetFormat() (internal/cmd/root.go:107-111) which correctly checks both flagJSON and flagJQ. This creates an inconsistency where --json works everywhere except the api subcommands.

View 4 additional findings in Devin Review.

Open in Devin Review

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.

1 participant