Story of yum module and the magic code

So I was working on changing the yum module to work with the magic module code and … we have a situation.

The yum module accepts the following arguments

state=installed pkg=pkgspec

state=removed pkg=pkgspec

state=latest pkg=pkgspec

informational commands:

list=installed

list=updates

list=available

list=repos

list=pkgspec

Now, the above module has two required arguments and the presence of ANY ONE of them is valid. That means, atleast one of state= and list= should be supplied. To make things a little more complicated, if state= is specified, then we should also have pkg= specified.

Now the module magic code does not take all of this into account. We cannot specify things like “either one of these parameters must be specified”. I am wondering what would be a better way to handle such cases?

Just handle it in the module code for now, I do not think the argument spec should deal with that kind of flow control. it does of course have defaults and choices, which are good to use.