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 scenet command.

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 and schema subcommands defined.

.. py:function:: run_build(args)

module:

scenet.cli

Run the build subcommand: 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 status0 on success, 1 when the document could not be compiled, 2 when the source file does not exist.

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:: scene_schema()

module:

scenet.cli

The schema for a multi-panel document.

Built from the panel schema rather than declared separately, so the two can never describe different languages. A scene allows the same keys as a panel – there they act as defaults every panel inherits – plus panels, whose members may additionally carry over.

rtype:
sphinx_autodoc_typehints_type:

\:py\:class\:\dict`\ \[:py:class:`str`, :py:data:`~typing.Any`]`

.. 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.

rtype:
sphinx_autodoc_typehints_type:

\:py\:class\:\int``

.. py:function:: main(argv=None)

module:

scenet.cli

Entry point for the scenet command.

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. 0 on success, 1 for a document that will not compile, 2 for 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