-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (31 loc) · 928 Bytes
/
main.py
File metadata and controls
37 lines (31 loc) · 928 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
#!/usr/bin/env python3
"""Workflow tool."""
import argparse
import logging
import sys
log = logging.getLogger(__name__)
class Pycli:
def __init__(self, config_path: str = "config.yaml"):
self.config = self._load_config(config_path)
log.info("pycli initialized")
def _load_config(self, path: str) -> dict:
import yaml, os
if not os.path.exists(path):
return {"verbose": False}
with open(path) as f:
return yaml.safe_load(f) or {}
def run(self) -> int:
log.info("pycli running...")
return 0
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("-c", "--config", default="config.yaml")
parser.add_argument("-v", "--verbose", action="store_true")
args = parser.parse_args()
logging.basicConfig(
level=logging.DEBUG if args.verbose else logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
)
sys.exit(Pycli(args.config).run())
if __name__ == "__main__":
main()