Files
scott/docs/api-reference.md
2026-09-16 22:34:34 +05:30

36 lines
1.2 KiB
Markdown

---
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 the `commands/` packages and (b) is prepended to `sys.path`
so 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:
1. Imports the command module; if it cannot be imported, prints a warning to *stderr* and skips
the command.
2. Verifies `s_run` method exists, is callable, and takes **exactly one** parameter; otherwise warns
to *stderr* and skips the command.
3. Creates an `argparse` subparser named `cmd_name`, using `s_description()` (if present) as its
help text.
1. 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)`.