cli

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package cli implements a python-compatible command front-end on top of the go-python interpreter.

It is intentionally a library, not just a main package: a single-binary sandbox can embed the python command by importing this package and calling Run with its own argv and io streams, while cmd/python is only a thin wrapper (os.Exit(cli.Run(os.Args, os.Stdin, os.Stdout, os.Stderr))).

Supported today: `python -c <command>` and `python <file.py> [args...]`, both with sys.argv populated and code run in a real __main__ module. Module (-m) and interactive (REPL) modes return a usage error for now.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int

Run executes a python-style invocation and returns a process exit code, following CPython's conventions: 0 on success, 1 on an uncaught exception, 2 on a command-line / file-open error.

args is the full argv including args[0] (the program name). stdin backs the guest's sys.stdin; stdout/stderr receive program output. Run never writes to the host process streams directly — everything goes through the passed writers — so it is safe to call in-process from an embedding sandbox.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL