Skip to content

Commit 7824f15

Browse files
Merge pull request #19 from kellyjonbrazil/dev
Dev v1.4.0
2 parents 11f5282 + daec2cf commit 7824f15

14 files changed

+881
-867
lines changed

Diff for: ADVANCED_USAGE.md

+16-30
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,25 @@ The file must be named `.jelloconf.py` and must be located in the proper directo
99
- Windows: `%appdata%/`
1010

1111
##### Setting Options
12-
To set `jello` options in the `.jelloconf.py` file, add any of the following and set to `True` or `False`:
12+
To set `jello` options in the `.jelloconf.py` file, import the `jello.lib.opts` class, add any of the following and set to `True` or `False`:
1313
```
14-
mono = True # -m option
15-
compact = True # -c option
16-
lines = True # -l option
17-
raw = True # -r option
18-
nulls = True # -n option
19-
schema = True # -s option
14+
from jello.lib import opts
15+
opts.mono = True # -m option
16+
opts.compact = True # -c option
17+
opts.lines = True # -l option
18+
opts.raw = True # -r option
19+
opts.nulls = True # -n option
20+
opts.schema = True # -s option
21+
opts.types = True # -t option
2022
```
2123
##### Setting Colors
22-
You can customize the colors by setting the following variables to one of the following string values: `'black'`, `'red'`, `'green'`, `'yellow'`, `'blue'`, `'magenta'`, `'cyan'`, `'gray'`, `'brightblack'`, `'brightred'`, `'brightgreen'`, `'brightyellow'`, `'brightblue'`, `'brightmagenta'`, `'brightcyan'`, or `'white'`.
24+
You can customize the colors by importing the `jello.lib.opts` class and setting the following variables to one of the following string values: `'black'`, `'red'`, `'green'`, `'yellow'`, `'blue'`, `'magenta'`, `'cyan'`, `'gray'`, `'brightblack'`, `'brightred'`, `'brightgreen'`, `'brightyellow'`, `'brightblue'`, `'brightmagenta'`, `'brightcyan'`, or `'white'`.
2325
```
24-
keyname_color = 'blue' # Key names
25-
keyword_color = 'brightblack' # true, false, null
26-
number_color = 'magenta' # integers, floats
27-
string_color = 'green' # strings
28-
arrayid_color = 'red' # array IDs in Schema view
29-
arraybracket_color = 'magenta' # array brackets in Schema view
26+
from jello.lib import opts
27+
opts.keyname_color = 'blue' # Key names
28+
opts.keyword_color = 'brightblack' # true, false, null
29+
opts.number_color = 'magenta' # integers, floats
30+
opts.string_color = 'green' # strings
3031
```
3132
> Note: Any colors set via the `JELLO_COLORS` environment variable will take precedence over any color values set in the `.jelloconf.py` configuration file
3233
@@ -61,20 +62,5 @@ jc -a | jello -i 'g("parsers.6.compatible")'
6162
"freebsd"
6263
]
6364
```
64-
## Setting Custom Colors via Environment Variable
65-
In addition to setting custom colors in the `.jelloconf.py` intialization file, you can also set them via the `JELLO_COLORS` environment variable. Any colors set in the environment variable will take precedence over any colors set in the initialization file.
6665

67-
The `JELLO_COLORS` environment variable takes six comma separated string values in the following format:
68-
```
69-
JELLO_COLORS=<keyname_color>,<keyword_color>,<number_color>,<string_color>,<arrayid_color>,<arraybracket_color>
70-
```
71-
Where colors are: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `gray`, `brightblack`, `brightred`, `brightgreen`, `brightyellow`, `brightblue`, `brightmagenta`, `brightcyan`, `white`, or `default`
72-
73-
For example, to set to the default colors:
74-
```
75-
JELLO_COLORS=blue,brightblack,magenta,green,red,magenta
76-
```
77-
or
78-
```
79-
JELLO_COLORS=default,default,default,default,default,default
80-
```
66+
> Tip: Add a line to print a message to STDERR in your `.jelloconf.py` file to show when the initialization file is being used: `print('Running initialization file', file=sys.stderr)`

Diff for: CHANGELOG

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
jello changelog
22

3+
20210614 v1.4.0
4+
- Add type annotation option for Schema view
5+
- Enhance error handling when a dict method is accessed (e.g. .get)
6+
- Enhance exception error messages
7+
- Pygments library dependency is now optional
8+
- Code refactor to split cli from lib
9+
310
20210609 v1.3.6
411
- Documentation fixes for packages and binaries hosting
512

Diff for: README.md

+65-19
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ cat data.json | jello '_["foo"]'
5555
- `-n` print selected `null` values
5656
- `-r` raw output of selected strings (no quotes)
5757
- `-s` print the JSON schema in grep-able format
58+
- `-t` print type annotations in schema view
5859
- `-h` help
5960
- `-v` version info
6061

@@ -89,15 +90,15 @@ echo '{"foo":"bar","baz":[1,2,3]}' | jello -l _.baz
8990
3
9091
```
9192

