File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ func ShowAppHelp(c *Context) error {
148148
149149// ShowCommandHelp prints help for the given command
150150func ShowCommandHelp (ctx * Context , command string ) error {
151- if c := ctx .App .Command (command ); c != nil {
151+ if c := ctx .App .BestCommand (command ); c != nil {
152152 if c .DescriptionFunc != nil {
153153 c .Description = c .DescriptionFunc (c , ctx .App )
154154 }
Original file line number Diff line number Diff line change @@ -237,6 +237,29 @@ func TestShowCommandHelp_CommandAliases(t *testing.T) {
237237 }
238238}
239239
240+ func TestShowCommandHelp_CommandShortcut (t * testing.T ) {
241+ app := & Application {
242+ Commands : []* Command {
243+ {
244+ Name : "bar" ,
245+ Category : "foo" ,
246+ Aliases : []* Alias {{Name : "fb" }},
247+ Action : func (ctx * Context ) error {
248+ return nil
249+ },
250+ },
251+ },
252+ }
253+
254+ output := & bytes.Buffer {}
255+ app .Writer = output
256+ app .Run ([]string {"foo" , "help" , "f:b" })
257+
258+ if ! strings .Contains (output .String (), "foo:bar" ) {
259+ t .Errorf ("expected output to include command name; got: %q" , output .String ())
260+ }
261+ }
262+
240263func TestShowCommandHelp_DescriptionFunc (t * testing.T ) {
241264 app := & Application {
242265 Commands : []* Command {
You can’t perform that action at this time.
0 commit comments