Skip to content

feat(help): add -h short flag for --help - #1918

Merged
kpfleming merged 4 commits into
fastly:mainfrom
Tyagiquamar:fix/help-short-flag-1641
Oct 5, 2026
Merged

kpfleming merged 4 commits into
fastly:mainfrom
Tyagiquamar:fix/help-short-flag-1641

Conversation

@Tyagiquamar

@Tyagiquamar Tyagiquamar commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Change summary

Adds -h as a short flag for --help, resolving #1641. The help command/flag was previously only reachable via the long form, while most other CLI flags already have short variants.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  • Does your submission pass tests?

Changes to Core Features:

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

User Impact

Users can now request help with fastly -h in addition to fastly --help, matching common CLI conventions.

Are there any considerations that need to be addressed for release?

None.

@Tyagiquamar
Tyagiquamar requested a review from a team as a code owner September 26, 2026 17:37
@Tyagiquamar
Tyagiquamar force-pushed the fix/help-short-flag-1641 branch from d02e993 to 25492eb Compare September 26, 2026 17:41

@kpfleming kpfleming left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please search the codebase for every reference to --help; there are many places where the presence of that flag is evaluated and all of them would have to also be aware of the short version.

Comment thread pkg/app/run.go
@rcaril

rcaril commented Sep 28, 2026

Copy link
Copy Markdown
Member

Hi @Tyagiquamar - please use our PR template:

### Change summary

 <!--
Briefly describe the changes introduced in this pull request. Include context or
reasoning behind the changes, even if they seem minor. If relevant, link to any
related discussions (e.g. Slack threads, tickets, documents).
-->

All Submissions:

* [ ] Have you followed the guidelines in our Contributing document?
* [ ] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/fastly/cli/pulls) for the same update/change?

<!-- You can erase any parts of this template not applicable to your Pull Request. -->

### New Feature Submissions:

* [ ] Does your submission pass tests?

### Changes to Core Features:

* [ ] Have you written new tests for your core changes, as applicable?
* [ ] Have you successfully run tests with your changes locally?

### User Impact

<!-- What is the user impact of this change? -->

### Are there any considerations that need to be addressed for release?

<!-- Any breaking changes, etc -->

@Tyagiquamar

Copy link
Copy Markdown
Contributor Author

Updated in e031ffa (comment at pkg/app/run.go explaining the name lookup + nil guard, since kingpin defines the help flag internally).

I searched the codebase for every runtime reference to --help. The complete set of places that evaluate its presence:

  • pkg/argparser/cmd.go IsHelpFlagOnly (line 288): string comparison args[0] == "--help" -> now also accepts -h.
  • pkg/argparser/cmd.go IsGlobalFlagsOnly (line 340): flag table -> -h added alongside --help.
  • pkg/argparser/flags.go ContextHasHelpFlag (line 334): looks up ctx.Elements.FlagMap()["help"] by clause name; with the short flag attached to the same clause, kingpin still keys the element as help, so this is unaffected (verified by the new tests).
  • pkg/app/usage.go (lines 291, 344, 351, 412): all go through IsHelpFlagOnly / ContextHasHelpFlag, so they inherit the short flag support.
  • pkg/app/usage.go globalFlags() map and the usage template: keyed by long name for rendering, not argument evaluation; unaffected.
  • Remaining --help mentions are help-text strings (e.g. pkg/commands/compute/setup/loggers.go), remediation messages, the help command handling (separate from the flag), shell completion scripts, and Docker/goreleaser files, none of which evaluate the flag's presence.

Validation: go build ./pkg/... and go test ./pkg/argparser/ ./pkg/app/ in Docker golang:1.26-bookworm, all green (includes the new TestShortHelpFlag and TestIsGlobalFlagsOnly cases covering -h).

Comment thread CHANGELOG.md Outdated
@kpfleming
kpfleming enabled auto-merge (squash) October 5, 2026 18:53
@kpfleming
kpfleming merged commit 81e6cb0 into fastly:main Oct 5, 2026
9 checks passed
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.

3 participants