Skip to content

Rewrite CLI output handling to use minijinja #194

@alilleybrinker

Description

@alilleybrinker

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    crate: omnibor-cliRelating to the omnibor-cli cratetype: refactorRegular maintenance of the code

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions