Crates.io | nu_plugin_from_dhall |
lib.rs | nu_plugin_from_dhall |
version | 0.0.1 |
source | src |
created_at | 2021-06-18 12:56:42.691562 |
updated_at | 2021-06-18 12:56:42.691562 |
description | Nushell plugin to add Dhall support |
homepage | |
repository | https://github.com/autophagy/nu_plugin_from_dhall |
max_upload_size | |
id | 411767 |
size | 58,405 |
nu_plugin_from_dhall
This is a plugin for Nushell to open Dhall files into nu
's structured
data types.
cargo install nu_plugin_from_dhall
Given a Dhall file:
> cat example.dhall
let AccountType = < Guest | User | Admin >
let Person =
{ name : Text
, age : Natural
, accountType : AccountType
, nickname : Optional Text
}
let alice
: Person
= { name = "Alice"
, age = 24
, accountType = AccountType.Admin
, nickname = Some "Cool Alice"
}
let bob
: Person
= { name = "Bob"
, age = 49
, accountType = AccountType.User
, nickname = None Text
}
let carlo
: Person
= { name = "Carlo"
, age = 20
, accountType = AccountType.Guest
, nickname = Some "Cooler Carlo"
}
in [ alice, bob, carlo ]
Use open
to parse the Dhall expression into structured data that Nushell can
pipe:
> open example.dhall
───┬─────────────┬─────┬───────┬──────────────
# │ accountType │ age │ name │ nickname
───┼─────────────┼─────┼───────┼──────────────
0 │ [row Admin] │ 24 │ Alice │ Cool Alice
1 │ [row User] │ 49 │ Bob │
2 │ [row Guest] │ 20 │ Carlo │ Cooler Carlo
───┴─────────────┴─────┴───────┴──────────────
> open example.dhall | where age > 20 | get name
───┬───────
0 │ Alice
1 │ Bob
───┴───────