Refactor CLI commands: replace 'run' and 'build' with 'init' command for workspace setup
This commit is contained in:
parent
8acbf2da36
commit
8ffa6d5aae
@ -1,47 +1,45 @@
|
|||||||
from .cli import CLI, ParsedCommandInput
|
from .cli import CLI
|
||||||
|
|
||||||
def help_text():
|
def help_text():
|
||||||
return [
|
return [
|
||||||
"%bold%%cyan%nut CLI: tiny shell, big squirrel energy :3%reset%",
|
"%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:
|
def main() -> int:
|
||||||
cli = CLI(help_callback=help_text)
|
cli = CLI(help_callback=help_text)
|
||||||
|
|
||||||
cli.command(
|
cli.command(
|
||||||
"run",
|
"init",
|
||||||
help="Run with passthrough args",
|
help="Create an empty nut workspace or reinitialize with --force",
|
||||||
description="Run accepts known flags and also forwards unknown trailing tokens.",
|
description=(
|
||||||
aliases=["r"],
|
"Initialize a nut development workspace by creating a Nutfile and default project files. "
|
||||||
passthrough=True,
|
"If a Nutfile already exists, initialization should fail unless --force is used."
|
||||||
).flag("debug", "d", help="Enable command debug mode").option(
|
),
|
||||||
"target",
|
).flag(
|
||||||
"t",
|
"force",
|
||||||
default="dev",
|
"f",
|
||||||
help="Execution target",
|
help="Reinitialize even when a Nutfile already exists",
|
||||||
).handle(cmd_run)
|
).arg(
|
||||||
|
"path",
|
||||||
cli.command(
|
nargs="?",
|
||||||
"build",
|
default=".",
|
||||||
help="Build output",
|
help="Directory to initialize (default: current directory)",
|
||||||
description="Build artifacts with optional release mode and output directory.",
|
).handle(cmd_init)
|
||||||
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)
|
|
||||||
|
|
||||||
return cli.run()
|
return cli.run()
|
||||||
|
|
||||||
def cmd_run(args, flags) -> int:
|
def cmd_init(args, flags) -> int:
|
||||||
print("RUN", args, flags)
|
print("INIT", args, flags)
|
||||||
return 0
|
|
||||||
|
|
||||||
def cmd_build(args, flags) -> int:
|
|
||||||
print("BUILD", args, flags)
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user