Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: All commands to have optional structured output, eg. --json #5662

Open
neongreen opened this issue Feb 12, 2025 · 2 comments
Open

FR: All commands to have optional structured output, eg. --json #5662

neongreen opened this issue Feb 12, 2025 · 2 comments

Comments

@neongreen
Copy link
Contributor

neongreen commented Feb 12, 2025

Is your feature request related to a problem? Please describe.
I want to be able to say things like

CHANGE_ID=$(jj new main --json | jq .change_id)

or

AUTHOR=$(jj show $commit --json | jq .author.name)

This comes up often when doing any scripting that involves repo operations.

Describe the solution you'd like
Add --json to the most popular commands. It would cause jj to stdout a json object with the "result" of whatever the command does.

It's ok if

  • it's just one or two commands at first,
  • and it's also ok if the JSON object is merely a subset of the result,
  • and it's also ok to fail to output any json if the command fails for whatever reason.
    • (but ideally the output would be {"error": ..., "details": {...}} or smth of course)

Describe alternatives you've considered
I haven't really. I mean, the backend/api idea is an alternative in a way, since then I just do curl jj/show instead of jj show --json, but I'd say the --json bit is actually a stepping stone towards the api.

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

No branches or pull requests

3 participants