ptyhelp

command module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 8 Imported by: 0

README

ptyhelp

Run a command inside a pseudo-terminal with a fixed width so tools that wrap help text to the terminal size (for example go-flags; see issue #423) produce stable, embeddable output for READMEs and docs.

Typical use: capture go run . --help, or any cmd args, optionally writing stdout to a file and/or replacing a fenced block in a Markdown file between HTML comment markers.

Install

go install github.com/apstndb/ptyhelp@v0.1.0

Usage

ptyhelp [flags] [-- command args...]

If you omit command args, the default is go run . --help. If you set -binary BIN, the default is BIN --help.

Flags:

Flag Meaning
-cols, -rows PTY size (default 256×40)
-o path Write raw output to a file
-target-file path Replace the <!-- NAME begin --><!-- NAME end --> region in that file with a fenced text code block (see -marker)
-marker NAME Marker name (default cli-output)

Example:

cd /path/to/your/module
ptyhelp -o /tmp/help.txt -target-file README.md -marker my-cli -- go run . --help

License

MIT — see LICENSE.

Documentation

Overview

Command ptyhelp runs an arbitrary command inside a PTY with a fixed width so line-oriented CLIs (e.g. go-flags --help) wrap predictably; see https://github.com/jessevdk/go-flags/issues/423. It uses github.com/aymanbagabas/go-pty (ConPTY on Windows, POSIX pty elsewhere).

Default command is "go run . --help" in the current working directory; pass "ptyhelp [flags] -- cmd args..." to override. Run ptyhelp from the module root (or cd there first).

Jump to

Keyboard shortcuts

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