Browse Source

Add option to supply quote at command line

pull/45/head
Joey Territo 2 years ago
parent
commit
1f36d10ea7
1 changed files with 7 additions and 0 deletions
  1. +7
    -0
      src/quote.py

+ 7
- 0
src/quote.py View File

@ -57,6 +57,7 @@ def print_usage():
print("Usage:") print("Usage:")
print("\t-a quote \t: Adds a quote to the quotes list") print("\t-a quote \t: Adds a quote to the quotes list")
print("\t-h \t\t: Prints usage message") print("\t-h \t\t: Prints usage message")
print("\t-q quote \t: Print this quote")
print("\t--<ASCII image to use> : name of a file (excluding extension) in " print("\t--<ASCII image to use> : name of a file (excluding extension) in "
"the \"asciiArt\" directory to use for the ASCII image") "the \"asciiArt\" directory to use for the ASCII image")
@ -91,6 +92,12 @@ def main():
add_quote() add_quote()
else: else:
print("You forgot to enter a quote.") print("You forgot to enter a quote.")
elif sys.argv[1].lower() == '-q':
if len(sys.argv) > 2:
quote = ' '.join(sys.argv[2:])
print_message(quote)
else:
print('You forgot to enter a quote.')
elif sys.argv[1][:2] == "--": elif sys.argv[1][:2] == "--":
quotes = module.input_file(INPUT_FILE) quotes = module.input_file(INPUT_FILE)
print_message(quotes[random.randint(0,(len(quotes) -1))], ascii_file=sys.argv[1][2:]+'.txt') print_message(quotes[random.randint(0,(len(quotes) -1))], ascii_file=sys.argv[1][2:]+'.txt')

Loading…
Cancel
Save