import argparse
def main():
# Create the parser
parser = argparse.ArgumentParser(description="Example script.")
# Add arguments with both short and long options
parser.add_argument('-a1', '--arg1', type=str, required=True, help="First argument (string).")
parser.add_argument('-a2', '--arg2', type=int, required=True, help="Second argument (integer).")
# Parse the arguments
args = parser.parse_args()
# Use the arguments
print(f"arg1: {args.arg1}")
print(f"arg2: {args.arg2}")
if __name__ == "__main__":
main()Parser example
Usage in bash: python parser_example.py -a1 "hello" -a2 42