File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,19 +69,24 @@ func runMigrated() (int, error) {
6969 ctx := context .Background ()
7070
7171 err := migratedRootCommand ().Run (ctx , os .Args )
72- if errors.HasType [* cmderrors.UsageError ](err ) {
73- return 2 , nil
74- }
75- if e , ok := err .(* cmderrors.ExitCodeError ); ok {
76- if e .HasError () {
77- return e .Code (), e
72+ if err != nil {
73+ if errors.HasType [* cmderrors.UsageError ](err ) {
74+ return 2 , nil
7875 }
79- return e .Code (), nil
80- }
81- var exitErr cli.ExitCoder
82- if errors .AsInterface (err , & exitErr ) {
83- return exitErr .ExitCode (), err
76+ if e , ok := err .(* cmderrors.ExitCodeError ); ok {
77+ if e .HasError () {
78+ return e .Code (), e
79+ }
80+ return e .Code (), nil
81+ }
82+ var exitErr cli.ExitCoder
83+ if errors .AsInterface (err , & exitErr ) {
84+ return exitErr .ExitCode (), err
85+ }
86+
87+ return 1 , err
8488 }
89+
8590 return 0 , err
8691}
8792
Original file line number Diff line number Diff line change @@ -20,7 +20,13 @@ func Wrap(cmd *cli.Command) *cli.Command {
2020 cmd .OnUsageError = OnUsageError
2121 if cmd .Action == nil {
2222 cmd .Action = func (ctx context.Context , cmd * cli.Command ) error {
23- return cli .ShowSubcommandHelp (cmd )
23+ if err := cli .ShowSubcommandHelp (cmd ); err != nil {
24+ return err
25+ }
26+ if cmd .Args ().Len () > 0 {
27+ return errors .Newf ("Unknown subcommand: %s" , cmd .Args ().First ())
28+ }
29+ return nil
2430 }
2531 } else {
2632 cmd .Action = wrapWithHelpOnUsageError (cmd .Action )
You can’t perform that action at this time.
0 commit comments