-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
area/v3relates to / is being considered for v3relates to / is being considered for v3kind/bugdescribes or fixes a bugdescribes or fixes a bugstatus/triagemaintainers still need to look into thismaintainers still need to look into this
Description
Dear developers,
My urfave/cli version is
( v3.6.1 )
Checklist
- Are you running the latest v3 release? The list of releases is here.
- Did you check the manual for your release? The v3 manual is here
- Did you perform a search about this problem? Here's the GitHub guide about searching.
Dependency Management
- My project is using go modules.
Describe the bug
Specifying a required flag breaks shell completion generation.
To reproduce
With greet defined as below with required dummy flag and EnableShellCompletion: true:
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/urfave/cli/v3"
)
func main() {
cmd := &cli.Command{
Name: "greet",
Usage: "fight the loneliness!",
EnableShellCompletion: true,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "dummy",
Usage: "dummy required flag",
Required: true,
},
&cli.BoolFlag{
Name: "debug",
Aliases: []string{"d"},
Usage: "debug flag",
Value: false,
},
},
Action: func(context.Context, *cli.Command) error {
fmt.Println("Hello friend!")
return nil
},
}
if err := cmd.Run(context.Background(), os.Args); err != nil {
log.Fatal(err)
}
}Observed behavior
When running greet completion bash I get following otuput:
$ ./greet completion bash
NAME:
greet completion - Output shell completion script for bash, zsh, fish, or Powershell
USAGE:
greet completion
DESCRIPTION:
Output shell completion script for bash, zsh, fish, or Powershell.
Source the output to enable completion.
# .bashrc
source <(greet completion bash)
# .zshrc
source <(greet completion zsh)
# fish
greet completion fish > ~/.config/fish/completions/greet.fish
# Powershell
Output the script to path/to/autocomplete/greet.ps1 an run it.
OPTIONS:
--help, -h show help
2025/11/30 20:34:36 Required flag "dummy" not set
Expected behavior
I was expecting that generating of shell completion is not dependant on required flags. The observed behaviour is not documented as well.
Run go version and paste its output here
go version go1.25.4 darwin/arm64
Metadata
Metadata
Assignees
Labels
area/v3relates to / is being considered for v3relates to / is being considered for v3kind/bugdescribes or fixes a bugdescribes or fixes a bugstatus/triagemaintainers still need to look into thismaintainers still need to look into this