92-
You can also create [JSON Lines](https://jsonlines.org/) with the `-l` option:
93+
The `-l` option also allows you to create [JSON Lines](https://jsonlines.org/):
9394
```bash
94-
echo '[{"foo":"bar","baz":[1,2,3]},{"foo":"bar","baz":[1,2,3]}]' | jello -l
95+
echo '[{"foo":"bar","baz":[1,2,3]},{"fiz":"boo","buz":[4,5,6]}]' | jello -l
9596

9697
{"foo":"bar","baz":[1,2,3]}
97-
{"foo":"bar","baz":[1,2,3]}
98+
{"fiz":"boo","buz":[4,5,6]}
9899
```
99100

100-
You can also print a grep-able schema by using the `-s` option:
101+
You can print a grep-able schema by using the `-s` option:
101102
```bash
102103
echo '{"foo":"bar","baz":[1,2,3]}' | jello -s
103104

@@ -109,7 +110,7 @@ echo '{"foo":"bar","baz":[1,2,3]}' | jello -s
109110

110111
#### Assigning Results to a Bash Array
111112

112-
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.
113+
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.
113114

114115
Bash variable:
115116
```
@@ -124,30 +125,75 @@ while read -r value; do
124125
done < <(cat data.json | jello -rl _.foo)
125126
```
126127

127-
Here is more [advanced usage](https://github.com/kellyjonbrazil/jello/blob/master/ADVANCED_USAGE.md) information.
128+
### Setting Custom Colors via Environment Variable
129+
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))
130+
131+
The `JELLO_COLORS` environment variable takes four comma separated string values in the following format:
132+
```
133+
JELLO_COLORS=<keyname_color>,<keyword_color>,<number_color>,<string_color>
134+
```
135+
Where colors are: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `gray`, `brightblack`, `brightred`, `brightgreen`, `brightyellow`, `brightblue`, `brightmagenta`, `brightcyan`, `white`, or `default`
136+
137+
For example, to set to the default colors:
138+
```
139+
JELLO_COLORS=blue,brightblack,magenta,green
140+
```
141+
or
142+
```
143+
JELLO_COLORS=default,default,default,default
144+
```
145+
146+
Here is more [Advanced Usage](https://github.com/kellyjonbrazil/jello/blob/master/ADVANCED_USAGE.md) information.
128147

129148
## Examples:
130149
### Printing the Grep-able Schema
131150
```bash
132151
jc -a | jello -s
133-
134152
.name = "jc";
135-
.version = "1.10.2";
136-
.description = "jc cli output JSON conversion tool";
153+
.version = "1.15.5";
154+
.description = "JSON CLI output utility";
137155
.author = "Kelly Brazil";
138156
.author_email = "[email protected]";
139-
.parser_count = 50;
140-
.parsers[0].name = "airport";
141-
.parsers[0].argument = "--airport";
142-
.parsers[0].version = "1.0";
143-
.parsers[0].description = "airport -I command parser";
157+
.website = "https://github.com/kellyjonbrazil/jc";
158+
.copyright = "© 2019-2021 Kelly Brazil";
159+
.license = "MIT License";
160+
.parser_count = 73;
161+
.parsers[0].name = "acpi";
162+
.parsers[0].argument = "--acpi";
163+
.parsers[0].version = "1.2";
164+
.parsers[0].description = "`acpi` command parser";
144165
.parsers[0].author = "Kelly Brazil";
145166
.parsers[0].author_email = "[email protected]";
146-
.parsers[0].compatible[0] = "darwin";
147-
.parsers[0].magic_commands[0] = "airport -I";
148-
.parsers[1].name = "airport_s";
149-
.parsers[1].argument = "--airport-s";
150-
.parsers[1].version = "1.0";
167+
.parsers[0].compatible[0] = "linux";
168+
.parsers[0].magic_commands[0] = "acpi";
169+
.parsers[1].name = "airport";
170+
.parsers[1].argument = "--airport";
171+
.parsers[1].version = "1.3";
172+
...
173+
```
174+
### Printing the Grep-able Schema with type annotations (useful for grepping types)
175+
```bash
176+
jc -a | jello -st
177+
.name = "jc"; // (string)
178+
.version = "1.15.5"; // (string)
179+
.description = "JSON CLI output utility"; // (string)
180+
.author = "Kelly Brazil"; // (string)
181+
.author_email = "[email protected]"; // (string)
182+
.website = "https://github.com/kellyjonbrazil/jc"; // (string)
183+
.copyright = "© 2019-2021 Kelly Brazil"; // (string)
184+
.license = "MIT License"; // (string)
185+
.parser_count = 73; // (number)
186+
.parsers[0].name = "acpi"; // (string)
187+
.parsers[0].argument = "--acpi"; // (string)
188+
.parsers[0].version = "1.2"; // (string)
189+
.parsers[0].description = "`acpi` command parser"; // (string)
190+
.parsers[0].author = "Kelly Brazil"; // (string)
191+
.parsers[0].author_email = "[email protected]"; // (string)
192+
.parsers[0].compatible[0] = "linux"; // (string)
193+
.parsers[0].magic_commands[0] = "acpi"; // (string)
194+
.parsers[1].name = "airport"; // (string)
195+
.parsers[1].argument = "--airport"; // (string)
196+
.parsers[1].version = "1.3"; // (string)
151197
...
152198
```
153199
### Lambda Functions and Math

Diff for: jello/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""jello - query JSON at the command line with python syntax"""
2+
3+
4+
__version__ = '1.4.0'
5+
AUTHOR = 'Kelly Brazil'
6+
WEBSITE = 'https://github.com/kellyjonbrazil/jello'
7+
COPYRIGHT = '© 2020-2021 Kelly Brazil'
8+
LICENSE = 'MIT License'

0 commit comments

Comments
 (0)