Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·67 lines (52 loc) · 1.75 KB
/
Copy pathmain.py
File metadata and controls
executable file
·67 lines (52 loc) · 1.75 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
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
"""
main.py - M8S5 Main Entry Point Module
Minimal entry point that orchestrates the core healthcheck modules
(validation, discovery, reporting, cli) and maintains backward
compatibility with existing CLI invocation patterns.
"""
import sys
from typing import Optional, List
from pathlib import Path
# Ensure project root is on sys.path for module imports
sys.path.insert(0, str(Path(__file__).parent))
import cli
from discovery import DiscoveryError
from core.validation import ValidationError
def main(argv: Optional[List[str]] = None) -> int:
"""Main entry point for the healthcheck CLI.
Args:
argv: Optional list of command-line arguments.
Defaults to sys.argv[1:] when None.
Returns:
int: Exit status (0 for success, non-zero for failure).
"""
if argv is not None:
sys.argv = [sys.argv[0]] + argv
try:
args = cli.parse_arguments()
if args.help_flag:
cli.print_help()
return 0
results = cli.run_health_check(
skill_name=args.skill_name if args.skill_name else None,
all_flag=args.all_flag,
)
cli.generate_all_reports(results)
return 0
except KeyboardInterrupt:
print("\nOperation interrupted by user.", file=sys.stderr)
return 1
except SystemExit as exc:
return int(exc.code) if exc.code is not None else 0
except DiscoveryError as e:
print(f"Discovery error: {e}", file=sys.stderr)
return 1
except ValidationError as e:
print(f"Validation error: {e}", file=sys.stderr)
return 1
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
return 1
if __name__ == "__main__":
sys.exit(main())