jhawksley / rjaws

John's AWS Tool - Nicer(ish) ways to interact with AWS
MIT License
0 stars 0 forks source link

Globally allow commands to present different output rendering formats #9

Open jhawksley opened 6 months ago

jhawksley commented 6 months ago

In order to integrate Jaws with pipelines, batching (and to some extent, prepare the groundwork for making it an Otel supplier), allow a new global option (--output, -o) which allows the user to get information in different renderings.

The default output format should be tabular (as now), and the next one should be json.

Presently commands implement trait Tabulatable, which allows them to emit columnar data (with headings, with optional extended attribute if --wide is set and honoured). It might be possible to simply change the driver at the output level to still receive a &dyn <something> as Tabulatable and use that to generate the requested output format.

jhawksley commented 6 months ago

Some commands (e.g. res) generate multiple blocks of output all with their own report headers, which are currently output manually to console.

In this case, the json output should be a list (the report block) of a list (each line of the report) of json objects (the fields). The header line is for human consumption only and could feasibly be dropped for output formats which are not text or tabular.

Res: The 'reservations' (first) block of the output has a Total line, which is currently woven into the table. This needs to be handled in a sane manner.

jhawksley commented 6 months ago

The first object of each output format, before the enumeration of table rows, could be a general "header" object:

What about a "trailer" object for the totaliser?