diff --git a/Gopkg.lock b/Gopkg.lock index 0adf8b8..1e568d6 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -3,11 +3,11 @@ [[projects]] branch = "master" - digest = "1:ebde2265eca1ac817356ea6306aafb046f3539871ec72f97e241fc1fac1a656a" + digest = "1:7cf0bc606bb5b12b2c431bd891679060d927083330118687898278bcf963ae8d" name = "github.com/genuinetools/pkg" packages = ["cli"] pruneopts = "NUT" - revision = "3926dab1fc19efd29fc6940eccaf05e3dd44c044" + revision = "cd7da1bd30dc725ffb0bababc615633f23654e0c" [[projects]] digest = "1:15042ad3498153684d09f393bbaec6b216c8eec6d61f63dff711de7d64ed8861" diff --git a/vendor/github.com/genuinetools/pkg/cli/cli.go b/vendor/github.com/genuinetools/pkg/cli/cli.go index 28f6575..67b529b 100644 --- a/vendor/github.com/genuinetools/pkg/cli/cli.go +++ b/vendor/github.com/genuinetools/pkg/cli/cli.go @@ -113,14 +113,21 @@ func (p *Program) Run() { } // Parse the flags the user gave us. - if err := p.FlagSet.Parse(os.Args); err != nil { + if err := p.FlagSet.Parse(os.Args[1:]); err != nil { p.usage(ctx) os.Exit(1) } // Run the main action _if_ we are not in the loop for the version command // that is added by default. - if p.FlagSet.NArg() < 2 { + if p.FlagSet.NArg() < 1 || p.FlagSet.Arg(0) != "version" { + if p.Before != nil { + if err := p.Before(ctx); err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + os.Exit(1) + } + } + if err := p.Action(ctx); err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) os.Exit(1)