fastly/cli

output for `fastly subcommand help` and `fastly subcommand --help` don't match

Opened this issue · 1 comments

Version

; fastly version
Fastly CLI version v10.2.0 (a61eac5c)
Built with go version go1.20.4 linux/amd64

What happened

i was setting up a new service, and noticed that certain command-line flags are not shown, depending on how you ask the Fastly CLI for help:

; fastly service create --help 
USAGE
  fastly service create [<flags>]

Create a Fastly service

OPTIONAL FLAGS
      --comment=COMMENT  Human-readable comment
  -n, --name=NAME        Service name
      --type=vcl         Service type. Can be one of "wasm" or "vcl", defaults
                         to "vcl".

GLOBAL FLAGS
      --help             Show context-sensitive help.
  -d, --accept-defaults  Accept default options for all interactive prompts
                         apart from Yes/No confirmations
  -y, --auto-yes         Answer yes automatically to all Yes/No confirmations.
                         This may suppress security warnings
  -i, --non-interactive  Do not prompt for user input - suitable for CI
                         processes. Equivalent to --accept-defaults and
                         --auto-yes
  -o, --profile=PROFILE  Switch account profile for single command execution
                         (see also: 'fastly profile switch')
  -q, --quiet            Silence all output except direct command output.
                         This won't prevent interactive prompts (see:
                         --accept-defaults, --auto-yes, --non-interactive)
  -t, --token=TOKEN      Fastly API token (or via FASTLY_API_TOKEN)
  -v, --verbose          Verbose logging

SEE ALSO
  https://developer.fastly.com/reference/cli/service/create/

; fastly help service create
USAGE
  fastly [<flags>] service create [<flags>]

GLOBAL FLAGS
      --help             Show context-sensitive help.
  -d, --accept-defaults  Accept default options for all interactive prompts
                         apart from Yes/No confirmations
  -y, --auto-yes         Answer yes automatically to all Yes/No confirmations.
                         This may suppress security warnings
  -i, --non-interactive  Do not prompt for user input - suitable for CI
                         processes. Equivalent to --accept-defaults and
                         --auto-yes
  -o, --profile=PROFILE  Switch account profile for single command execution
                         (see also: 'fastly profile switch')
  -q, --quiet            Silence all output except direct command output.
                         This won't prevent interactive prompts (see:
                         --accept-defaults, --auto-yes, --non-interactive)
  -t, --token=TOKEN      Fastly API token (or via FASTLY_API_TOKEN)
  -v, --verbose          Verbose logging

SEE ALSO
  https://developer.fastly.com/reference/cli/service/create/

in my case, --type was the important flag that i was looking for, which only shows up when --help is used.

👋🏻

Yup. They behave slightly differently and my understanding is that this is a side effect of the CLI parser we're using (Kingpin), which has long been unmaintained.

Ideally, we should migrate to another parser (and that work was started by @grantstephens here #738 but the work wasn't scheduled/prioritised) but there are probably lots of edge cases and integration details we need to account for so not necessarily a simple task as we lean fairly heavily into the Kingpin features and have some custom overrides that might be tricky to migrate.

I'll raise this internally to get feedback and will report back.