All docs
Tool·
decorator
Tool.command
declares an lsd CLI command from a typed function
Python
command(name, *, help="")
Returns Callable — the decorated function, unchanged
Parameters#
| name | type | default | description |
|---|---|---|---|
name |
str |
— | the sub-command name, invoked as lsd <tool> <name> |
help |
str |
"" |
one-line help text shown in lsd <tool> --help |
Example#
Python
@tool.command("count", help="Count rows in a file")
def count(ctx, path: str) -> None:
print(len(Source.file(path).read()))
Notes#
The function is (ctx, ...); its typed parameters become CLI options — no default → required
positional/option, with default → optional. There is no argparse to write. The command is surfaced
when the tool is mounted into a CLI host.
See also#
API: action · dispatch · Context
Guides: Commands & actions · A CLI command
By LSD Team · Last updated Jul 17, 2026
Ask on Discord
View as Markdown