Skip to content

Commit 6eedc2a

Browse files
committed
feat(01_hello): add answer
1 parent 443b4a8 commit 6eedc2a

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

‎01_hello/hello.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python3
2+
"""hello module."""
3+
4+
import argparse
5+
from typing import Any
6+
7+
8+
def get_args(args: list[Any] | None = None) -> argparse.Namespace:
9+
"""Get parsed argparse agruments."""
10+
parser = argparse.ArgumentParser(
11+
description="Say hello",
12+
allow_abbrev=False,
13+
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
14+
)
15+
parser.add_argument(
16+
"-n",
17+
"--name",
18+
default="World",
19+
help="The name to greet",
20+
)
21+
22+
return parser.parse_args(args)
23+
24+
25+
def main():
26+
"""Run main logic."""
27+
args = get_args()
28+
print(f"Hello, {args.name}!")
29+
30+
31+
if __name__ == "__main__":
32+
main()

0 commit comments

Comments
 (0)