Prefer a parser error to occur if option '--tang-url' is specified, but '--clevis=tang' is not.
mulkieran opened this issue · 2 comments
Also, '--trust-url' and '--thumbprint' should require that '--tang-url' be set.
This is hard to enforce inside the parser using add_argument
keyword arguments, but could be done at the very end of parsing, perhaps.
Everything that requires a StratisCliParserError falls into this category. The problem is that an argparse.ArgumentError requires an argument that represents a parse something, like a RangeAction.
I believe that it is possible to resolve this problem with a custom Action class. I haven't found any way to use a custom ActionClass to make this work. One way is to add an additional set of optional subcommands to the create
subcommand, one called "nbde" or "tang", one called "tpm". "tpm" has no arguments of its own, but "nbde"/"tang" has a mandatory "url" argument. This also has some problems, it feels a bit unintuitive. On the other hand, there wouldn't be any problem with ignored options, while there certainly is a problem now. Yet another possibility is to extend ArgumentParser with a special subclass that will modify parse_args
in order to check the coherence of the arguments.