summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArjun Satarkar <me@arjunsatarkar.net>2023-05-24 16:47:46 +0000
committerArjun Satarkar <me@arjunsatarkar.net>2023-05-24 16:47:46 +0000
commitc5150be9f9f42f8928800ccf874fffa95649e7f4 (patch)
treebf038a098c467d977d763e669d2d91c494d88f88
parent504cbcec63407d8b54ba14079a74fa48513e921f (diff)
downloadDnDnDnD-c5150be9f9f42f8928800ccf874fffa95649e7f4.tar
DnDnDnD-c5150be9f9f42f8928800ccf874fffa95649e7f4.tar.gz
DnDnDnD-c5150be9f9f42f8928800ccf874fffa95649e7f4.zip
Use nicer argument parsing
-rwxr-xr-xmain.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/main.py b/main.py
index c9bfc7b..5bfc8b9 100755
--- a/main.py
+++ b/main.py
@@ -1,10 +1,11 @@
#!/usr/bin/env python3
+import argparse
import sys
-try:
- word_num = int(sys.argv[1])
-except IndexError:
- word_num = None
+parser = argparse.ArgumentParser(prog="D&D&D&D", description="Dungeons & Dragons D...")
+parser.add_argument("word_num", default=None, nargs="?", type=int)
+args = parser.parse_args()
+word_num = args.word_num
WORDLIST_FILE_PATH = "corncob_lowercase.txt"