-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterra_cli.py
More file actions
87 lines (74 loc) · 2.87 KB
/
terra_cli.py
File metadata and controls
87 lines (74 loc) · 2.87 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
#!/usr/bin/env python3
"""
Terra - Command line interface for Fern framework
Usage: fern [command] [options]
Commands:
bloom Check system health
sprout <project_name> Create new Fern project
fire [file] Run single file or project
prepare <platform> Build for target platform
install <package> Install Fern packages
templates Manage project templates
lsp <subcommand> Manage Language Server Protocol
help Show this help message
"""
import sys
import os
import argparse
import subprocess
from pathlib import Path
# Add the CLI modules to Python path
CLI_DIR = Path(__file__).parent
sys.path.insert(0, str(CLI_DIR))
from commands.bloom import BloomCommand
from commands.sprout import SproutCommand
from commands.fire import FireCommand
from commands.prepare import PrepareCommand
from commands.install import InstallCommand
from commands.templates import TemplatesCommand
from commands.lsp import LSPCommand
from utils.colors import Colors, print_colored
class FernCLI:
def __init__(self):
self.commands = {
'bloom': BloomCommand(),
'sprout': SproutCommand(),
'fire': FireCommand(),
'prepare': PrepareCommand(),
'install': InstallCommand(),
'templates': TemplatesCommand(),
'lsp': LSPCommand(),
}
def run(self, args):
if len(args) == 0 or args[0] in ['help', '-h', '--help']:
self.show_help()
return
command_name = args[0]
command_args = args[1:]
if command_name not in self.commands:
print_colored(f"Unknown command: {command_name}", Colors.RED)
print_colored("Run 'fern help' to see available commands", Colors.YELLOW)
return
try:
self.commands[command_name].execute(command_args)
except Exception as e:
print_colored(f"Error executing {command_name}: {str(e)}", Colors.RED)
sys.exit(1)
def show_help(self):
print_colored("🌿 Terra CLI", Colors.GREEN)
print_colored("=" * 40, Colors.CYAN)
print(__doc__)
print_colored("\nExamples:", Colors.CYAN)
print(" fern bloom # Check system health")
print(" fern sprout my_app # Create new project")
print(" fern fire main.cpp # Run single file")
print(" fern fire # Run current project")
print(" fern prepare web # Build for web")
print(" fern prepare linux # Build for linux")
print(" fern lsp start # Start LSP server")
print(" fern lsp config # Configure VS Code")
def main():
cli = FernCLI()
cli.run(sys.argv[1:])
if __name__ == "__main__":
main()