Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DXCDT-602: Add help text to api cmd when no args passed #914

Merged
merged 1 commit into from
Nov 16, 2023
Merged
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
6 changes: 5 additions & 1 deletion internal/cli/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func apiCmd(cli *cli) *cobra.Command {

cmd := &cobra.Command{
Use: "api <method> <url-path>",
Args: cobra.RangeArgs(1, 2),
Args: cobra.RangeArgs(0, 2),
Short: "Makes an authenticated HTTP request to the Auth0 Management API",
Long: fmt.Sprintf(
`Makes an authenticated HTTP request to the [Auth0 Management API](%s) and returns the response as JSON.
Expand Down Expand Up @@ -117,6 +117,10 @@ func apiUsageTemplate() string {

func apiCmdRun(cli *cli, inputs *apiCmdInputs) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return cmd.Help()
}

if err := inputs.fromArgs(args, cli.tenant); err != nil {
return fmt.Errorf("failed to parse command inputs: %w", err)
}
Expand Down
Loading