@@ -191,8 +191,8 @@ func cliArgContains(flagName string, args []string) bool {
191
191
192
192
func printFlagSuggestions (lastArg string , flags []Flag , writer io.Writer ) {
193
193
// Trim the prefix twice to handle both "-short" and "--long" flags.
194
- currentArg := strings .TrimPrefix (lastArg , "-" )
195
- currentArg = strings .TrimPrefix (currentArg , "-" )
194
+ cur := strings .TrimPrefix (lastArg , "-" )
195
+ cur = strings .TrimPrefix (cur , "-" )
196
196
for _ , flag := range flags {
197
197
if bflag , ok := flag .(* BoolFlag ); ok && bflag .Hidden {
198
198
continue
@@ -215,7 +215,7 @@ func printFlagSuggestions(lastArg string, flags []Flag, writer io.Writer) {
215
215
continue
216
216
}
217
217
// match if last argument matches this flag and it is not repeated
218
- if strings .HasPrefix (name , currentArg ) && currentArg != name && ! cliArgContains (name , os .Args ) {
218
+ if strings .HasPrefix (name , cur ) && cur != name && ! cliArgContains (name , os .Args ) {
219
219
flagCompletion := fmt .Sprintf ("%s%s" , strings .Repeat ("-" , count ), name )
220
220
if usage != "" && strings .HasSuffix (os .Getenv ("SHELL" ), "zsh" ) {
221
221
flagCompletion = fmt .Sprintf ("%s:%s" , flagCompletion , usage )
0 commit comments