I'm using the great Cobra (https://github.com/spf13/cobra) package to
implement subcommands in my (little) code.
I have two questions, the first is more Cobra-related (I didn'f find a
cobra google group) and the second more general:
* I have (for example) two subcommands A and B and the A subcommand include
some functions and the function called by B
* Thus A and B need to share some flags
* I can't attach the same flags to two different subcommands otherwise my
program will crash with `panic: <B> flag redefined: <flag name>
This is also described in https://code.google.com/p/go/issues/detail?id=298
I can agree that using the same flag with different meanings in different
context can be confusing, but the same flag with the same meaning
shouldn't be a problem. Moreover, now I have to put the flags as persistent
and attach them to the root command and I
don't think this is a great solution because I am linking flags with a
command (the root one) that doesn't need them.
Is there a better solution?
Why is not possible to check for redefined flags at compile time (given
that they are written in the source) instead of crash
at run time?
thanks a lot
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firstname.lastname@example.org.
For more options, visit https://groups.google.com/groups/opt_out.