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

Delegate plugin --help flag to the plugin #956

Merged

Conversation

vcheung-stripe
Copy link
Collaborator

Reviewers

r? @
cc @stripe/developer-products

Summary

There is a bug where if you run a plugin command with --help or -h, you get the wrong output. This is because cobra parses the --help flag in the mainline CLI, bypassing the plugin process completely.

Expected:

❯ stripe apps --help
Commands for building Stripe apps

Usage:
  stripe apps [command]

Available Commands:
  add         Add a building block for developing your app
  create      Create a new Stripe app
  grant       Grant configuration access to your app
  help        Help about any command
  remove      Remove a building block from your stripe-app json
  revoke      Revoke configuration access to your app
  start       Start a development server for viewing your app in the Stripe dashboard
  upload      Upload your app to be submitted for review

Flags:
      --api-key string        Your API key to use for the command
      --color string          turn on/off color output (on, off, auto)
      --config string         config file (default is $HOME/.config/stripe/config.toml)
      --device-name string    device name
  -h, --help                  help for apps
      --log-level string      log level (debug, info, trace, warn, error) (default "info")
  -p, --project-name string   the project name to read from for config (default "default")

Use "stripe apps [command] --help" for more information about a command.

Actual:

❯ stripe apps --help
Usage:
  stripe apps [flags]

Flags:
  -h, --help   help for apps

Global flags:
      --api-key string        Your API key to use for the command
      --color string          turn on/off color output (on, off, auto)
      --config string         config file (default is $HOME/.config/stripe/config.toml)
      --device-name string    device name
      --log-level string      log level (debug, info, trace, warn, error) (default "info")
  -p, --project-name string   the project name to read from for config (default "default")

We fix this bug by overriding the default help function in the mainline CLI's plugin command: we call into the plugin process, passing along the --help flag so that the plugin process's help function gets invoked.

@vcheung-stripe vcheung-stripe requested a review from a team as a code owner August 29, 2022 19:29
Copy link
Contributor

@etsai-stripe etsai-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

@vcheung-stripe vcheung-stripe merged commit ed6cd48 into stripe:master Aug 30, 2022
@vcheung-stripe vcheung-stripe deleted the vcheung/fix-plugin-help-flag branch August 30, 2022 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants