I am writing a CLI tool in go and have chosen github.com/jessevdk/go-flags for the CLI arg parsing. I am trying to figure out the best way to make a positional arg mandatory. Currently, I have the following:
func main() {
args, err := flags.Parse(&opts)
if err != nil {
panic(err)
}
if len(args) < 1 {
panic("An s3 bucket is required")
}
}
This works, but it doesn't result in help output being displayed, as would be the case with a flag being marked "required:true"
. Is there a way to replicate that behavior by manually calling a "print help" function or setting a required number of positional arguments?