go-flags icon indicating copy to clipboard operation
go-flags copied to clipboard

Dependent parameter

Open roker opened this issue 6 years ago • 1 comments

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)

roker avatar Dec 06 '18 13:12 roker

Submitted pull request

roker avatar Dec 07 '18 14:12 roker