-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvalidate_config.py
More file actions
27 lines (23 loc) · 749 Bytes
/
validate_config.py
File metadata and controls
27 lines (23 loc) · 749 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
#!/usr/bin/env python3
import argparse
import sys
import os
# First try importing via site-packages path, then try directly from "src"
try:
from autopatch.actions_handler import ConfigReader
except ImportError:
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
from src.actions_handler import ConfigReader
def main():
parser = argparse.ArgumentParser(description="Validate config")
parser.add_argument("config_file", help="Path to config file")
args = parser.parse_args()
try:
ConfigReader(args.config_file)
# green color
print("\033[92mConfig is valid\033[0m")
except Exception as e:
print(f"Error: {e}")
sys.exit(1)
if __name__ == "__main__":
main()