I've been looking online a lot for guidelines that explains how to write a good usage output of a program.
Lets say I have some little program written in Python:
import sys
def main():
if len(sys.argv < 5):
print("Wrong usage")
else:
#Do something with the 4 parameters
#First two looks like this: -s1 SOMETHING1
#Second two looks like this: -s2 SOMETHING2
if __name__ == "__main__":
main()
And lets say I'm calling this program like this:
py someProgram.py -s1 SOMETHING1 -s2 SOMETHING2
first 2 arguments are required, and the other 2 parameters aren't.
What would be a good practice of a usage message ?
I thought of something like this :
Usage: py program.py -p1 param1 [-p2 param2]
Is this right ? I feel like the -p1 param1
part is wrong, it just doesn't look right.
EDIT: Ok, I'm getting super lost at the argparse documentation. Can someone please provide a simple example of my need ? Is it possible to connect 2 parameters together ? lets say if I'm trying to access args.u it will give me the param1 value ?