Dokumentacja CLI

Składnia

snapper [OPTIONS] [FILE...]
snapper init [--dry-run]
snapper sdiff [--no-color] [-f FORMAT] <OLD> <NEW>
snapper git-diff [--no-color] [-f FORMAT] [REF] [FILE...]
snapper watch [-f FORMAT] <PATTERNS...>
snapper lsp
snapper mcp

Jeśli nie podano plików, snapper czyta ze stdin i pisze na stdout.

Opcje

-f, --format <FORMAT>

Input format. One of: org, latex, markdown, rst, plaintext.

Wykrywany automatycznie na podstawie rozszerzenia pliku, gdy pominięty. Domyślnie plaintext dla stdin.

--stdin-filepath <ŚCIEŻKA>

Przyjmij tę nazwę pliku podczas czytania ze stdin, na potrzeby automatycznego wykrywania formatu. Przydatne dla integracji z edytorem, które przekazują zawartość bufora potokiem.

Przykład: cat paper.org | snapper --stdin-filepath paper.org

-o, --output <PLIK>

Zapisz wynik do pliku zamiast na stdout.

-i, --in-place

Modyfikuj pliki wejściowe w miejscu. Wymaga argumentów plikowych (nie stdin).

-w, --max-width <N>

Maximum line width. Sentences exceeding this width are wrapped at atomic word boundaries (links, inline code, math, and similar tokens stay on one line). Default: 0 (unlimited). Also respects max_line_length from .editorconfig if present.

--clause-breaks

Prefer soft breaks after independent-clause punctuation (comma, semicolon, colon, em dash, ASCII --). Off by default.

With --max-width 0 (the default), insert a newline after every such mark that is already followed by whitespace. A sentence that is already one independent clause stays one line.

With --max-width set, overflowing sentences prefer those marks; a sentence that already fits stays on one line.

Tokens such as 1,000, 10:30, URLs, --flags, and unspaced dashes never split. --check uses the same mode when the flag or clause_breaks config is on.

--format-code

After in-block comment reflow, pipe each code-block body through the formatter argv from [code.<lang>] in .snapperrc.toml (if present). Default is off so subprocesses are never spawned unless requested. Missing binaries, non-zero exits, and a ~30s timeout are non-fatal; the reflowed body is kept and a diagnostic may be written to stderr.

--check

Check mode for CI. Exits with code 1 if any file would change, without modifying anything. Prints the paths of files that would be reformatted to stderr. With no file arguments, checks stdin (JSON/SARIF on stdout, same exit codes).

--diff

Wyświetla ujednolicony diff planowanych zmian, bez modyfikowania czegokolwiek. Przydatne do przeglądu przed commitem. Kończy działanie z kodem 1, jeśli jakikolwiek plik uległby zmianie.

--range <START:END>

Formatuj tylko linie w podanym zakresie (indeksowanie od 1, włącznie). Linie poza zakresem przechodzą bez zmian. Przydatne dla integracji formatowania zaznaczenia w edytorze.

Przykład: snapper --range 10:20 paper.org

--output-format <text|json|sarif>

Format wyjściowy dla trybu --check. Domyślnie: text (wypisuje nazwy plików na stderr).

  • json : outputs a JSON array of files, each with would_reformat and a diagnostics array of 1-indexed line / kind (fused / wrap / long) / excerpt

  • sarif : outputs SARIF v2.1.0 for GitHub Code Scanning, with one result per diagnostic (snapper/fused, snapper/wrap, snapper/long) plus snapper/needs-reformat when the file would change

--strict-long

Treat advisory long diagnostics as --check failures.

A long finding is never the sole cause of exit 1 unless this flag is set. The threshold is --max-width when that is non-zero, otherwise long_threshold from .snapperrc.toml (default 120).

--neural

