Browse Source

Merge pull request #45 from jtt9340/master

Allow roosay quote to be specified at the command line
master
Jeffery Russell 2 years ago
committed by GitHub
parent
commit
2edfeb945e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions
  1. +9
    -0
      src/quote.py

+ 9
- 0
src/quote.py View File

@ -57,6 +57,9 @@ 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 "
"the \"asciiArt\" directory to use for the ASCII image")
def add_quote(): def add_quote():
@ -89,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