elm-decode-runner
v0.3.0
Published
CLI tool to run an Elm decoder on stdin JSON
Downloads
6
Readme
elm-decode-runner
CLI tool to run an Elm decoder on JSON input from stdin.
Installation
Using npm
npm install -g elm-decode-runnerUsing Nix
You can run elm-decode-runner directly from GitHub without installing:
echo '{"name":"Alice","age":30}' | nix run github:pete-murphy/node-elm-decode-runner -- Example.User.decoderUsage
Direct Decoder Usage
echo '{"name":"Alice","age":30}' | elm-decode-runner Example.User.decoderDiscover Available Decoders
elm-decode-runner --discoverInteractive Decoder Selection (with fzf)
echo '{"name":"Alice","age":30}' | elm-decode-runner --discoverThis will:
- Parse and validate your JSON input
- Discover all available decoders in your project
- Launch
fzfto let you interactively select a decoder - Run the selected decoder on your JSON input
This tool makes it easy to test Elm decoders from the command line by:
- Taking JSON input from stdin
- Running it through the specified Elm decoder
- Printing the result to stdout
Requirements
- Must be run in an Elm project directory (with valid
elm.json) - The specified decoder must be found in the module path
- For interactive mode:
fzfmust be installed (optional)
Arguments
elm-decode-runner <Module.Path.decoderName>- Run a specific decoderelm-decode-runner --discover- List all available decodersecho '{}' | elm-decode-runner --discover- Interactive decoder selection
Where:
Module.Pathis the Elm module path (e.g.,Example.User)decoderNameis the name of the decoder function (e.g.,decoder)
Examples
Success case
❯ curl -s https://jsonplaceholder.typicode.com/todos/1 | elm-decode-runner Example.Todo.decoder
{ completed = False, id = 1, title = "delectus aut autem", userId = 1 }Discovery example
❯ elm-decode-runner --discover
Example.Todo.decoder
Example.User.userDecoder
Example.User.adminDecoder
Utils.Config.settingsDecoderInteractive example
❯ echo '{"id":1,"name":"Alice"}' | elm-decode-runner --discover
# Opens fzf with list of decoders, after selection:
{ id = 1, name = "Alice" }Failure case
❯ echo '{"name":"Alice","age":30}' | elm-decode-runner Example.User.decoder
Problem with the given value:
{
"name": "Alice",
"age": 30
}
Expecting an OBJECT with a field named `email`License
ISC
