redhat-et / copilot-ops

copilot-ops is a CLI tool that boosts up any DevOps repo to a ninja level of Artificially Intelligent Ops Repo
Apache License 2.0
34 stars 13 forks source link

Output Formatting #76

Closed RobotSail closed 2 years ago

RobotSail commented 2 years ago

At the time of writing, the copilot-ops CLI only has one way of printing the data to STDOUT: plaintext. This is not sufficient for integrating the CLI into other services since processes will need to be able to extract data efficiently. Copilot-ops should be able to format its output as JSON in addition to the current plaintext output.

RobotSail commented 2 years ago

Logs should go to STDERR, output should still go to STDOUT. The output should now be formatted based on user specification, e.g. raw output, JSON, YAML.

The formats could vary depending on whether you're using filesets, regular files, etc.

{
    "generatedFiles": [
     {
           "name": "generated.yaml"
           "path": "path/to/dir"
           "contents": "<generated contents>"
      },
    ], 
    "errors": [
         {
             "error_code": "OPENAI_MISSING_TOKEN",
             "message": "We couldn't find the OpenAI token, please make sure it is set", 
         }
     ]
}

This should be regardless of the --write flag, e.g. should I also write or not. Log level can be controlled by a verbosity setting, e.g. --verbose would print out logs, --verbose 5 would be verbose with level 5.