Command line¶
Reference: the sextile command, which serves or draws any application named
the way an ASGI server names one — module:name, a Sextile or a factory that
returns one.
sextile serve your_service:app
sextile render your_service:app --page 82489493
sextile serve¶
Answers calls from terminals on a TCP port.
Option |
Default |
Does |
|---|---|---|
|
|
the address to listen on |
|
|
the port to listen on |
|
|
release a caller who says nothing this long; |
|
half the idle timeout |
warn a silent caller with a draining bar; |
|
|
how many callers may be on the line at once; |
sextile render¶
Draws one frame to standard output and, to standard error, where each key would
lead — the quickest check that a menu is wired up. Exits 0 when it drew, 2
where the page, frame or number is not there.
Option |
Default |
Does |
|---|---|---|
|
the page to draw, |
|
|
|
which frame of a page that runs to several |
|
|
how to draw it |
|
suppress the ANSI colour |
|
draws |
|---|---|
|
colour, as the Beeb would draw it |
|
the character and attribute layers |
|
the wire stream, as a hex dump |
|
a self-contained web page, drawn with Bedstead |
Building your own¶
A service with its own command line builds a click.Group and adds the pieces
sextile itself uses. standard_commands(load) returns the render and serve
commands to add to it, given a load that builds the application; its options=
are added to both, for a flag such as a database path, and page_example= sets
what render --page’s help shows. form_options and listening_options add the
option tables above to a command of your own, load_application resolves a
module:name, and render_page and run_service carry out the two commands.
See sextile.cli.
import click
from sextile.cli import CONTEXT_SETTINGS, standard_commands
@click.group(context_settings=CONTEXT_SETTINGS)
def cli() -> None: ...
for command in standard_commands(lambda context: build_application(...)):
cli.add_command(command)
Why a module:name: the framework serves an application it is told about at the
command line rather than one it imports, so a service is a library the sextile
command drives, not a program that reaches back into the framework.