Tags: sayanarijit/jf
Tags
v0.5.0 Added CLI options. This adds: -r, --raw output the raw rendered value without formatting -p, --pretty pretty print the output -y, --yaml output as YAML instead of JSON -h, --help print this help message -v, --version print the version number -- stop parsing options And removes: - `%v` - `%R` - `%Y` - `%J` Also the Rust library exposes more functions, each for different formatting options.
v0.4.2 Added support for control placeholders. - `%R` enable raw mode - render but do not format output - `%Y` enable pretty YAML mode - format output into pretty YAML - `%J` enable pretty JSON mode - format output into pretty JSON Example: ```bash jf "%R%*q" a b c "a","b","c" jf "%Y[%*q]" a b c - a - b - c jf "%J[%*q]" a b c [ "a", "b", "c" ] ```
v0.4.1
To allow merging arrays and objects via expansion, trailing comma after `s` and
`q` will be auto removed after the expansion if no value is passed for the
placeholder.
Example:
```bash
jf "[%(a)*s, %(b)*s]" b=2 b=1
[2,1]
jf "{%(a)**s, %(b)**s}" b=2 b=1
{"2":1}
```
v0.4.0
- Use `%-s`, `%-q`, `%*-s`, `%*-q`, `%**-s`, `%**-q` syntax to read from stdin.
- Use `%(NAME@FILE)q` syntax to read default value from file.
- Use `%(NAME@-)q` syntax to read default value from stdin.
- Use `NAME@FILE` syntax to pass value for named placeholder from file.
- Use `NAME@-` syntax to pass value for named placeholder from stdin.
- Stdin values are separated by null (`\0`).
Examples:
```bash
seq 1 3 | xargs printf '%s\0' | jf '[%*-s]'
seq 1 3 | xargs printf '%s\0' | jf '{%q: %-s, %q: %(two)s, three: %(three@-)s}' one two two@-
```
Also, display better error for invalid expandable placeholder syntax.
v0.3.2
- Use `${NAME?}q`/`$(NAME?)s` syntax to define nullable placeholder.
- As opposed to optional placeholders that defaults to blank, nullable
placeholders will default to `null`.
- Useful for defining nullable string or array items.
Example:
```
jf "[str or bool, %(str)?q %(bool)?s, nullable, %(nullable?)q]" str=true
```
PreviousNext