Browse Source

init

master
Robin Thoni 3 years ago
commit
537a5cfdd8
Signed by: Robin THONI <robin@rthoni.com> GPG Key ID: 4E09DEF46B99E61E
3 changed files with 33 additions and 0 deletions
  1. 1
    0
      .gitignore
  2. 30
    0
      main.py
  3. 2
    0
      requirements.txt

+ 1
- 0
.gitignore View File

@@ -0,0 +1 @@
1
+.idea

+ 30
- 0
main.py View File

@@ -0,0 +1,30 @@
1
+#! /usr/bin/env python3
2
+
3
+import sys
4
+
5
+import argparse
6
+import pydantic
7
+
8
+
9
+class Options(pydantic.BaseModel):
10
+    config_path: str = pydantic.Field(alias='config')
11
+
12
+
13
+def main(argv):
14
+    default_options = Options(**{
15
+        'config': './config.yml'
16
+    })
17
+
18
+    parser = argparse.ArgumentParser(description='Some awesome project')
19
+    parser.add_argument('-c', '--config', type=str, default=default_options.config_path, help='Path to config file')
20
+    args = parser.parse_args(argv[1:])
21
+
22
+    options = Options(**vars(args))
23
+
24
+    print(options.config_path)
25
+
26
+    return 0
27
+
28
+
29
+if __name__ == '__main__':
30
+    sys.exit(main(sys.argv))

+ 2
- 0
requirements.txt View File

@@ -0,0 +1,2 @@
1
+pydantic~=1.6.1
2
+argparse~=1.4.0

Loading…
Cancel
Save