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
Client *lifx.Client
Config Config
Name string
}
type Flags struct {

View File

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

View File

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