Compare commits

...

2 Commits

Author SHA1 Message Date
8c6567bc8a
Using os.Args is not necessary 2021-02-07 17:31:57 -06:00
d8be978ba8
Pass command name to CmdArgs struct 2021-02-07 17:31:19 -06:00
3 changed files with 3 additions and 2 deletions

View File

@ -23,6 +23,7 @@ type CmdArgs struct {
Flags Flags Flags Flags
Client *lifx.Client Client *lifx.Client
Config Config Config Config
Name string
} }
type Flags struct { type Flags struct {

View File

@ -237,6 +237,7 @@ func Main(args []string) (int, error) {
fs.Parse(args[2:]) fs.Parse(args[2:])
cmdArgs.Flags = Flags{FlagSet: fs} cmdArgs.Flags = Flags{FlagSet: fs}
cmdArgs.Name = command
exitCode, err := cmd.Func(cmdArgs) exitCode, err := cmd.Func(cmdArgs)
if err != nil { if err != nil {
err = fmt.Errorf("fatal: %s", err) err = fmt.Errorf("fatal: %s", err)

View File

@ -2,7 +2,6 @@ package lumecmd
import ( import (
"fmt" "fmt"
"os"
lifx "git.kill0.net/chill9/lume" lifx "git.kill0.net/chill9/lume"
) )
@ -23,7 +22,7 @@ func SetColorCmd(args CmdArgs) (int, error) {
name := args.Flags.String("name") name := args.Flags.String("name")
if (hueFlag == "" || saturationFlag == "") && rgbFlag == "" && name == "" { if (hueFlag == "" || saturationFlag == "") && rgbFlag == "" && name == "" {
printCmdHelp(os.Args[1]) printCmdHelp(args.Name)
return ExitFailure, nil return ExitFailure, nil
} }