forked from RK1905101/Mini_Python_Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand_line_pyjokes.py
More file actions
29 lines (24 loc) · 810 Bytes
/
command_line_pyjokes.py
File metadata and controls
29 lines (24 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pyjokes
import click
"""
USAGE:
python command_line_pyjokes.py -l en -c chuck
where 'en' is the language and 'chuck' is the category (both arguments are optional)
python command_line_pyjokes.py --help
to get more information on usage.
"""
@click.command()
@click.option(
"--language", "-l", default="en", help="Select the language of the joke among: 'en', 'de', 'es', 'gl' , 'eus'"
)
@click.option("--category", "-c", default="neutral", help="Select a category among: 'neutral', 'chuck', 'all'")
def joke(language, category):
"""Simple function that tells nerdy jokes according to chosen language & category."""
print(
pyjokes.get_joke(
language=language,
category=category
)
)
if __name__ == "__main__":
joke()