Merge pull request #14 from nshauli/master

Add support for writing JSON results to output file using --output flag
This commit is contained in:
jerbia 2019-05-27 15:03:17 +03:00 committed by GitHub
commit 322876c8e0
Failed to generate hash of commit
2 changed files with 3 additions and 1 deletions

2
app.go
View file

@ -51,7 +51,7 @@ func outputResults(controls *check.Controls, summary check.Summary) error {
if err != nil {
return err
}
fmt.Println(string(out))
util.PrintOutput(string(out), outputFile)
} else {
util.PrettyPrint(controls, summary, noRemediations, includeTestOutput)
}

View file

@ -35,6 +35,7 @@ var (
checkList string
jsonFmt bool
includeTestOutput bool
outputFile string
)
// RootCmd represents the base command when called without any subcommands
@ -74,6 +75,7 @@ func init() {
RootCmd.Flags().StringVarP(&cfgDir, "config-dir", "D", "cfg", "directory to get benchmark definitions")
RootCmd.PersistentFlags().BoolVar(&jsonFmt, "json", false, "Prints the results as JSON")
RootCmd.PersistentFlags().BoolVar(&includeTestOutput, "include-test-output", false, "Prints the test's output")
RootCmd.PersistentFlags().StringVar(&outputFile, "outputfile", "", "Writes the JSON results to output file")
RootCmd.PersistentFlags().StringVarP(
&checkList,
"check",