Skip to content

Commit f92a505

Browse files
committed
cowsay implementation
1 parent eb532ec commit f92a505

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

implement-cowsay/.venv/cow.py

Whitespace-only changes.

implement-cowsay/cow.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import argparse
2+
import sys
3+
import cowsay
4+
5+
def main():
6+
available_chars = sorted(cowsay.char_names)
7+
8+
parser = argparse.ArgumentParser(
9+
description = "A CLI tool that makes ASCII characters speak!"
10+
)
11+
12+
parser.add_argument(
13+
"message",
14+
help = "The message for the character to speak."
15+
)
16+
17+
parser.add_argument(
18+
"-c","--character",
19+
choices= available_chars,
20+
default = "cow",
21+
help ="Choose a character (default:cow)"
22+
23+
)
24+
25+
args = parser.parse_args()
26+
27+
try:
28+
print(cowsay.get_output_string(args.character, args.message))
29+
except KeyError:
30+
print (f"Error : Character '{args.character}' not found.")
31+
32+
if __name__ == "__main__":
33+
main()

0 commit comments

Comments
 (0)