Command line#
The scenet command. See the CLI reference for the interface itself;
this page documents the functions behind it.
scenet.cli#
.. py:module:: scenet.cli
Command-line entry point.
.. py:function:: build_parser()
- module:
scenet.cli
Build the argument parser for the
scenetcommand.Exposed separately from :func:
main <scenet.cli.main>so that tests, shell-completion generators and documentation tooling can inspect the interface without running it.- rtype:
- sphinx_autodoc_typehints_type:
\:py\:class\:\~argparse.ArgumentParser``
- returns:
A parser with the
build,check,schemaandmcpsubcommands defined.
.. py:function:: run_build(args)
- module:
scenet.cli
Run the
buildsubcommand: compile a document and write its outputs.- type args:
- sphinx_autodoc_typehints_type:
\:py\:class\:\~argparse.Namespace``
- param args:
Parsed arguments from :func:
build_parser <scenet.cli.build_parser>.- rtype:
- sphinx_autodoc_typehints_type:
\:py\:class\:\int``
- returns:
A process exit status –
0on success,1when the document could not be compiled,2when the source file does not exist or has an extension no frontend reads.
Every error the compiler can raise inherits
ScenetError, and all of them mean “your panel cannot be compiled” rather than “scenet broke” – so they are reported as a plain one-line message rather than a traceback.
.. py:function:: run_check(args)
- module:
scenet.cli
Run the
checksubcommand: validate documents and report what is wrong.- type args:
- sphinx_autodoc_typehints_type:
\:py\:class\:\~argparse.Namespace``
- param args:
Parsed arguments from :func:
build_parser <scenet.cli.build_parser>.- rtype:
- sphinx_autodoc_typehints_type:
\:py\:class\:\int``
- returns:
A process exit status –
0when every document is valid,1when any has a finding,2when a file does not exist or has an extension no frontend reads.
Unlike
build, this never stops at the first fault. pydantic reports every field error at once and a run over several files reports all of them, because a caller fixing them – a person or an agent – wants the whole list, not one round trip per mistake.
.. py:function:: run_schema(args)
- module:
scenet.cli
Emit the panel JSON Schema.
Generated from the pydantic models rather than hand-written, so editor completion is derived from the compiler’s own definition of the language and the two cannot disagree. It describes the syntax as written, not the IR it normalises into; see
- mod:
scenet.schema <scenet.schema>.- rtype:
- sphinx_autodoc_typehints_type:
\:py\:class\:\int``
.. py:function:: run_mcp(args)
- module:
scenet.cli
Run the
mcpsubcommand: serve the tools until the client disconnects.- type args:
- sphinx_autodoc_typehints_type:
\:py\:class\:\~argparse.Namespace``
- param args:
Parsed arguments from :func:
build_parser <scenet.cli.build_parser>.- rtype:
- sphinx_autodoc_typehints_type:
\:py\:class\:\int``
- returns:
A process exit status –
0once the client has gone,2when the optionalmcpdependency is not installed.
Nothing is printed to stdout, before or after: on the stdio transport stdout is the protocol stream. The server module is imported here rather than at the top of the file, so every other command works without the extra installed.
.. py:function:: main(argv=None)
- module:
scenet.cli
Entry point for the
scenetcommand.- type argv:
- sphinx_autodoc_typehints_type:
\:py\:class\:\~collections.abc.Sequence`\ \[:py:class:`str`] | :py:obj:`None``
- param argv:
Arguments to parse. Defaults to
sys.argv[1:], which is what happens when the installed console script runs; pass a list explicitly from tests.- rtype:
- sphinx_autodoc_typehints_type:
\:py\:class\:\int``
- returns:
A process exit status.
0on success,1for a document that will not compile,2for a usage error or a missing file.
.. admonition:: Example
from scenet.cli import main main([”–definitely-not-a-flag”]) Traceback (most recent call last): … SystemExit: 2