Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions cmd/src/abc.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package main

import (
"context"

"github.com/sourcegraph/src-cli/internal/clicompat"
"github.com/urfave/cli/v3"
)
Expand All @@ -18,12 +16,6 @@ var abcCommand = clicompat.Wrap(&cli.Command{
abcVariablesSetCommand,
abcVariablesDeleteCommand,
},
Action: func(ctx context.Context, cmd *cli.Command) error {
return cli.ShowSubcommandHelp(cmd)
},
}),
},
Action: func(ctx context.Context, cmd *cli.Command) error {
return cli.ShowSubcommandHelp(cmd)
},
})
5 changes: 0 additions & 5 deletions cmd/src/auth.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package main

import (
"context"

"github.com/sourcegraph/src-cli/internal/clicompat"
"github.com/urfave/cli/v3"
)
Expand Down Expand Up @@ -32,7 +30,4 @@ var authCommand = clicompat.Wrap(&cli.Command{
Commands: []*cli.Command{
authTokenCommand,
},
Action: func(ctx context.Context, cmd *cli.Command) error {
return cli.ShowSubcommandHelp(cmd)
},
})
12 changes: 7 additions & 5 deletions internal/clicompat/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ func Wrap(cmd *cli.Command) *cli.Command {
}

cmd.OnUsageError = OnUsageError
cmd.Action = wrapWithHelpOnUsageError(cmd.Action)
if cmd.Action == nil {
cmd.Action = func(ctx context.Context, cmd *cli.Command) error {
return cli.ShowSubcommandHelp(cmd)
}
} else {
cmd.Action = wrapWithHelpOnUsageError(cmd.Action)
}
return cmd
}

func wrapWithHelpOnUsageError(action cli.ActionFunc) cli.ActionFunc {
if action == nil {
return nil
}

return func(ctx context.Context, cmd *cli.Command) error {
err := action(ctx, cmd)
if err != nil && errors.HasType[*cmderrors.UsageError](err) {
Expand Down
Loading