-
Notifications
You must be signed in to change notification settings - Fork 344
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: make jj commands more composable #3814
Comments
I'll second the desire for machine-readable output; I often like to build small tools in fzf for things like "select one of the files that have conflicts" or "select a branch to I'd love either:
😄 |
Some relevant inspiration here is libxo, which is used by the core command‐line utilities that ship as part of FreeBSD. It provides an API that allows output formatting to be annotated such that all those utilities can output the same information in a structured JSON or XML format. Similarly, it would be nice if In general, I would be happy to see |
I think this part of your comment belongs in #3262. As @khionu has requested something similar. |
I guess it would make sense to integrate the structured output into the templating language :) But I didn’t necessarily mean to imply that with my comment. Thanks for the pointer to the discussion in #3262. |
@ilyagr mentioned "scripting language" in Discord recently. It's the first time I've heard it mentioned so I don't know if there's been much discussion about that, but I think that sounds like a wonderful way to enable both interactive and non-interactive use of jj without needing to go the Using Lua as the hypothetical language, I'm imagining something vaguely like this: $ echo duplicate-and-rebase.lua
tx = jj.start_transaction()
dupes = tx.duplicate({ revset = ARGS["r"] })
rebased = tx.rebase({ revisions = dupes, destination = ARGS["d"] })
tx.finish("Duplicated and rebased revisions")
print(json(rebased))
$ jj script <duplicate-and-rebase.lua -- -d main -r main..my-branch In other words, some way to do useful things like:
This idea appeals to me because it means normal jj commands don't need to worry so much about non-interactive use. It might also partially solve #3673. |
Is your feature request related to a problem? Please describe.
By "composable", I mean that it should be possible to efficiently use the output of one command as the input to another. Oftentimes, jj features like
mean that many workflows can be accomplished without explicitly using the output of previous commands, instead just relying on stable change IDs or similar, but it's not enough for all use-cases.
For example, if I would like to run
jj split
and then immediately rebase the newly-created commits (or maybe just those which touch a certain file path, etc.), there's not an easy way to address the newly-created commits, so I have to manually construct and issue two different commands to do so.Describe the solution you'd like
🤷
Describe alternatives you've considered
Two main approaches come to mind:
There's also some alternative abstraction boundaries (via a stable compile-time or runtime API):
jj api
command to establish structured interprocess communication for seamless IDE integration #3219Additional context
The text was updated successfully, but these errors were encountered: