-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfac.py
More file actions
executable file
·104 lines (75 loc) · 2.52 KB
/
fac.py
File metadata and controls
executable file
·104 lines (75 loc) · 2.52 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python3
"""FAC CLI - Command line interface for Founders and Coders training operations."""
import sys
from typing import List, Tuple
import config
def parse(args: List[str]) -> Tuple[str, List[str]]:
"""Parse command line arguments."""
if len(args) < 2:
return "help", []
command = args[1]
remaining_args = args[2:] if len(args) > 2 else []
return command, remaining_args
def route(args: List[str]) -> None:
"""Route command to appropriate handler."""
command, cmd_args = parse(args)
dispatch(command, cmd_args)
def dispatch(command: str, args: List[str]) -> None:
"""Dispatch to command handler."""
# Help commands don't need configuration validation
help_commands = ["help", "--help", "-h"]
if command in help_commands:
show_help()
return
commands = {
"gr": lambda: run_gr(args),
}
if command in commands:
try:
# Validate configuration for commands that need it
config.validate()
commands[command]()
except KeyboardInterrupt:
print("\nOperation cancelled by user", file=sys.stderr)
sys.exit(130)
except Exception as e:
if config.get("FAC_CLI_DEBUG", "false").lower() == "true":
raise
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)
else:
show_error(f"Unknown command: {command}")
def run_gr(args: List[str]) -> None:
"""Run gateway recent command."""
try:
from commands import gr
gr.run(args)
except ImportError:
config.error("Gateway recent command module not found")
def show_help() -> None:
"""Show help information."""
help_text = """
FAC CLI - Founders and Coders Training Operations
Usage:
./fac.py <command> [options]
Available commands:
gr Gateway recent - fetch and display recent gateway data
help, --help Show this help message
Examples:
./fac.py gr Display recent gateway data from Airtable
./fac.py help Show this help message
Configuration:
Copy .env.example to .env and configure your Airtable credentials.
For more information, see README.md
"""
print(help_text.strip())
def show_error(message: str) -> None:
"""Show error message and help."""
print(f"Error: {message}", file=sys.stderr)
print("Use './fac.py help' for usage information", file=sys.stderr)
sys.exit(1)
def main() -> None:
"""Main entry point."""
route(sys.argv)
if __name__ == "__main__":
main()