From 320815293dd9c6a72c02f329005b3ba0594237ad Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sun, 31 Jan 2021 11:08:24 -0600 Subject: [PATCH] ExitFailure matches stdlib.h --- cmd/command.go | 2 +- cmd/ls.go | 2 +- cmd/main.go | 8 ++++---- cmd/poweroff.go | 2 +- cmd/poweron.go | 2 +- cmd/setcolor.go | 10 +++++----- cmd/setstate.go | 2 +- cmd/setwhite.go | 6 +++--- cmd/toggle.go | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cmd/command.go b/cmd/command.go index c8b0c6b..3dd376d 100644 --- a/cmd/command.go +++ b/cmd/command.go @@ -11,7 +11,7 @@ import ( const ( ExitSuccess = iota - ExitError + ExitFailure ) type Config struct { diff --git a/cmd/ls.go b/cmd/ls.go index 7c224d8..03a0f3b 100644 --- a/cmd/ls.go +++ b/cmd/ls.go @@ -23,7 +23,7 @@ func LsCmd(args CmdArgs) (int, error) { selector := args.Flags.String("selector") lights, err := c.ListLights(selector) if err != nil { - return ExitError, err + return ExitFailure, err } PrintLights(lights) return ExitSuccess, nil diff --git a/cmd/main.go b/cmd/main.go index 27994dc..815647c 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -20,12 +20,12 @@ func Main(args []string) (int, error) { configPath := getConfigPath() if configPath == "" { err = errors.New("fatal: ~/.lumerc was not found") - return ExitError, err + return ExitFailure, err } if _, err := toml.DecodeFile(configPath, &config); err != nil { err = fmt.Errorf("fatal: failed to parse %s; %w", configPath, err) - return ExitError, err + return ExitFailure, err } envAccessToken := os.Getenv("LIFX_ACCESS_TOKEN") @@ -34,7 +34,7 @@ func Main(args []string) (int, error) { } if err = config.Validate(); err != nil { - return ExitError, fmt.Errorf("fatal: %s", err) + return ExitFailure, fmt.Errorf("fatal: %s", err) } flag.Parse() @@ -51,7 +51,7 @@ func Main(args []string) (int, error) { cmd, ok := GetCommand(command) if !ok { err = fmt.Errorf("lume: '%s' is not lume command. See 'lume help'", command) - return ExitError, err + return ExitFailure, err } fs := cmd.Flags fs.Parse(args[2:]) diff --git a/cmd/poweroff.go b/cmd/poweroff.go index 941f16c..ebf81fa 100644 --- a/cmd/poweroff.go +++ b/cmd/poweroff.go @@ -33,7 +33,7 @@ func PoweroffCmd(args CmdArgs) (int, error) { r, err := c.SetState(selector, state) if err != nil { - return ExitError, err + return ExitFailure, err } PrintResults(r.Results) return ExitSuccess, nil diff --git a/cmd/poweron.go b/cmd/poweron.go index 711411a..620048c 100644 --- a/cmd/poweron.go +++ b/cmd/poweron.go @@ -33,7 +33,7 @@ func PoweronCmd(args CmdArgs) (int, error) { r, err := c.SetState(selector, state) if err != nil { - return ExitError, err + return ExitFailure, err } PrintResults(r.Results) return ExitSuccess, nil diff --git a/cmd/setcolor.go b/cmd/setcolor.go index e616799..c05bb1c 100644 --- a/cmd/setcolor.go +++ b/cmd/setcolor.go @@ -65,7 +65,7 @@ func SetColorCmd(args CmdArgs) (int, error) { if (hueFlag == "" || saturationFlag == "") && rgbFlag == "" && name == "" { printCmdHelp(os.Args[1]) - return ExitError, nil + return ExitFailure, nil } if hueFlag != "" || saturationFlag != "" { @@ -85,17 +85,17 @@ func SetColorCmd(args CmdArgs) (int, error) { } else if rgbFlag != "" { color, err := parseRGB(rgbFlag) if err != nil { - return ExitError, err + return ExitFailure, err } state.Color = color } else if name != "" { hsb, ok := args.Config.Colors[name] if !ok { - return ExitError, fmt.Errorf("%s is not a defined color", name) + return ExitFailure, fmt.Errorf("%s is not a defined color", name) } color, err := lifx.NewHSBColor(hsb[0], hsb[1], hsb[2]) if err != nil { - return ExitError, err + return ExitFailure, err } state.Color = color } @@ -115,7 +115,7 @@ func SetColorCmd(args CmdArgs) (int, error) { r, err := c.SetState(selector, state) if err != nil { fmt.Printf("fatal: %s\n", err) - return ExitError, err + return ExitFailure, err } if !fast { diff --git a/cmd/setstate.go b/cmd/setstate.go index aca286c..3e3f748 100644 --- a/cmd/setstate.go +++ b/cmd/setstate.go @@ -75,7 +75,7 @@ func SetStateCmd(args CmdArgs) (int, error) { r, err := c.SetState(selector, state) if err != nil { - return ExitError, err + return ExitFailure, err } if !fast { diff --git a/cmd/setwhite.go b/cmd/setwhite.go index 05bc648..8498ad9 100644 --- a/cmd/setwhite.go +++ b/cmd/setwhite.go @@ -58,7 +58,7 @@ func SetWhiteCmd(args CmdArgs) (int, error) { kelvin := args.Flags.Int16("kelvin") color, err := lifx.NewWhite(kelvin) if err != nil { - return ExitError, err + return ExitFailure, err } state.Color = color } @@ -68,7 +68,7 @@ func SetWhiteCmd(args CmdArgs) (int, error) { name := args.Flags.String("name") color, err := lifx.NewWhiteString(name) if err != nil { - return ExitError, err + return ExitFailure, err } state.Color = color } @@ -93,7 +93,7 @@ func SetWhiteCmd(args CmdArgs) (int, error) { r, err := c.SetState(selector, state) if err != nil { - return ExitError, err + return ExitFailure, err } if !fast { diff --git a/cmd/toggle.go b/cmd/toggle.go index 6509cbc..5616b12 100644 --- a/cmd/toggle.go +++ b/cmd/toggle.go @@ -29,7 +29,7 @@ func ToggleCmd(args CmdArgs) (int, error) { selector := args.Flags.String("selector") r, err := c.Toggle(selector, duration) if err != nil { - return ExitError, err + return ExitFailure, err } PrintResults(r.Results) return ExitSuccess, nil