Consider:
import getopt
options, remainder = getopt.getopt(sys.argv[1:], 'd:a', ['directory=',
'algorithm',
'version=',
])
print 'OPTIONS :', options
for opt, arg in options:
if opt in ('-d', '--dir'):
directory_path = arg
elif opt in ('-a', '--alg'):
algorithm = arg
elif opt == '--version':
version = arg
This script works fine, but if the user does not specify any argument (the -d option is a must), how do I specify this and make the program continue without exiting with an error: as no file path specified
If the user does not know which arguments are available to use, how do I show like help or usage?