-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
55 lines (42 loc) · 1.2 KB
/
example.py
File metadata and controls
55 lines (42 loc) · 1.2 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
"""Advanced example with string option argument.
This example demonstrates:
- String option arguments
- Using uv run (default runner)
"""
import argparse
import sys
from pathlib import Path
from argparse_ps1 import generate_ps1_wrapper
def main() -> int:
"""Main entry point."""
parser = argparse.ArgumentParser(description="Advanced example with options")
parser.add_argument(
"-o",
"--option",
type=str,
help="String option argument",
)
parser.add_argument(
"--make-ps1",
action="store_true",
help="Generate PowerShell wrapper script",
)
args = parser.parse_args()
if args.make_ps1:
# Generate PowerShell wrapper script using uv run
output = generate_ps1_wrapper(
parser,
script_path=Path(__file__).resolve(),
skip_dests={"make_ps1"},
)
print(f"Generated PowerShell wrapper: {output}")
return 0
# Handle the option
if args.option:
print(f"Option value: {args.option}")
else:
print("No option provided. Use --option <value> to set a value.")
return 0
if __name__ == "__main__":
sys.exit(main())