49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
from .cli import CLI, ParsedCommandInput
|
|
|
|
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%",
|
|
]
|
|
|
|
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)
|
|
|
|
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)
|
|
return 0
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|