1.2 KiB
title
| title |
|---|
| Scott API Reference |
Scott API Reference
Scott(app_dir: str, app_desc: str = "")
Creates the framework and its argument parser.
-
app_dir— typically__file__from the entry script. Scott resolves it to the containing directory, which is used to (a) locate thecommands/packages and (b) is prepended tosys.pathso the tool works no matter which directory you invoke it from. -
app_desc— description shown at the top of the tool's help output.
Scott.register(cmd_name: str)
Registers a command by dynamically importing commands.<cmd_name>.handler. During registration Scott:
-
Imports the command module; if it cannot be imported, prints a warning to stderr and skips the command.
-
Verifies
s_runmethod exists, is callable, and takes exactly one parameter; otherwise warns to stderr and skips the command. -
Creates an
argparsesubparser namedcmd_name, usings_description()(if present) as its help text. -
Calls
handler.s_arguments(subparser)(if present) so the command can add options.
Skipped commands never appear in help output and cannot be invoked.
Scott.run()
Parses the process arguments and dispatches to the selected command's s_run(args).