func (s *ClientSuite) TestBadCommand(c *check.C) {
exited := handler.RunCommand("arvados-client", []string{"no such command"}, bytes.NewReader(nil), ioutil.Discard, ioutil.Discard)
- c.Check(exited, check.Equals, cmd.EX_USAGE)
+ c.Check(exited, check.Equals, cmd.EXIT_INVALIDARGUMENT)
}
func (s *ClientSuite) TestBadSubcommandArgs(c *check.C) {
exited := handler.RunCommand("arvados-client", []string{"get"}, bytes.NewReader(nil), ioutil.Discard, ioutil.Discard)
- c.Check(exited, check.Equals, cmd.EX_USAGE)
+ c.Check(exited, check.Equals, cmd.EXIT_INVALIDARGUMENT)
}
func (s *ClientSuite) TestVersion(c *check.C) {
LimitNOFILE=65536
Restart=always
RestartSec=1
-RestartPreventExitStatus=64
+RestartPreventExitStatus=2
# systemd<=219 (centos:7, debian:8, ubuntu:trusty) obeys StartLimitInterval in the [Service] section
StartLimitInterval=0
LimitNOFILE=65536
Restart=always
RestartSec=1
-RestartPreventExitStatus=64
+RestartPreventExitStatus=2
# systemd<=219 (centos:7, debian:8, ubuntu:trusty) obeys StartLimitInterval in the [Service] section
StartLimitInterval=0
LimitNOFILE=65536
Restart=always
RestartSec=1
-RestartPreventExitStatus=64
+RestartPreventExitStatus=2
# systemd<=219 (centos:7, debian:8, ubuntu:trusty) obeys StartLimitInterval in the [Service] section
StartLimitInterval=0
LimitNOFILE=65536
Restart=always
RestartSec=1
-RestartPreventExitStatus=64
+RestartPreventExitStatus=2
# systemd<=219 (centos:7, debian:8, ubuntu:trusty) obeys StartLimitInterval in the [Service] section
StartLimitInterval=0
LimitNOFILE=65536
Restart=always
RestartSec=1
-RestartPreventExitStatus=64
+RestartPreventExitStatus=2
# systemd<=219 (centos:7, debian:8, ubuntu:trusty) obeys StartLimitInterval in the [Service] section
StartLimitInterval=0
LimitNOFILE=65536
Restart=always
RestartSec=1
-RestartPreventExitStatus=64
+RestartPreventExitStatus=2
# systemd<=219 (centos:7, debian:8, ubuntu:trusty) obeys StartLimitInterval in the [Service] section
StartLimitInterval=0
LimitNOFILE=65536
Restart=always
RestartSec=1
-RestartPreventExitStatus=64
+RestartPreventExitStatus=2
# systemd<=219 (centos:7, debian:8, ubuntu:trusty) obeys StartLimitInterval in the [Service] section
StartLimitInterval=0
Restart=always
RestartSec=10s
Nice=19
-RestartPreventExitStatus=64
+RestartPreventExitStatus=2
# systemd<=219 (centos:7, debian:8, ubuntu:trusty) obeys StartLimitInterval in the [Service] section
StartLimitInterval=0
LimitNOFILE=65536
Restart=always
RestartSec=1
-RestartPreventExitStatus=64
+RestartPreventExitStatus=2
# systemd<=219 (centos:7, debian:8, ubuntu:trusty) obeys StartLimitInterval in the [Service] section
StartLimitInterval=0
LimitNOFILE=65536
Restart=always
RestartSec=1
-RestartPreventExitStatus=64
+RestartPreventExitStatus=2
# systemd<=219 (centos:7, debian:8, ubuntu:trusty) obeys StartLimitInterval in the [Service] section
StartLimitInterval=0
LimitNOFILE=65536
Restart=always
RestartSec=1
-RestartPreventExitStatus=64
+RestartPreventExitStatus=2
# systemd<=219 (centos:7, debian:8, ubuntu:trusty) obeys StartLimitInterval in the [Service] section
StartLimitInterval=0
flags.SetOutput(stderr)
err = flags.Parse(args)
if err != nil {
- return cmd.EX_USAGE
+ return cmd.EXIT_INVALIDARGUMENT
}
if len(flags.Args()) != 1 {
fmt.Fprintf(stderr, "usage of %s:\n", prog)
flags.PrintDefaults()
- return cmd.EX_USAGE
+ return cmd.EXIT_INVALIDARGUMENT
}
if opts.Short {
opts.Format = "uuid"
"github.com/sirupsen/logrus"
)
-const EX_USAGE = 64
+const EXIT_INVALIDARGUMENT = 2
type Handler interface {
RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int
} else if len(args) < 1 {
fmt.Fprintf(stderr, "usage: %s command [args]\n", prog)
m.Usage(stderr)
- return EX_USAGE
+ return EXIT_INVALIDARGUMENT
} else if cmd, ok = m[args[0]]; ok {
return cmd.RunCommand(prog+" "+args[0], args[1:], stdin, stdout, stderr)
} else {
fmt.Fprintf(stderr, "%s: unrecognized command %q\n", prog, args[0])
m.Usage(stderr)
- return EX_USAGE
+ return EXIT_INVALIDARGUMENT
}
}
stdout := bytes.NewBuffer(nil)
stderr := bytes.NewBuffer(nil)
exited := testCmd.RunCommand("prog", []string{"nosuchcommand", "hi"}, bytes.NewReader(nil), stdout, stderr)
- c.Check(exited, check.Equals, 64)
+ c.Check(exited, check.Equals, 2)
c.Check(stdout.String(), check.Equals, "")
c.Check(stderr.String(), check.Matches, `(?ms)^prog: unrecognized command "nosuchcommand"\n.*echo.*\n`)
}
// running normally, or false if it should exit now.
//
// If ok is false, the second return value is an appropriate exit
-// code: 0 if "-help" was given, EX_USAGE (64) if there was a usage
-// error.
+// code: 0 if "-help" was given, 2 if there was a usage error.
func ParseFlags(f FlagSet, prog string, args []string, positional string, stderr io.Writer) (ok bool, exitCode int) {
f.Init(prog, flag.ContinueOnError)
f.SetOutput(io.Discard)
case nil:
if f.NArg() > 0 && positional == "" {
fmt.Fprintf(stderr, "unrecognized command line arguments: %v (try -help)\n", f.Args())
- return false, EX_USAGE
+ return false, EXIT_INVALIDARGUMENT
}
return true, 0
case flag.ErrHelp:
return false, 0
default:
fmt.Fprintf(stderr, "error parsing command line arguments: %s (try -help)\n", err)
- return false, EX_USAGE
+ return false, EXIT_INVALIDARGUMENT
}
}
func (s *CommandSuite) TestDump_BadArg(c *check.C) {
var stderr bytes.Buffer
code := DumpCommand.RunCommand("arvados config-dump", []string{"-badarg"}, bytes.NewBuffer(nil), bytes.NewBuffer(nil), &stderr)
- c.Check(code, check.Equals, cmd.EX_USAGE)
+ c.Check(code, check.Equals, cmd.EXIT_INVALIDARGUMENT)
c.Check(stderr.String(), check.Equals, "error parsing command line arguments: flag provided but not defined: -badarg (try -help)\n")
}
fmt.Fprint(stderr,
"Usage error: the -commit-pulls or -commit-trash command line flags are no longer supported.\n",
"Use Collections.BalancePullLimit and Collections.BalanceTrashLimit instead.\n")
- return cmd.EX_USAGE
+ return cmd.EXIT_INVALIDARGUMENT
}
// Drop our custom args that would be rejected by the generic