cli
Internal CLI exposed to Python.
Index
Classes
Options for the |
||
External command context |
||
An external CLI command that may be invoked by the command line argument parser. |
Functions
- main(args: Sequence[str], interactive: Callable[[syside.cli.Interactive], int] | None = None, external: Sequence[syside.cli.ExternalCommand] = ()) int
Entry point to internal Syside CLI. Returns exit code on completion.
argsmust either be<syside> args...or<python> -m <syside> args..., i.e. they must be the same as called from the command line, e.g.sys.argv.The
interactiveargument is used to provide Python implementation for theinteractivecommand.Raises anything
interactiveorexternalmay raise if executed.The
servercommand will use underlying nativestdinandstdoutstreams directly, any modifications tosys.stdoutandsys.stdinwill not be propagated.Warning
Multiple threads running
servercommand simultaneously are not supported as it overrides global exit and error hooks. If multiple servers are needed, run them in separate processes.Note
Syside depends on output streams supporting full Unicode range. If the standard stream encoding is not Unicode, e.g.
not encoding.startswith("utf"), it will be temporarilyreconfiguredto platform-specific encoding:Windows:
utf-16because by defaultPowerShellconverts all redirected output toutf-16regardless. Note that this inserts byte order mark (BOM) into the output stream. If another encoding is required or BOM is unwanted:call
sys.std*.reconfigure(encoding="utf-*")from Python provided they are instances ofio.TextIOWrapper.run python with
PYTHONIOENCODING="utf-*"environment variable:$env:PYTHONIOENCODING="utf-8" python ...
run python in
UTF-8mode:python -X utf8 ...
or:
$env:PYTHONUTF8="1" python ...
change terminal or system locale to Unicode (
chcp 65001does not seem to have any effect on Python)
Linux, macOS:
utf-8. This is typically the default in all cases.