Metadata-Version: 2.5
Name: localtools-cli-output-to-json
Version: 1.0.0
Summary: Turn command output (df, ps, dig, ip, netstat, Cisco/Juniper/Arista show commands, ...) into JSON, offline (localtools, jc + TextFSM/ntc-templates)
Project-URL: Source, https://github.com/chayprabs/localtools
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.12
Requires-Dist: jc==1.26.0
Requires-Dist: multipart==2.0.1
Requires-Dist: ntc-templates==9.3.0
Requires-Dist: pygments==2.21.0
Requires-Dist: ruamel-yaml==0.19.1
Requires-Dist: textfsm==2.1.0
Requires-Dist: xmltodict==1.0.4
Description-Content-Type: text/markdown

# CLI Output to JSON

Paste or upload command output and extract structured data with **jc 1.26.0** and **TextFSM 2.1.0 / ntc-templates 9.3.0**. Includes searchable parsers, command/header suggestions, bundled parser documentation and JSON, compact JSON, JSON Lines or CSV downloads. Runs offline; never executes the supplied command or connects to devices.

Install (no administrator):

```powershell
irm https://raw.githubusercontent.com/chayprabs/localtools/main/cli-output-to-json/install.ps1 | iex
```

```sh
curl -fsSL https://raw.githubusercontent.com/chayprabs/localtools/main/cli-output-to-json/install.sh | bash
# Or Python 3.12+ on any OS:
pipx install localtools-cli-output-to-json
```

Portable ZIPs: [Windows, macOS and Linux releases](https://github.com/chayprabs/localtools/releases/tag/cli-output-to-json-v1.0.0).

Run `localtools-cli-output-to-json` for the UI at <http://127.0.0.1:47119>. Paste text or choose one UTF-8 file, search/select a parser and Convert. Network template IDs start with `ntc/`. Suggestions use the command index (including platform) or familiar headers, and require your selection; they are not validation or probability scores. Parser documentation is available in the UI.

```sh
localtools-cli-output-to-json parsers cisco_ios
localtools-cli-output-to-json parsers --docs df
localtools-cli-output-to-json suggest output.txt --command 'show ip interface brief' --platform cisco_ios
localtools-cli-output-to-json parse output.txt --parser df --format json -o output.json
localtools-cli-output-to-json parse router.txt --parser ntc/cisco_ios_show_ip_interface_brief --format csv
df -h | localtools-cli-output-to-json parse --parser df
```

CLI reads a file or stdin (`-`); `--strip-prompt` explicitly removes a recognized first-line shell/device prompt. No prompt or ANSI removal occurs by default. CLI output files are written atomically; notes go to stderr. JSON preserves integer digits and Unicode; the UI displays output text without converting integer values to JavaScript numbers. JSONL emits one array member per line (a non-array is one record). CSV unions record keys and encodes nested values as JSON; absent/null fields become empty cells. CSV is data, so spreadsheet users should import fields as text to avoid formula evaluation.

API: `GET /api/parsers`, `GET /api/docs?parser=df`, `POST /api/suggest`, `POST /api/parse` (JSON envelope with `output` as a string, notes and record count), or `POST /api/convert` (download response). POST accepts JSON fields or multipart fields; upload under `file` **or** paste under `input`. Fields: `parser`, `format` (default `json`), `command`, `platform`, `strip_prompt` (`true` or `false`). Example:

```sh
curl http://127.0.0.1:47119/api/convert -F parser=df -F file=@output.txt -o output.json
```

Limits: 4 MiB UTF-8 input, 100,000 lines, 65,536 characters per line, 16 MiB rendered output, 15-second parser deadline and two simultaneous parser jobs. JSON request envelope up to 24 MiB accommodates escaped 4 MiB text. Preview shows at most 131,072 characters; Copy/Download retain the entire result. Input violations return 413, parser/format failures 422, malformed requests 400 and overload 503. Independent supervisor processes stop regex-bound parsers on timeout, client disconnect or server exit; each worker has a 768 MiB address-space/Windows-job memory budget. Parent-owned temporary folders are removed after jobs; only exact tool folders older than one hour, containing no links, are swept on next startup after a hard kill.

Engine choice: [jc](https://github.com/kellyjonbrazil/jc) has mature OS-command parsers; [NTC templates](https://ntc-templates.readthedocs.io/en/latest/user/lib_getting_started/) adds indexed platform/command-specific network parsing. Pure Python wheels include the templates and work in all four portable CPython ZIPs. Parser/template output matches these pinned engines, including their limitations. Naive date/time conversions use the machine's timezone, as jc does.

Cuts and cautions: extraction is not a lossless transcription or command validator. Parsers can ignore lines, lose duplicate keys or infer types according to their upstream rules; warnings are surfaced, and zero extraction is explicitly flagged. Device firmware/output variants may need a different template. Only the 969 **indexed** NTC parser entries are exposed (multi-template index entries use TextFSM's key merge); custom templates, unindexed templates, remote execution, binary inputs/DER certificates and automatic parser selection are unsupported. jc text parsers can accept PEM/XML/plist, but this UI accepts UTF-8 text only. Suggestions cover registered command names and a small set of familiar headers; unknown/ambiguous inputs require manual selection. ANSI, pager prompts and unrelated surrounding output should be removed before parsing. Non-finite numbers cannot be exported as JSON.

Update/uninstall: `localtools-cli-output-to-json update` / `localtools-cli-output-to-json uninstall`; pipx installs use `pipx upgrade` / `pipx uninstall localtools-cli-output-to-json`.

MIT license. See `THIRD_PARTY_NOTICES.md` and included dependency/runtime licenses.
