Update references to parsed CLI args to use zero-index because command is no longer in that slice

master
Chris Bednarski 4 years ago
parent 168ef0ce47
commit fdfc2f9001

@ -97,46 +97,46 @@ func wrappedMain(args []string) error {
return Format(options) return Format(options)
case "add": case "add":
if len(cli.Args()) != 3 { if len(cli.Args()) != 2 {
return fmt.Errorf("Usage: %s add <hostname> <ip>", cli.Name()) return fmt.Errorf("Usage: %s add <hostname> <ip>", cli.Name())
} }
return Add(options, cli.Arg(1), cli.Arg(2)) return Add(options, cli.Arg(0), cli.Arg(1))
case "rm": case "rm":
if cli.Arg(1) == "" { if cli.Arg(0) == "" {
return CommandUsage(command) return CommandUsage(command)
} }
return Remove(options, cli.Arg(1)) return Remove(options, cli.Arg(0))
case "on": case "on":
if cli.Arg(1) == "" { if cli.Arg(0) == "" {
return CommandUsage(command) return CommandUsage(command)
} }
return Enable(options, cli.Arg(1)) return Enable(options, cli.Arg(0))
case "off": case "off":
if cli.Arg(1) == "" { if cli.Arg(0) == "" {
return CommandUsage(command) return CommandUsage(command)
} }
return Disable(options, cli.Arg(1)) return Disable(options, cli.Arg(0))
case "ls": case "ls":
return List(options) return List(options)
case "has": case "has":
if cli.Arg(1) == "" { if cli.Arg(0) == "" {
return CommandUsage(command) return CommandUsage(command)
} }
return Has(options, cli.Arg(1)) return Has(options, cli.Arg(0))
case "dump": case "dump":
return Dump(options) return Dump(options)
case "apply": case "apply":
if cli.Arg(1) == "" { if cli.Arg(0) == "" {
return fmt.Errorf("Usage: %s apply <filename>", args[0]) return fmt.Errorf("Usage: %s apply <filename>", args[0])
} }
return Apply(options, cli.Arg(1)) return Apply(options, cli.Arg(0))
default: default:
return ErrInvalidCommand return ErrInvalidCommand

Loading…
Cancel
Save