Skip to content

Add structured text output (YAML or JSON) #99

@gbirke

Description

@gbirke

Is your feature request related to a problem? Please describe

I'd like to use mani as part of a shell script that further processes the output of mani commands. While it's certainly possible to parse the output of the table format, it needs a "stateful" parser in the shell script that checks for separating lines and keeps track which repo to add the output lines to. And there is no way to capture for example the return code of the command.

A structured format like JSON or YAML would allow for further processing and filtering of the results with tools like jq and yq. Or piping it into document databases, structured logs, etc.

Describe the solution you'd like

Running mani run my-command -o json with two configured projects could produce the following JSON output:

[
   {
     "project":"my-first-project",
     "output": [ "success!", "counted_lines: 5"],
     "exit-code": 0,
     "command" "my-command"
   },
   {
     "project":"my-second-project",
     "output": [ "syntax error: unreticulated splines", "", "failed to build"],
     "exit-code": 1,
     "command" "my-command"
   }
]

When running with --parallel, you could opt instead for a "streaming JSON" format, where each result is a one-line JSON object, followed by a newline.

YAML already allows for a "streaming" format by separating each block/document with three dashes.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions