runegraft.cli. By the end you’ll have a fully interactive shell plus automation-friendly commands.
1. Create the CLI object
name sets the shell prompt (forge>) and prefixes the help table. Use the description to display a sentence at the top of help output.
2. Choose a root behavior
Decide what should happen when the CLI is launched with no arguments. Most projects keep the built-in shell:3. Register commands with routes
<name:type>tokens ensure positional arguments are parsed and validated up front.- Optional arguments live in
[brackets]and default toNone. - The first line of the docstring becomes the help summary.
4. Add options and flags
Any parameter not in the route automatically becomes an option:dry_runis inferred as a flag because of theboolannotation.retriesuses the explicitoptionhelper to set short/long names and help text.
5. Register custom types
Some domains need more thanint or path. Use cli.type() to register your own transformer:
<version:semver> appears in a route, Runegraft will call parse_semver.
6. Wire up __main__
Finally, expose a main() that builds the CLI and calls run:
python -m runegraft launches the shell, while python -m runegraft install https://… works in scripts. Package the module with project.scripts to ship a standalone runegraft binary.