Open arxanas opened 1 month ago
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 new
onto"; but jj status
's current output isn't very easy to chop into the right format for things like finding conflicts or w/e.
I'd love either:
git --porcelain
flag which would tell jj to only output the info I asked for, and in a structured format so I can hack-and-slash it with other unixy tools.đ
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 jj
commands could return structured data and pretty output in one go, rather than handling them as separate code paths; this would ensure that all the same information is available in both, and cut down on code duplication. Of course, theyâre dealing with the case of decadesâold Unix utilities that really need to be able to output in whatever bespoke format people have become used to; Itâs possible that Jujutsuâs output is uniform enough, or could be made uniform enough, that we could do something simpler and less flexible and have a more limited standard set of structured command output structures that can be mapped to userâfriendly unstructured output.
In general, I would be happy to see jj
grow a --json
argument on all commands, even if some kind of embedded scripting DSL is also added; you canât anticipate all the possible contexts someone might want to do scripting in. However, I do think that we might want to consider how highâvalue this is compared to factoring things out so that thereâs a highâlevel Rust API you can use to accomplish the same things the commands do? We could bind it to Python if we want a more lightweight and scriptable interface. Complex shell scripts are painful and JSON is a pretty lowestâcommonâdenominator type to stuff everything into; itâs always nicer to use a highâlevel API than string commands together once you pass a pretty low complexity threshold.
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:
Additional context