cli

Internal CLI exposed to Python.

Index

Classes

Interactive

Options for the interactive command.

ExtContext

External command context

ExternalCommand

An external CLI command that may be invoked by the command line argument parser.

Functions

main

Entry point to internal Syside CLI. Returns exit code on completion.


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

args must 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 interactive argument is used to provide Python implementation for the interactive command.

Raises anything interactive or external may raise if executed.

The server command will use underlying native stdin and stdout streams directly, any modifications to sys.stdout and sys.stdin will not be propagated.

Warning

Multiple threads running server command 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 temporarily reconfigured to platform-specific encoding:

  • Windows: utf-16 because by default PowerShell converts all redirected output to utf-16 regardless. 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 of io.TextIOWrapper.

    • run python with PYTHONIOENCODING="utf-*" environment variable:

      $env:PYTHONIOENCODING="utf-8"
      python ...
      
    • run python in UTF-8 mode:

      python -X utf8 ...
      

      or:

      $env:PYTHONUTF8="1"
      python ...
      
    • change terminal or system locale to Unicode (chcp 65001 does not seem to have any effect on Python)

  • Linux, macOS: utf-8. This is typically the default in all cases.