Skip to content

Latest commit

 

History

History
58 lines (44 loc) · 2.23 KB

cli.md

File metadata and controls

58 lines (44 loc) · 2.23 KB
summary Headless CLI for trimming text without launching the UI
read_when
Using Trimmy in scripts or CI
Trimming text via stdin or files without the menu bar app

Trimmy CLI

TrimmyCLI is a headless trimmer that uses the same heuristics as the app. It reads from a file or stdin and writes the trimmed text to stdout (or JSON).

Usage

swift run TrimmyCLI --trim /path/to/file
pbpaste | swift run TrimmyCLI --trim -

Or install the packaged helper from the app: Settings → Advanced → “Install CLI”, which symlinks the bundled helper to /usr/local/bin/trimmy and /opt/homebrew/bin/trimmy. The app stays responsive while macOS requests administrator authorization. Paths containing shell characters are handled literally. Then you can run trimmy --help.

Options

  • --trim <file>: input file (use - or omit to read stdin)
  • --force, -f: force High aggressiveness
  • --aggressiveness {low|normal|high}
  • --preserve-blank-lines / --no-preserve-blank-lines
  • --remove-box-drawing / --keep-box-drawing
  • --json: emit {original, trimmed, transformed}
  • --version, -v: print Trimmy CLI version
  • --help, -h: show help

- also selects stdin on its own. Qualify a filename that matches an option, such as ./-f, to treat it as a file. Unknown arguments and invalid sensitivity levels produce an error before input is read.

Exit codes

  • 0: the cleaner changed the text
  • 1: invalid arguments / no input / read error
  • 2: the cleaner did not change the text
  • 3: JSON encoding error

Text mode adds a final newline only when the trimmed text does not already end with one. That newline alone does not count as a change. JSON uses the same exit codes.

Read failures identify the input file or stdin and report the underlying error. Input must be valid UTF-8; invalid bytes are a read error, while an empty stdin stream reports that no input was provided.

Examples

Trim a file:

swift run TrimmyCLI --trim scripts/setup.sh --aggressiveness normal

Trim stdin, force High aggressiveness, emit JSON:

pbpaste | swift run TrimmyCLI --trim - --force --json

Keep blank lines but strip box-drawing:

swift run TrimmyCLI --trim notes.txt --preserve-blank-lines --remove-box-drawing