From fdfc2f90016b1a010355c1cf87af4ca9e624c452 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Fri, 13 Mar 2020 01:42:53 -0700 Subject: [PATCH] Update references to parsed CLI args to use zero-index because command is no longer in that slice --- main.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index df384cb..cd20579 100644 --- a/main.go +++ b/main.go @@ -97,46 +97,46 @@ func wrappedMain(args []string) error { return Format(options) case "add": - if len(cli.Args()) != 3 { + if len(cli.Args()) != 2 { return fmt.Errorf("Usage: %s add ", cli.Name()) } - return Add(options, cli.Arg(1), cli.Arg(2)) + return Add(options, cli.Arg(0), cli.Arg(1)) case "rm": - if cli.Arg(1) == "" { + if cli.Arg(0) == "" { return CommandUsage(command) } - return Remove(options, cli.Arg(1)) + return Remove(options, cli.Arg(0)) case "on": - if cli.Arg(1) == "" { + if cli.Arg(0) == "" { return CommandUsage(command) } - return Enable(options, cli.Arg(1)) + return Enable(options, cli.Arg(0)) case "off": - if cli.Arg(1) == "" { + if cli.Arg(0) == "" { return CommandUsage(command) } - return Disable(options, cli.Arg(1)) + return Disable(options, cli.Arg(0)) case "ls": return List(options) case "has": - if cli.Arg(1) == "" { + if cli.Arg(0) == "" { return CommandUsage(command) } - return Has(options, cli.Arg(1)) + return Has(options, cli.Arg(0)) case "dump": return Dump(options) case "apply": - if cli.Arg(1) == "" { + if cli.Arg(0) == "" { return fmt.Errorf("Usage: %s apply ", args[0]) } - return Apply(options, cli.Arg(1)) + return Apply(options, cli.Arg(0)) default: return ErrInvalidCommand