Skip to content

Command-Line Interface

The pyle binary runs a script, reads one from stdin, or prints version and help information.

Terminal window
pyle [options] [script] [args...]
Flag Description
-h, --help Print usage and exit
-v, --version Print version information and exit
-d, --dissassamble Print the disassembled bytecode before running

The misspelling --dissassamble is the actual flag name. -d is the short form.

Terminal window
pyle --version
# Pyle version 0.3.0 (abc1234)
pyle -d script.pyl
pyle script.pyl one two --flag

Use - as the script path to read the program from stdin.

Terminal window
echo 'print("hi")' | pyle -

The virtual script name becomes <stdin> in error messages.

The interpreter uses a simple, predictable rule:

  • Flags before the script path belong to pyle.
  • The first non-flag token is the script path.
  • Everything after the script path goes to the script verbatim, even -d or --version.
  • -- before the script forces positional parsing.
Terminal window
pyle -d script.pyl -v

Here -d is interpreted by pyle, and -v is passed to the script. Inside the script, os.args is ["-v"].

let os = import("os")
print(os.args)
print(os.script_path())
print(os.script_dir())
Situation Exit code
Successful run 0
--version or --help 0
No script given 1
Lex, parse, or compile error 1
Uncaught runtime panic 1
Script calls exit(n) n

exit(code?) exits immediately with the given code, defaulting to 0.

if not ok {
exit(2)
}

The interpreter refuses to run or import a .d.pyl file:

Error: 'std/os.d.pyl' is a type definition file, not a script.

Declaration files are for editors and the language server.

The interpreter adds two directories to the import path:

  • std/ next to the executable.
  • ./std/ relative to the current working directory.

That is how import("worker") finds std/worker.pyl. Add more with add_import_path.

The CLI sets PYLE_GIT_HASH to the build’s git hash. PYLE_VERSION is always available.

printf("Pyle {} ({})", PYLE_VERSION, PYLE_GIT_HASH)

PYLE_GIT_HASH is only set by the CLI, not by libpyle.

The interpreter does not require any environment variables. Worker processes are initialized from the spawn environment, so os.is_worker() and os.worker_args() work in the child.