Repository navigation
fix(help): show command flags in 'fastly help <subcommand>' matching '--help' - #1972
Open
Tyagiquamar wants to merge 1 commit into
Open
Tyagiquamar wants to merge 1 commit into
Tyagiquamar wants to merge 1 commit into
Conversation
…'--help' Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>
|
Thanks for the contribution! This pull request doesn't follow our pull request template:
Please edit the description to use the template. If it is still missing after 3 days, this pull request will be closed automatically. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Running
fastly <subcommand> --helpdisplays command-specific flags underREQUIRED FLAGSandOPTIONAL FLAGS, followed byGLOBAL FLAGS. However, runningfastly help <subcommand>(e.g.fastly help service create) only printsGLOBAL FLAGSand completely omits the subcommand's required and optional flags, as well as its detailed description.Root cause
In
pkg/app/usage.go,VerboseUsageTemplate(the template used when parsing Kingpin help commands viaapp.Parse("help ...")) only included blocks forSUBCOMMANDSandGLOBAL FLAGS. It lacked template directives to render.Context.SelectedCommand.Helpas well as.Context.Flags|RequiredFlagsand.Context.Flags|OptionalFlags. As a result, help requested viafastly help <subcommand>dropped all command-specific flags and descriptions.Fix
VerboseUsageTemplateinpkg/app/usage.goto include:{{.Context.SelectedCommand.Help|Wrap 0}}when.Context.SelectedCommand.Helpis present.REQUIRED FLAGSblock using{{if .Context.Flags|RequiredFlags -}}.OPTIONAL FLAGSblock using{{if .Context.Flags|OptionalFlags -}}.pkg/app/run_test.go(TestHelpSubcommandFlags) verifying thatfastly help service createandfastly help service alert createproperly outputOPTIONAL FLAGS,REQUIRED FLAGS, andGLOBAL FLAGS.Validation
go test -v ./pkg/app(all tests passed, includingTestHelpSubcommandFlags).fastly help service createandfastly help service alert createagainst the built binary and verified that required, optional, and global flags are displayed consistently with<subcommand> --help.gofmton modified files.Related issue
Fixes #950