Created
March 21, 2023 07:13
-
-
Save Iksas/f119cdf9a8d04da85b8e1c606a6682c1 to your computer and use it in GitHub Desktop.
argparse template
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
import argparse | |
... | |
if __name__ == "__main__": | |
# parse CLI arguments | |
parser = argparse.ArgumentParser(description="Search popular Hacker News posts") | |
parser.add_argument('-u', '--update', default=False, help='update the database', action='store_true', dest='update') | |
parser.add_argument('-d', '--domain', default=False, help='search for posts from a domain', action='store_true', dest='domain') | |
parser.add_argument('query', nargs='?', help='the search query') | |
options = parser.parse_args() | |
if options.domain: | |
print(options.query) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment