From 8ffa6d5aaeeae9bd3f39065f60bd62f9449ad539 Mon Sep 17 00:00:00 2001 From: lordlogo2002 Date: Fri, 3 Apr 2026 15:15:58 +0200 Subject: [PATCH] Refactor CLI commands: replace 'run' and 'build' with 'init' command for workspace setup --- nut/__main__.py | 60 ++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/nut/__main__.py b/nut/__main__.py index 477d81f..9dd7aa9 100644 --- a/nut/__main__.py +++ b/nut/__main__.py @@ -1,47 +1,45 @@ -from .cli import CLI, ParsedCommandInput +from .cli import CLI def help_text(): return [ "%bold%%cyan%nut CLI: tiny shell, big squirrel energy :3%reset%", - "%magenta%Tip:%reset% try %bold%nut help run%reset% or %bold%nut run -d --target dev foo bar%reset%", + "", + "%magenta%%bold%Tip:%reset% %cyan%Listen up, aye?%reset% This isnae a magical artefact that bends to yer whims. If it breaks, chances are %red%ye broke it.%reset%", + "%yellow%%bold%Read:%reset% The words on the screen are no decorative. They are instructions. %bold%Follow them.%reset% It’s not abstract art.", + "%blue%%bold%Fun Fact:%reset% The machine is doing exactly what ye told it to. The tragedy is %bold%what ye told it.%reset%", + "%red%%bold%Tip:%reset% If ye hammer commands like a drunken engineer, don’t act surprised when it explodes like one.", + "%cyan%%bold%Read:%reset% Slow down. Think. Then type. In that order. Not the other way around, ye absolute menace.", + "%magenta%%bold%Fun Fact:%reset% Most errors are user-generated. Aye — %bold%you’re the feature.%reset%", + "%yellow%%bold%Tip:%reset% This is a tool, not a therapist. It willnae fix poor decisions, only execute them faster.", + "%red%%bold%Fun Fact:%reset% The problem is rarely the system. It’s the organic interface attached to the keyboard.", + "%cyan%%bold%Tip:%reset% Be precise. Be deliberate. Or be prepared to be wrong — repeatedly, loudly, and with confidence.", ] def main() -> int: cli = CLI(help_callback=help_text) cli.command( - "run", - help="Run with passthrough args", - description="Run accepts known flags and also forwards unknown trailing tokens.", - aliases=["r"], - passthrough=True, - ).flag("debug", "d", help="Enable command debug mode").option( - "target", - "t", - default="dev", - help="Execution target", - ).handle(cmd_run) - - cli.command( - "build", - help="Build output", - description="Build artifacts with optional release mode and output directory.", - aliases=["b"], - ).flag("release", "r", help="Enable release build").option( - "output", - "o", - default="dist", - help="Output directory", - ).arg("inputs", nargs="*", help="Optional input names").handle(cmd_build) + "init", + help="Create an empty nut workspace or reinitialize with --force", + description=( + "Initialize a nut development workspace by creating a Nutfile and default project files. " + "If a Nutfile already exists, initialization should fail unless --force is used." + ), + ).flag( + "force", + "f", + help="Reinitialize even when a Nutfile already exists", + ).arg( + "path", + nargs="?", + default=".", + help="Directory to initialize (default: current directory)", + ).handle(cmd_init) return cli.run() -def cmd_run(args, flags) -> int: - print("RUN", args, flags) - return 0 - -def cmd_build(args, flags) -> int: - print("BUILD", args, flags) +def cmd_init(args, flags) -> int: + print("INIT", args, flags) return 0 if __name__ == "__main__":