2 releases

0.1.1 Oct 10, 2023
0.1.0 Oct 10, 2023

#822 in Text processing

35 downloads per month

MIT/Apache and maybe CC-PDDC

14KB
157 lines

nu_plugin_ron

This is a nushell plugin to parse RON text into nu structured types.

Installing

To add the plugin permanently, just install it and call register on it:

Using Cargo

cargo install nu_plugin_ron
register ~/.cargo/bin/nu_plugin_ron

Usage

Consider the following RON example:

Scene( // class name is optional
    materials: { // this is a map
        "metal": (
            reflectivity: 1.0,
        ),
        "plastic": (
            reflectivity: 0.5,
        ),
    },
    entities: [ // this is an array
        (
            name: "hero",
            material: "metal",
        ),
        (
            name: "monster",
            material: "plastic",
        ),
    ],
)
$ open example.ron
╭───────────┬───────────────────────────────────────╮
           │ ╭───┬──────────┬─────────╮            │
 entities  │ │ # │ material │  name   │            │
│           │ ├───┼──────────┼─────────┤            │
│           │ │ 0 │ metal    │ hero    │            │
│           │ │ 1 │ plastic  │ monster │            │
│           │ ╰───┴──────────┴─────────╯            │
│           │ ╭─────────┬─────────────────────────╮ │
│ materials │ │         │ ╭──────────────┬──────╮ │ │
│           │ │ metal   │ │ reflectivity │ 1.00 │ │ │
│           │ │         │ ╰──────────────┴──────╯ │ │
│           │ │         │ ╭──────────────┬──────╮ │ │
│           │ │ plastic │ │ reflectivity │ 0.50 │ │ │
│           │ │         │ ╰──────────────┴──────╯ │ │
│           │ ╰─────────┴─────────────────────────╯ │
╰───────────┴───────────────────────────────────────╯

$ open example.ron | update materials.metal.reflectivity 2.00 | save -f new_example.ron
$ open new_example.ron
╭───────────┬───────────────────────────────────────╮
│           │ ╭───┬──────────┬─────────╮            │
│ entities  │ │ # │ material │  name   │            │
│           │ ├───┼──────────┼─────────┤            │
│           │ │ 0 │ metal    │ hero    │            │
│           │ │ 1 │ plastic  │ monster │            │
│           │ ╰───┴──────────┴─────────╯            │
│           │ ╭─────────┬─────────────────────────╮ │
│ materials │ │         │ ╭──────────────┬──────╮ │ │
│           │ │ metal   │ │ reflectivity │ 2.00 │ │ │
│           │ │         │ ╰──────────────┴──────╯ │ │
│           │ │         │ ╭──────────────┬──────╮ │ │
│           │ │ plastic │ │ reflectivity │ 0.50 │ │ │
│           │ │         │ ╰──────────────┴──────╯ │ │
│           │ ╰─────────┴─────────────────────────╯ │
╰───────────┴───────────────────────────────────────╯

Dependencies

~14–30MB
~397K SLoC