Użyj neuronowego wykrywania zdań przez nnsplit (LSTM na poziomie bajtów, backend tract). Pobiera i zapisuje model (~4MB) do ~/.cache/nnsplit/ przy pierwszym użyciu. Wykrywanie oparte na regułach pozostaje domyślne (szybsze, lepsza obsługa skrótów). Wykrywanie neuronowe sprawdza się najlepiej w tekście nieangielskim.

--lang <KOD>

Język dla neuronowego wykrywania zdań. Domyślnie: en. Dostępne: en, de, fr, no, sv, zh, tr, ru, uk.

--model-path <ŚCIEŻKA>

Ścieżka do niestandardowego pliku modelu ONNX dla wykrywania neuronowego. Nadpisuje --lang.

--use-pandoc

Require the pandoc path (auto FFI, then CLI). Parse may use in-process FFI when libsnapper_pandoc loads; the writer still needs pandoc on PATH (libsnapper_pandoc is reader-only) unless that library exports a writer. Without FFI, both parse and write use the pandoc CLI. A missing binary is an explicit error (never silent all-prose). Enables support for typst, asciidoc, docx, html, and all other pandoc-supported formats. The default (omit this flag) already uses pandoc when an FFI writer or pandoc on PATH is available.

--native

Force today’s native line parsers (markdown / org / rst / latex / plaintext). Conflicts with --use-pandoc. Use this when you want source-oriented splice instead of the pandoc writer. Editors, wasm, and LSP stay native even without this flag.

--pandoc-backend <auto|ffi|cli>

How to obtain the pandoc AST when the pandoc path is used. auto (default) prefers in-process FFI, else CLI. ffi requires libsnapper_pandoc (explicit error if missing). cli uses a pandoc subprocess (explicit error if missing). The writer still needs pandoc on PATH when the FFI library has no writer.

--config <ŚCIEŻKA>

Ścieżka do pliku konfiguracyjnego .snapperrc.toml. Gdy pominięta, snapper szuka od bieżącego katalogu w górę.

-h, --help

Wyświetl komunikat pomocy.

-V, --version

Wyświetl wersję.

--color <WHEN>

When to color --diff / sdiff / git-diff output: auto (default), always, or never. Global. sdiff and git-diff also accept --no-color as an alias for --color never.

Podkomendy

snapper init

Zainicjalizuj snappera dla projektu. Wykrywa, które formaty prozy istnieją w drzewie katalogów i generuje:

  • .snapperrc.toml z rozsądnymi wartościami domyślnymi

  • wpisy .gitattributes dla filtra git smudge/clean

  • fragment hooka pre-commit

  • fragment konfiguracji Apheleia (Emacs)

Użyj --dry-run, aby wyświetlić podgląd bez zapisywania plików.

snapper sdiff <OLD> <NEW>

Sentence-level diff between two files. Parses both files, extracts sentences, diffs at sentence granularity. Whitespace reflow produces zero diff. Colored output by default; use --no-color to disable. Exits with code 1 if differences found.

snapper git-diff [REF] [FILE...]

Sentence-level diff against a git ref. Default ref: HEAD. If no files specified, diffs all changed recognized prose files (.org, .tex, .latex, .md, .markdown, .rst, .rest, .txt). Uses git show REF:path to retrieve the old version.

snapper watch <PATTERNS...>

Watch files and auto-reformat on save. Accepts file paths or glob patterns. 200ms debounce to avoid reformatting during rapid saves. Press Ctrl+C to stop.

snapper lsp

Start the Language Server Protocol server on stdin/stdout. Provides document formatting, range formatting, and diagnostics (flags lines with multiple sentences). Works with any LSP-compatible editor (Neovim, Emacs eglot, VS Code, Helix).

snapper mcp

Start the MCP server on stdin/stdout. Tools: format_text, detect_format, check_formatting, split_sentences. Published binaries include this server (mcp is a default Cargo feature).

Kody wyjścia

  • 0 : Success (or --check / --diff with no changes needed; advisory long diagnostics do not fail --check unless --strict-long)

  • 1 : --check or --diff found files that would change, --strict-long saw a long diagnostic, or any error