go-flags
go-flags copied to clipboard
Dependent parameter
There is no way to specify that parameter is dependent to another parameter (where parameter is only meaningful if some other parameter is set or in docopt notation "-a [-x [-y 255]]"). This could be quite elegantly achieved by adding additional flag to variable notation specifying reverse dependancy to parent flag:
type Some struct { A bool 'short "a"' X bool 'short "x"` Y int 'short "y" depends="a,x"' }
It would throw an error where -y would be specified while -a and -x wouldn't be present.
This would greatly enhance flexibility and prevent additional checking for parameter combinations within the code, which on its own is not a problem, but emitting the errors to keep the common look & feel is :)
(great work, you are running circles around other command line parsing libraries)
Submitted pull request