0

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 ..."

4

1 回答 1

1

如果文件在逻辑上成对属于一起,最不容易出错的方法可能是要求它们一起输入,例如

mycommand -Pair FileA1,FileA1 -Pair FileB1,FileB2

这样,您可以强制要求文件必须成对输入(任何没有两个输入文件的 -Pair 参数都可能产生错误),并且对用户来说很明显文件必须一起输入。

于 2012-10-28T23:37:21.160 回答