-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_67.py
More file actions
39 lines (25 loc) · 847 Bytes
/
Copy pathexample_67.py
File metadata and controls
39 lines (25 loc) · 847 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
33
34
35
36
37
38
39
import typer
"""See https://typer.tiangolo.com/tutorial/commands/context/"""
"""
Configuring the Context
You can pass configurations for the context when creating a command or callback
You can read more about this at:
https://click.palletsprojects.com/en/7.x/api/#context
For example, you could keep additional CLI parameters not declared in your CLI
program with `ignore_unknown_options` and `allow_extra_args`
Then you can access those extra raw CLI parameters as a `list` of `str` in
`ctx.args`:
"""
app = typer.Typer()
@app.command(
context_settings={"allow_extra_args": True, "ignore_unknown_options": True}
)
def main(ctx: typer.Context):
"""
Try running with:
--name Camila --city Berlin
"""
for extra_arg in ctx.args:
print(f"Got extra arg: {extra_arg}")
if __name__ == "__main__":
app()