tabnas_jsonic_cli/lib.rs
1/* Copyright (c) 2020-2026 Richard Rodger, Oliver Sturm, and other
2contributors, MIT License */
3
4//! The `jsonic` command as a library: read relaxed JSON from arguments,
5//! files or standard input, parse it with
6//! [`tabnas-jsonic`](https://github.com/tabnas/jsonic), merge the results
7//! and print standard JSON.
8//!
9//! This is the Rust port of the canonical TypeScript implementation in
10//! `ts/src/jsonic-cli.ts`; the TypeScript version is authoritative and
11//! this crate tracks it. The Go port is in `go/`.
12//!
13//! The crate is a library plus a thin `src/bin/jsonic.rs` launcher, so
14//! the command can be driven in process:
15//!
16//! ```
17//! let argv: Vec<String> = ["jsonic", "a:b:1", "a:c:2"]
18//! .iter()
19//! .map(|s| s.to_string())
20//! .collect();
21//! let mut out: Vec<u8> = Vec::new();
22//! let code = tabnas_jsonic_cli::run(
23//! &argv,
24//! &mut std::io::empty(),
25//! &mut out,
26//! &mut std::io::sink(),
27//! );
28//! assert_eq!(code, 0);
29//! assert_eq!(String::from_utf8(out).unwrap(), "{\"a\":{\"b\":1,\"c\":2}}\n");
30//! ```
31
32mod args;
33pub mod cli;
34mod help;
35mod merge;
36pub mod registry;
37mod stringify;
38
39pub use cli::{capture, run, run_with_plugins, Captured};
40pub use registry::{plugins, register_plugin};
41
42/// This crate's version. It MUST equal `ts/package.json` "version" and
43/// the `version` in `Cargo.toml`: the release orchestrator rewrites all
44/// of them, and `tests/version_test.rs` fails the build if they drift.
45/// Mirrors `VERSION` in `ts/src/jsonic-cli.ts` and `const VERSION` in
46/// `go/cmd/jsonic/main.go`.
47pub const VERSION: &str = "0.5.10";
48
49#[cfg(doctest)]
50#[doc = include_str!("../README.md")]
51mod readme_examples {}