Skip to content
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

Pluggable output formatters #140

Open
tdviet opened this issue Apr 13, 2022 · 1 comment
Open

Pluggable output formatters #140

tdviet opened this issue Apr 13, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@tdviet
Copy link
Owner

tdviet commented Apr 13, 2022

fedcloud client already provides output in different formats: text, JSON, YAML. However, there are requests to provide different output formats, e.g. bash shell, CSV, Terraform. Developing and maintaining all formatters in the main code of fedcloud client is not feasible, therefore, it would be better to make the formatter pluggable.

The design is as follows:

  • Users can specify output formatter functions via option, e.g. --output-formatter fedcloud.terraform
  • fedcloud will send the output as Python objects (string, list, dict) to the formatter, instead of printing them to terminal.
  • the formatter will print outputs to terminal accordingly.
@tdviet tdviet added the enhancement New feature or request label Apr 13, 2022
@EGI-ILM
Copy link
Contributor

EGI-ILM commented Apr 13, 2022

Thanks for splitting the original issue. The formatters as "pluggable" components is a good idea.

Some ideas for the discussion, in case you can take them into consideration:

  • Initially I would suggest having formatters for the current output formats: table, json, yaml.
  • I would suggest option "-f" (format), as it seems more standard and concise: -f table
  • If no format is suggested I would default to "table", for example. If no formatter table exist, I would just output the "raw" data.
  • The option "-o" could be used to save a file (the functionality could be inside fedcloudclient, as it is generic): -f json -o myfile.json
  • Output plugins could be defined in a directory. New files can make available new output formats, example:
/fedcloudclient/formatters/
     | table
     | json
     | yaml
     | terraform

An idea is: when using -f terraform the unformatted output is sent to the formatter with name "formatters/terraform" for formatting.

  • Perhaps it is good if the formatter receives two data streams: one for the standard output and one for the error output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants