tabnas-jsonic-cli 0.5.14

Command-line interface for the jsonic relaxed-JSON parser: reads relaxed JSON from arguments, files or standard input and prints standard JSON.
Documentation
/* Copyright (c) 2020-2026 Richard Rodger, Oliver Sturm, and other
contributors, MIT License */

//! The `--help` / `-h` text. It mirrors the TypeScript `help()`, with a
//! Rust-specific Plugins section: loading a plugin module by reference is
//! not available here (see [`crate::registry`]), so `-p` resolves against
//! the compiled-in registry instead.

pub(crate) const HELP: &str = r#"
A JSON parser that isn't strict.

Usage: jsonic <args> [<source-text>]*

where
  <source-text> is the source text to be parsed into JSON.
    If omitted, the source text is read from STDIN. If multiple source texts
    are provided, they will be merged in precedence (from highest)
    right to left, STDIN, <file>.

  <args> are the command arguments:

    -                      Alias for STDIN.

    --file <file>          Load and parse <file>.
    -f <file>

    --option <name=value>  Set option <name> to <value>, where <name>
    -o <name=value>          can be a dotted path (see example below).

    --nice                 Print JSON indented over multiple lines.
    -n

    --meta <meta=value>    Set parse meta data <name> to <value>, where <name>
    -m <meta=value>          can be a dotted path (see option example).

    --plugin <require>     Load a plugin, where <require> is the plugin module
    -p <require>             reference (name or path).

    --debug                Print abbreviated lex and parse logs for debugging,
    -d                       alias of `--meta log = -1`.

    --help                 Print this help message.
    -h

Output:
  Output is generated by the built-in JSON.stringify method. The `replacer`
    and `space` arguments can be specified using `-o JSON.replacer=...` and
    `-o JSON.space=...` respectively.


Plugins
  Plugins are compiled into the binary (Rust cannot load modules at runtime).
  The built-in plugins can be specified using the abbreviated references:
    debug, jsonic, json
  (the @tabnas/<name> forms also resolve).

  Plugin options can be specified using: `-o plugin.<name>.<option>=<value>`.
  See the example below.

  To add more plugins, build a custom binary that registers them with the
  tabnas_jsonic_cli crate before calling run:
    tabnas_jsonic_cli::register_plugin("csv", tabnas_csv::plugin());


Examples:

# Basic usage
> jsonic a:1
{"a":1}

> jsonic -n a:1
{
  "a": 1
}


# Merging arguments
> jsonic a:b:1 a:c:2
{"a":{"b":1,"c":2}}


# Output options
> jsonic a:b:1 a:c:2 --option JSON.space=2
{
  "a": {
    "b": 1,
    "c": 2
  }
}


# Piping
> echo a:1 | jsonic
{"a":1}


# Using plugins (a custom binary with the csv plugin registered)
> jsonic -p csv  -o plugin.csv.record.separators=^ "a,b^1,2"
[{"a":"1","b":"2"}]

# Using built-in plugins
> jsonic -p json '{"a":1}'
{"a":1}


# Full debug tracing
> jsonic -d -o plugin.debug.trace=true a:1
... lots of debug info, including token-by-token trace ...
{"a":1}


See also: https://github.com/tabnas/jsonic
"#;