Skip to content

Commit

Permalink
feat(cmd/chaos_monkey/random_status_code): Add --verbose flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejsika committed Feb 13, 2024
1 parent b58df1a commit e3aae79
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/chaos_monkey/random_status_code/random_status_code.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
package random_status_code

import (
"fmt"
"os"

parent_cmd "github.com/sikalabs/slu/cmd/chaos_monkey"
"github.com/sikalabs/slu/utils/random_utils"
"github.com/spf13/cobra"
)

var FlagVerbose bool

var Cmd = &cobra.Command{
Use: "random-status-code",
Aliases: []string{"rsc"},
Short: "Return random status code",
Run: func(c *cobra.Command, args []string) {
ok := random_utils.RandomBool()
if ok {
if FlagVerbose {
fmt.Println("exit code 0")
}
os.Exit(0)
} else {
fmt.Println("exit code 1")
os.Exit(1)
}
},
}

func init() {
parent_cmd.Cmd.AddCommand(Cmd)
Cmd.PersistentFlags().BoolVarP(
&FlagVerbose,
"verbose",
"v",
false,
"Verbose output",
)
}

0 comments on commit e3aae79

Please sign in to comment.