Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions handlers/cmd/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import subprocess
from handlers.pyprompt import Terminal
from handlers.config import getConfigData
from handlers.stir.stir import stir

# from handlers.stir.stir import stir # Importing stir function from handlers.stir.stir
from handlers.stir.stir import stir_hot_reload # Import the specific function
pyp = Terminal()

def list():
Expand Down Expand Up @@ -32,15 +32,13 @@ def run(group, hot=False):
pyp.error(f"No commands found for group '{group}'.")
return

pyp.good(f"Running commands in group: [high]{group}[/high]")
for cmd in commands:
pyp.high(f"→ Executing: {cmd}")
os.system(cmd)
pyp.good(f"✔ Command succeeded: {cmd}")
# Enable stir mode if hot flag is passed
if hot:
pyp.good("Stir mode is enabled.")
stir()
if hot:
stir_hot_reload()
else:
for cmd in commands:
pyp.high(f"→ Executing: {cmd}")
os.system(cmd)
pyp.good(f"✔ Command succeeded: {cmd}")

except Exception as e:
pyp.error(f"Error running commands: {e}")
7 changes: 6 additions & 1 deletion handlers/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
DEFAULT_COOK_CONFIG = {
"name": "",
"author": "",
"stir": True,
# "stir": True,
"cmd": {
"serve": [],
"build": [],
Expand All @@ -32,6 +32,11 @@
}
}

DEFAULT_STIR_CONFIG = {
"command": [],
"ignore_patterns": [],
"watch_dir": ""
}

COOK_BANNER = r'''
_________ ____ __ __
Expand Down
35 changes: 35 additions & 0 deletions handlers/stir/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from enum import Enum

class Color(Enum):
RED = '\033[91m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
BLUE = '\033[94m'
MAGENTA = '\033[95m'
CYAN = '\033[96m'
WHITE = '\033[97m'
RESET = '\033[0m'

def log(color: Color, message: str):
"""Print a colored log message"""
print(f"{color.value}{message}{Color.RESET.value}")

def info(message: str):
"""Print an info message"""
log(Color.CYAN, f"{message}")

def success(message: str):
"""Print a success message"""
log(Color.GREEN, f"{message}")

def warning(message: str):
"""Print a warning message"""
log(Color.YELLOW, f"{message}")

def error(message: str):
"""Print an error message"""
log(Color.RED, f"{message}")

def debug(message: str):
"""Print a debug message"""
log(Color.MAGENTA, f"{message}")
Loading