Skip to content

Commit

Permalink
DXCDT-602: Add help text to api cmd when no args passed (#914)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught authored Nov 16, 2023
1 parent f9900b1 commit a3454d3
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit a3454d3

Please sign in to comment.