-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic.py
More file actions
32 lines (26 loc) · 946 Bytes
/
basic.py
File metadata and controls
32 lines (26 loc) · 946 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
#!/usr/bin/env python
# PYTHON_ARGCOMPLETE_OK
"""
CommandLine:
cd ~/code/scriptconfig
python examples/basic.py --help
# The command line if flexible by default
python examples/basic.py --my-option1=3
python examples/basic.py --my_option1=4
python examples/basic.py "a positional arg"
python examples/basic.py --position-arg "positional args can always be given as key/value pairs"
"""
import scriptconfig as scfg
import ubelt as ub
import rich
import rich.markup
class MyConfig(scfg.DataConfig):
position_arg = scfg.Value(None, help='position argument', position=1)
my_option1 = scfg.Value(None, help='option1')
my_option2 = scfg.Value(None, help='option2')
@classmethod
def main(cls, cmdline=1, **kwargs):
self = cls.cli(cmdline=cmdline, data=kwargs)
rich.print('Called My Script With: ' + rich.markup.escape(ub.urepr(self)))
if __name__ == '__main__':
MyConfig().main()