Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

argparse CLI #1

Merged
merged 1 commit into from
Nov 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 41 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import argparse
import os
import pickle
import sys
#from IPython import embed
from tqdm import tqdm
from itertools import combinations
Expand Down Expand Up @@ -37,18 +39,47 @@ def get_tree():
return tree

if __name__ == "__main__":
tree = get_tree()
if len(sys.argv) > 1:
parser = argparse.ArgumentParser(
description="Generator of Rad Names from Decent Paper Acronyms"
)
parser.add_argument(
"words",
type=str,
nargs="+",
help="Paper title words.",
)
parser.add_argument(
"--ordered",
action="store_true",
help="Preserve word order.",
)
parser.add_argument(
"--minwords",
type=int,
default=0,
help="Minimum number of used words. (default 0 => use all.)",
)
args = parser.parse_args()
words = args.words
preserve_order = args.ordered
use_all = args.minwords in (0, len(words))
minwords = 1
if not use_all:
minwords = args.minwords
else:
print()
print("Please input paper title words separated by spaces")
words = input(">").split(" ")

print()
print("Please input paper title words separated by spaces")
words = input(">").split(" ")
words = [word.lower() for word in words]
preserve_order = input("Preserve word order? y/n >") == "y"
use_all = input("Force use of all words? y/n >") == "y"
minwords = 1
if not use_all:
minwords = eval(input("Minimum number of used words: >"))

preserve_order = input("Preserve word order? y/n >") == "y"
use_all = input("Force use of all words? y/n >") == "y"
minwords = 1
if not (use_all):
minwords = eval(input("Minimum number of used words: >"))
tree = get_tree()
words = [word.lower() for word in words]

orders = []
if preserve_order and use_all:
Expand Down