Lua API Overview
ptool exposes a broad set of helpers through ptool and p.
Modules are grouped by domain. Within each group, entries are listed in alphabetical order.
Runtime & Interaction
- ANSI API: Build styled terminal output with ANSI escape sequences.
- Args API: Command-line argument schema parsing for Lua scripts.
- Core Lua API: Script lifecycle, process execution, config, and terminal helpers.
- Log API: Write timestamped terminal logs with level-based output.
- Shell API: Split shell-like command lines into argument arrays.
- TUI API: Build simple terminal user interfaces with a structured view tree and event loop.
Data & Text
- DateTime API: Parse, compare, format, and convert concrete datetimes with timezone support.
- Hash API: Compute SHA-256, SHA-1, and MD5 digests.
- JSON API: Parse JSON text and stringify Lua values as JSON.
- Regex API: Compile regexes and search, capture, replace, or split text.
- SemVer API: Parse, compare, and bump semantic versions.
- String API: Trim, split, join, replace, and format strings.
- Table API: Map, filter, and concatenate dense list tables.
- Template API: Render text templates from Lua data.
- TOML API: Parse, stringify, read, update, and remove TOML values.
- YAML API: Parse YAML text, read nested values, and stringify Lua values as YAML.
Filesystem & Platform
- Filesystem API: Read, write, create, and glob filesystem paths.
- OS API: Read runtime environment variables and inspect host process details.
- Path API: Manipulate paths lexically without touching the filesystem.
- Platform API: Detect the current OS, architecture, and target triple.
Networking & Remote
- HTTP API: Send HTTP requests and consume response bodies.
- Network API: Parse URLs, IP addresses, and host-port pairs.
- SSH API: Connect to remote hosts, run commands, send HTTP requests from the remote host, and transfer files.
Development & Storage
- Database API: Open database connections and run SQL queries.
- Git API: Open repositories, inspect status, and clone, fetch, or push through libgit2-backed handles.
Use this page as the entrypoint, then jump to the module page you need for the full function reference.