Created
October 17, 2022 13:26
-
-
Save MLKrisJohnson/46f8eddbb60960c37f74821491fe519d to your computer and use it in GitHub Desktop.
Test program for Python argparse module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Test program for argparse module.""" | |
import argparse | |
def main(): | |
parser = argparse.ArgumentParser( | |
description='Test Python argparse module.', | |
epilog='This script doesn\'t do anything useful.' | |
) | |
parser.add_argument('-v', '--verbose', help='verbose output', action='count', default=0) | |
parser.add_argument('-d', '--debug', help='enable debug mode', action='store_true') | |
parser.add_argument('-o', '--output', help='set output directory', metavar='<path>') | |
parser.add_argument('args', nargs='*', help='positional arguments') | |
args = parser.parse_args() | |
print(f'{vars(args)}') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment