-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_03.py
More file actions
32 lines (22 loc) · 866 Bytes
/
Copy pathexample_03.py
File metadata and controls
32 lines (22 loc) · 866 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
30
31
32
"""See https://typer.tiangolo.com/tutorial/first-steps/"""
# This time with Arguments and Options
# CLI options begin with -- so they are named, therefore order for these
# is not important
# By Default:
# - A CLI argument is required
# - A CLI option is optional
# Parameters of type `bool` are automatically interpreted as CLI options
# rather than CLI arguments
# Also
# - CLI arguments depend on the sequence order
# - CLI options start with -- and don't depend on the order
# Note that for this boolean flag, Type automatically creates a
# --formal and --no-formal option as shown if you run with the --help option
import typer
def main(name: str, age: int, formal: bool = False):
if formal:
print(f"Good day Ms. {name}")
else:
print(f"Hello {name}, what's it like to be {age}?")
if __name__ == "__main__":
typer.run(main)