pyinfra-dev / pyinfra

pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast and scales from one server to thousands.
https://pyinfra.com
MIT License
3.93k stars 383 forks source link

Add `--json` output flag #509

Open Fizzadar opened 3 years ago

Fizzadar commented 3 years ago

Is your feature request related to a problem? Please describe. As it stands pyinfra is very much a CLI tool executed by users. There's the programmatic API as well for Python folk but there's also no reason the CLI can't be used within scripts and so on. Currently output is written (correctly) to stderr but no machine readable output is emitted to stdout - this flag would push out JSON during execution, such that the whole output would be a valid JSON object.

This would make it possible to integrate pyinfra into any number of systems without writing any Python code.

Describe the solution you'd like Add --json CLI flag that makes pyinfra emit machine readable JSON output to stdout during execution. Possibly in tandem with a flag to hide most/all stderr user output.

paolodina commented 2 years ago

Currently output is written (correctly) to stderr

I'm using subprocess to run pyinfra from my script and also noted that. May I ask why this is correct? Seems counterintuitive.

Any kind of ETA for this particular --json implementation?