-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Currently the code for handling CLI output is pretty unwieldy, in particular we have multiple types involved to represent both the format selected by the user, as well as whether the response is success or failure, and finally to handle the different specific operations run.
There's a better way, based on using minijinja with templates we compile in. Essentially, the JSON data provided as context to the template can be output directly if the output format is JSON. Otherwise, the template can be selected based on the format, success/failure, and command. These template files will then be much easier to understand and edit, enabling nice separation between the logic for formatting of the output and the determining which format to use.
I've used just such a structure in my own CWE API CLI (so many acronyms lol), seen here: https://github.com/alilleybrinker/cwe-api