alecthomas / kingpin

CONTRIBUTIONS ONLY: A Go (golang) command line and flag parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

subcommand structure help

keith6014 opened this issue · comments

So, I have something like this

var (
app=kingpin.New("cmd")

l = app.command("l")
le=l.Arg("e","E")

s = app.command("s")
se=s.Arg("e","E")
seE=s.Arg("n","number").Int()

)

My intention is to have something like this

cmd l production 
cmd s production apple # s is the subcommand, production is an environment, target is apple
cmd s production apple 10 # s is the subcommand, production is an environment, target is apple with 10 objects

How can I setup a structure in kinpin for something like that?

You can't do that unfortunately. Variable arguments can't be interspersed with commands.

If you're feeling adventurous you could try Kong, which has a solution for this exact problem, among others.