I’m writing a Python script that takes five pairs of files as arguments. I would like to allow the user to input these files as command-line arguments, but I’m worried he will put the files in the wrong order or not put a file right after the file it’s paired with. How can I design my command-line arguments to avoid this problem in the least clunky way possible?
For example, if the files are “U1”, “M1”, “U2”, “M2”, “U3”, “M3”, “U4”, “M4”, “U5”, “M5”, I’m afraid the person might put the files in the order “U1 U2 U3 U4 U5 M1 M2 M3 M4 M5”, or “U1 M2 U3 M4 M5 …”
If files logically belong together in pairs, the least error prone method is probably to require them to be entered together, e.g.
That way, you can enforce the contract that files must be entered in pairs (any -Pair argument without two input files can generate an error), and it is obvious to the user that the files must be entered together.