1

Working with jessevdk/go-flags, I would like to get the following usage command:

./main [OPTIONS] arg1 [arg2]

I am able to get the OPTIONS right but I cannot add commands. I see that I can use AddCommand but I have not been able to generate my mandatory and optional commands.

I have tried this:

type AddCommand struct {
        Arg1 string `required:true`
        Arg2 string `subcommand:"Arg1"`
}

p := flags.NewParser(&opts, flags.Default)
var arg AddCommand
p.AddCommand("arg1", "Arg1", "Arg1", &arg)
args, err := p.Parse()

What am I missing to get a command with its optional subcommand?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Arkon
  • 2,648
  • 6
  • 26
  • 46

0 Answers0