Skip to content

feat: add TOON output format alongside json/yaml - #282

Merged
maximelb merged 2 commits into
cli-v2from
cli-v2-toon-output
Apr 24, 2026
Merged

maximelb merged 2 commits into
cli-v2from
cli-v2-toon-output

Conversation

@maximelb

Copy link
Copy Markdown
Contributor

Summary

  • Adds --output toon to the CLI, rendering results in Token-Oriented Object Notation (a compact, LLM-friendly format that saves ~30-60% tokens vs JSON). See https://toonformat.dev.
  • Implementation uses the toon_format package, maintained under the official toon-format GitHub org (MIT, listed as the official Python implementation on the TOON site). Pinned as toon_format>=0.9.0b1,<1.0 since upstream is currently in beta (v0.9.0b1).
  • Dispatches through format_output like the other formats, and is treated as a buffered format (same memory semantics as yaml/csv) in search run.

Notes on package choice

There are several third-party TOON ports on PyPI (toon-py, toon-python, py-toon-format, etc.), but the one chosen here is the only implementation listed under the official toon-format GitHub org, referenced from toonformat.dev's implementation list. It is MIT-licensed and pure-Python with no transitive deps. It's still labeled beta (0.9.x); the version pin allows upstream patch/beta bumps while preventing a 1.0 API break from sneaking in.

Example

$ limacharlie sensor list --output toon
[2]{sid,plat,hostname}:
  s1,windows,host-1
  s2,linux,host-2

Test plan

  • pytest tests/unit - all 3110 unit tests pass (4 new TOON tests added in test_output.py)
  • limacharlie --help shows [json|yaml|toon|csv|table|jsonl] as the --output choices
  • Smoke-tested dict, list-of-dicts (tabular form), and nested data roundtrips via format_output(..., fmt="toon")

🤖 Generated with Claude Code

maximelb and others added 2 commits April 23, 2026 17:06
Wires up Token-Oriented Object Notation (TOON) as a new --output
choice so CLI output can be piped into LLM prompts with ~30-60%
fewer tokens than equivalent JSON.

Uses the toon_format package from the official toon-format org
(MIT, community-driven, currently beta).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Unit tests for nested structures, unicode, empty list, ImportError
  guard, and that list-of-dicts hit the compact tabular form.
- Integration tests confirming --filter / --fields / --sort-by still
  work with fmt=toon.
- Search output test parallel to the yaml/csv/jsonl ones.
- Refresh remaining "CSV and YAML" help strings in search.py.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@maximelb
maximelb requested a review from dzimine-lc April 24, 2026 00:50
@maximelb
maximelb marked this pull request as ready for review April 24, 2026 00:50
@maximelb
maximelb merged commit 22af661 into cli-v2 Apr 24, 2026
7 checks passed
@maximelb
maximelb deleted the cli-v2-toon-output branch April 24, 2026 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant