process
The one command type: an external process to start, as an executable and its arguments.
A command is declared once so that it passes from whatever produced it to whatever runs it as itself. A repo adapter answers a verb with one, and anything that starts a process takes one.
Obtaining it
Name the coordinate process:process among the libraries your repository vendors. It arrives with type:type, the base every generated model has, and depends on nothing else.
Public API
Import from the package root, process. The surface is what the package root exports, and nothing deeper.
Command–executableandargs. Generated fromcommand.schema.yml, which is exported asprocess:command, so a schema elsewhere references the shape by coordinate and its generated model holds this class.argv(command=)– the list of strings a process is started from: the executable, then its arguments.from_argv(argv=)– the command a list of strings spells: its first item, then the rest. An empty list is refused, as an emptyexecutableis.
from process import Command, argv, from_argv
command = Command(executable="ruff", args=["check", "--fix"])
argv(command=command) # ["ruff", "check", "--fix"]
from_argv(argv=["ruff", "format"]) # Command(executable="ruff", args=["format"])
The document format
process:command is the one schema this package defines, command.schema.yml. A schema document that holds a command references it by coordinate:
externalSchemas:
process:
id: process:command
target: process
definitions:
launch:
fields:
command:
type: process.command
Responsibilities
What this package owns:
- What a command is. One declaration of the shape.
- Which item of a list is the program.
argvandfrom_argvare the only two places a command and a list of strings are turned into each other.
What it leaves to others:
- Starting the process. Where it runs, with what environment, and what happens to its output are the runner’s.
- Templates of a command. A command line with slots a run fills – a repo adapter’s declared verb, with the arguments a run passes through – is declared by whoever fills the slots, and renders to a
Command.