forked from mirrors/linux-bench
Merge pull request #14 from nshauli/master
Add support for writing JSON results to output file using --output flag
This commit is contained in:
commit
322876c8e0
2 changed files with 3 additions and 1 deletions
2
app.go
2
app.go
|
@ -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)
|
||||
}
|
||||
|
|
2
root.go
2
root.go
|
@ -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",
|
||||
|
|
Loading…
Add table
Reference in a new issue