@@ -63,6 +63,36 @@ func TestCompletionShell(t *testing.T) {
6363 }
6464}
6565
66+ func TestCompletionFishFormat (t * testing.T ) {
67+ // Regression test for https://github.com/urfave/cli/issues/2285
68+ // Fish completion was broken due to incorrect format specifiers
69+
70+ cmd := & Command {
71+ Name : "myapp" ,
72+ EnableShellCompletion : true ,
73+ }
74+
75+ r := require .New (t )
76+
77+ // Test the fish shell completion renderer directly
78+ fishRender := shellCompletions ["fish" ]
79+ r .NotNil (fishRender , "fish completion renderer should exist" )
80+
81+ output , err := fishRender (cmd , "myapp" )
82+ r .NoError (err )
83+
84+ // Verify the function name is correctly formatted
85+ r .Contains (output , "function __myapp_perform_completion" , "function name should contain app name" )
86+
87+ // Verify no format errors (like %! or (string=) which indicate broken fmt.Sprintf)
88+ r .NotContains (output , "%!" , "output should not contain format errors" )
89+ r .NotContains (output , "(string=" , "output should not contain invalid fish syntax" )
90+
91+ // Verify the complete commands reference the app correctly
92+ r .Contains (output , "complete -c myapp" , "complete command should reference app name" )
93+ r .Contains (output , "(__myapp_perform_completion)" , "completion function should be registered" )
94+ }
95+
6696func TestCompletionSubcommand (t * testing.T ) {
6797 tests := []struct {
6898 name string
0 commit comments