pyinvoke / invoke

Pythonic task management & command execution.
http://pyinvoke.org
BSD 2-Clause "Simplified" License
4.35k stars 366 forks source link

required non-positional arguments #707

Open anarcat opened 4 years ago

anarcat commented 4 years ago

I have this task that transfers virtual machines between two servers. It operates like this:

fab -H instance migrate --from FOO --to BAR

FOO and BAR are deliberately not positional arguments because I wanted to remove the risk of confusion due to ambiguity. Specifying the arguments with --option makes the naming explicit. Maybe that's not a strong argument for this job, so consider the retirement task:

fab -H instance retire --ganeti-master FOO --puppet-server BAR --backupserver BAZ

In this case, I could also have used positional arguments to make sure the user provides all arguments, but then the order would have been totally arbitrary. Why is the ganeti master before the puppet server?

Therefore, I would like to be able to specify arguments as required, regardless of whether they are positional or not. Maybe required=True argument like argparse does?

Thanks!

PS: This is the inverse of #159 and is not named "required optional arguments" because that would be confusing and silly. ;)

NoCodingAllowed commented 3 years ago

Seconded, I would like this to remove ambiguity as well