-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Sean Collings edited this page Jul 6, 2021
·
6 revisions
At it's simplest, Arc centers around a CLI object
from arc import CLI
cli = CLI()Commands are created using Python decorators. A function becomes a command using the cli.comand() decorator. You can pass a name into the command decorator. If there isn't an explicit name, the function's name will be used. This will be the name used to execute the command.
@cli.command("hello")
def hello():
print("Hello, World!")To run the CLI, you simply need to call the cli, like you would call a regular function
cli()from arc import CLI
cli = CLI()
@cli.command("hello")
def hello():
'''Command that prints Hello World'''
print("Hello, World!")
cli()$ python example.py hello
Hello, World!
All CLI's come bundled with a help command that displays all installed commands. The command uses the function's docstring as it's documentation
$ python example.py --help
USAGE
cli <command> [arguments ...]
DESCRIPTION
Handles default arguments
ARGUMENTS
--help shows this help
--version displays the version
SUBCOMMANDS
help Displays information for a given command
hello Command that prints Hello World
You can take control of what the help command outputs, by creating your own command with the name help
@cli.command("help")
def helper():
# print out your helper :)