Dear developers,
My urfave/cli version is
( v3.6.1 )
Checklist
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
Dear developers,
My urfave/cli version is
( v3.6.1 )
Checklist
Dependency Management
Describe the bug
Specifying a required flag breaks shell completion generation.
To reproduce
With
greetdefined as below with requireddummyflag andEnableShellCompletion: true:Observed behavior
When running
greet completion bashI get following otuput: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 versionand paste its output herego version go1.25.4 darwin/arm64