Skip to main content

Crate tabnas_jsonic_cli

Crate tabnas_jsonic_cli 

Source
Expand description

The jsonic command as a library: read relaxed JSON from arguments, files or standard input, parse it with tabnas-jsonic, merge the results and print standard JSON.

This is the Rust port of the canonical TypeScript implementation in ts/src/jsonic-cli.ts; the TypeScript version is authoritative and this crate tracks it. The Go port is in go/.

The crate is a library plus a thin src/bin/jsonic.rs launcher, so the command can be driven in process:

let argv: Vec<String> = ["jsonic", "a:b:1", "a:c:2"]
    .iter()
    .map(|s| s.to_string())
    .collect();
let mut out: Vec<u8> = Vec::new();
let code = tabnas_jsonic_cli::run(
    &argv,
    &mut std::io::empty(),
    &mut out,
    &mut std::io::sink(),
);
assert_eq!(code, 0);
assert_eq!(String::from_utf8(out).unwrap(), "{\"a\":{\"b\":1,\"c\":2}}\n");

Re-exports§

pub use cli::capture;
pub use cli::run;
pub use cli::run_with_plugins;
pub use cli::Captured;
pub use registry::plugins;
pub use registry::register_plugin;

Modules§

cli
The command itself: argument parsing, option, meta and plugin wiring, source merging and serialization. The port of ts/src/jsonic-cli.ts and of go/cli/run.go.
registry
The compiled-in plugin registry behind -p / --plugin. The port of go/cli/registry.go.

Constants§

VERSION
This crate’s version. It MUST equal ts/package.json “version” and the version in Cargo.toml: the release orchestrator rewrites all of them, and tests/version_test.rs fails the build if they drift. Mirrors VERSION in ts/src/jsonic-cli.ts and const VERSION in go/cmd/jsonic/main.go.