-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from kellyjonbrazil/dev
Dev v1.4.0
- Loading branch information
Showing
14 changed files
with
881 additions
and
867 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ cat data.json | jello '_["foo"]' | |
- `-n` print selected `null` values | ||
- `-r` raw output of selected strings (no quotes) | ||
- `-s` print the JSON schema in grep-able format | ||
- `-t` print type annotations in schema view | ||
- `-h` help | ||
- `-v` version info | ||
|
||
|
@@ -89,15 +90,15 @@ echo '{"foo":"bar","baz":[1,2,3]}' | jello -l _.baz | |
3 | ||
``` | ||
|
||
You can also create [JSON Lines](https://jsonlines.org/) with the `-l` option: | ||
The `-l` option also allows you to create [JSON Lines](https://jsonlines.org/): | ||
```bash | ||
echo '[{"foo":"bar","baz":[1,2,3]},{"foo":"bar","baz":[1,2,3]}]' | jello -l | ||
echo '[{"foo":"bar","baz":[1,2,3]},{"fiz":"boo","buz":[4,5,6]}]' | jello -l | ||
|
||
{"foo":"bar","baz":[1,2,3]} | ||
{"foo":"bar","baz":[1,2,3]} | ||
{"fiz":"boo","buz":[4,5,6]} | ||
``` | ||
|
||
You can also print a grep-able schema by using the `-s` option: | ||
You can print a grep-able schema by using the `-s` option: | ||
```bash | ||
echo '{"foo":"bar","baz":[1,2,3]}' | jello -s | ||
|
||
|
@@ -109,7 +110,7 @@ echo '{"foo":"bar","baz":[1,2,3]}' | jello -s | |
|
||
#### Assigning Results to a Bash Array | ||
|
||
Use the `-l` option to print JSON array output in a manner suitable to be assigned to a bash array. The `-r` option can be used to remove quotation marks around strings. If you want `null` values to be printed as `null`, use the `-n` option, otherwise they are blank lines. | ||
Use the `-l` option to print JSON array output in a manner suitable to be assigned to a bash array. The `-r` option can be used to remove quotation marks around strings. If you want `null` values to be printed as `null`, use the `-n` option, otherwise they are printed as blank lines. | ||
|
||
Bash variable: | ||
``` | ||
|
@@ -124,30 +125,75 @@ while read -r value; do | |
done < <(cat data.json | jello -rl _.foo) | ||
``` | ||
|
||
Here is more [advanced usage](https://github.com/kellyjonbrazil/jello/blob/master/ADVANCED_USAGE.md) information. | ||
### Setting Custom Colors via Environment Variable | ||
Custom colors can be set via the `JELLO_COLORS` environment variable. Any colors set in the environment variable will take precedence over any colors set in the initialization file. (see [Advanced Usage](https://github.com/kellyjonbrazil/jello/blob/master/ADVANCED_USAGE.md)) | ||
|
||
The `JELLO_COLORS` environment variable takes four comma separated string values in the following format: | ||
``` | ||
JELLO_COLORS=<keyname_color>,<keyword_color>,<number_color>,<string_color> | ||
``` | ||
Where colors are: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `gray`, `brightblack`, `brightred`, `brightgreen`, `brightyellow`, `brightblue`, `brightmagenta`, `brightcyan`, `white`, or `default` | ||
|
||
For example, to set to the default colors: | ||
``` | ||
JELLO_COLORS=blue,brightblack,magenta,green | ||
``` | ||
or | ||
``` | ||
JELLO_COLORS=default,default,default,default | ||
``` | ||
|
||
Here is more [Advanced Usage](https://github.com/kellyjonbrazil/jello/blob/master/ADVANCED_USAGE.md) information. | ||
|
||
## Examples: | ||
### Printing the Grep-able Schema | ||
```bash | ||
jc -a | jello -s | ||
|
||
.name = "jc"; | ||
.version = "1.10.2"; | ||
.description = "jc cli output JSON conversion tool"; | ||
.version = "1.15.5"; | ||
.description = "JSON CLI output utility"; | ||
.author = "Kelly Brazil"; | ||
.author_email = "[email protected]"; | ||
.parser_count = 50; | ||
.parsers[0].name = "airport"; | ||
.parsers[0].argument = "--airport"; | ||
.parsers[0].version = "1.0"; | ||
.parsers[0].description = "airport -I command parser"; | ||
.website = "https://github.com/kellyjonbrazil/jc"; | ||
.copyright = "© 2019-2021 Kelly Brazil"; | ||
.license = "MIT License"; | ||
.parser_count = 73; | ||
.parsers[0].name = "acpi"; | ||
.parsers[0].argument = "--acpi"; | ||
.parsers[0].version = "1.2"; | ||
.parsers[0].description = "`acpi` command parser"; | ||
.parsers[0].author = "Kelly Brazil"; | ||
.parsers[0].author_email = "[email protected]"; | ||
.parsers[0].compatible[0] = "darwin"; | ||
.parsers[0].magic_commands[0] = "airport -I"; | ||
.parsers[1].name = "airport_s"; | ||
.parsers[1].argument = "--airport-s"; | ||
.parsers[1].version = "1.0"; | ||
.parsers[0].compatible[0] = "linux"; | ||
.parsers[0].magic_commands[0] = "acpi"; | ||
.parsers[1].name = "airport"; | ||
.parsers[1].argument = "--airport"; | ||
.parsers[1].version = "1.3"; | ||
... | ||
``` | ||
### Printing the Grep-able Schema with type annotations (useful for grepping types) | ||
```bash | ||
jc -a | jello -st | ||
.name = "jc"; // (string) | ||
.version = "1.15.5"; // (string) | ||
.description = "JSON CLI output utility"; // (string) | ||
.author = "Kelly Brazil"; // (string) | ||
.author_email = "[email protected]"; // (string) | ||
.website = "https://github.com/kellyjonbrazil/jc"; // (string) | ||
.copyright = "© 2019-2021 Kelly Brazil"; // (string) | ||
.license = "MIT License"; // (string) | ||
.parser_count = 73; // (number) | ||
.parsers[0].name = "acpi"; // (string) | ||
.parsers[0].argument = "--acpi"; // (string) | ||
.parsers[0].version = "1.2"; // (string) | ||
.parsers[0].description = "`acpi` command parser"; // (string) | ||
.parsers[0].author = "Kelly Brazil"; // (string) | ||
.parsers[0].author_email = "[email protected]"; // (string) | ||
.parsers[0].compatible[0] = "linux"; // (string) | ||
.parsers[0].magic_commands[0] = "acpi"; // (string) | ||
.parsers[1].name = "airport"; // (string) | ||
.parsers[1].argument = "--airport"; // (string) | ||
.parsers[1].version = "1.3"; // (string) | ||
... | ||
``` | ||
### Lambda Functions and Math | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"""jello - query JSON at the command line with python syntax""" | ||
|
||
|
||
__version__ = '1.4.0' | ||
AUTHOR = 'Kelly Brazil' | ||
WEBSITE = 'https://github.com/kellyjonbrazil/jello' | ||
COPYRIGHT = '© 2020-2021 Kelly Brazil' | ||
LICENSE = 'MIT License' |
Oops, something went wrong.