Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theirish81/walkcli
A utility to parse, select and transform YAML/JSON strings in a *NIX pipe.
https://github.com/theirish81/walkcli
cli json template yaml
Last synced: 19 days ago
JSON representation
A utility to parse, select and transform YAML/JSON strings in a *NIX pipe.
- Host: GitHub
- URL: https://github.com/theirish81/walkcli
- Owner: theirish81
- License: mit
- Created: 2022-09-23T07:31:42.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-03-17T16:58:52.000Z (over 1 year ago)
- Last Synced: 2024-10-11T20:06:28.786Z (about 1 month ago)
- Topics: cli, json, template, yaml
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Walk-CLI
A utility to parse, select and transform YAML/JSON strings in a *NIX pipe.Sometimes your scripts will perform API calls or `cat` files containing a big amount of YAML or JSON and all you need
is to transform it to something more readable, or easier to digest in the next step of the pipe.That's what Walk-CLI is all about.
## Basic usage
`walkcli -t "template"`* `template`: is a template written in the [GoWalker](https://github.com/theirish81/gowalker) format. It's somewhat
similar to what you would use in JavaScript template literals, as it uses the `${...}` notation to open templates,
and the dot notation to navigate data structures.* `stdin`: the program will wait for a standard input to digest. You can input the text after running the program or use
a pipe.### Examples
* `cat myfile.json | walkcli -t '${user.id}'`
* `cat products.json | walkcli -t '${item[0]'`### Pretty-print and conversion
The output of `walkcli` can be any string. If you, however, are in need to output JSON or YAML, there's a couple of
switches which may improve your experience.* `-j`: parses the output string as a JSON and beautifies it
* `-c`: adds colors to the output JSON
* `-y`: parses the output string as a YAMLObviously if you use one of the parsers, the process will only succeed if the output string is syntactically correct.
## External templates
Sometimes the desired output needs to be something more complex than a string or two. In this case inlining the template
won't do it. To solve this problem, you can reference external template files.in the `--template` argument, provide, instead, a path to file preceded by `file://` as in `file://my_templates/main.templ`.
Requirements:
* Template files must have an extension. We recommend `.templ`
* The template format is the one described in [GoWalker](https://github.com/theirish81/gowalker)**IMPORTANT:** the engine will load the provided file and use it as *main* template, but will also load all the other
files in the same directory as *sub-templates*. We therefore recommend that you use one directory for task.