Validate flags before running the command

This commit is contained in:
Ryan Cavicchioni 2021-02-07 17:38:49 -06:00
parent 8c6567bc8a
commit 8e7ff7f39a
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
2 changed files with 10 additions and 0 deletions

View File

@ -37,6 +37,11 @@ func SetStateCmd(args CmdArgs) (int, error) {
fast := args.Flags.Bool("fast")
state.Fast = fast
if power == "" && color == "" && brightnessFlag == "" && infraredFlag == "" {
printCmdHelp(args.Name)
return ExitFailure, nil
}
r, err := c.SetState(selector, state)
if err != nil {
return ExitFailure, err

View File

@ -52,6 +52,11 @@ func SetWhiteCmd(args CmdArgs) (int, error) {
fast := args.Flags.Bool("fast")
state.Fast = fast
if power == "" && kelvinFlag == "" && name == "" && brightnessFlag == "" && infraredFlag == "" {
printCmdHelp(args.Name)
return ExitFailure, nil
}
r, err := c.SetState(selector, state)
if err != nil {
return ExitFailure, err