Skip to content

Commit

Permalink
v1.2.1 - update README and fix bug with -c, --command option
Browse files Browse the repository at this point in the history
  • Loading branch information
clarketm committed Jan 9, 2019
1 parent 748870c commit d338637
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $ pip install pprintjson

```text
usage: pprintjson.py [-h] [-i num] [-o file] [-s str] [-v] [file]
usage: pprintjson.py [-h] [-i num] [-o file] [-c cmd] [-v] [file]
A pretty-printing function for json.
Expand All @@ -26,7 +26,7 @@ optional arguments:
-h, --help show this help message and exit
-i num, --indent num indent <num> number of spaces at each level (default: 4)
-o file, --output file write output to <file> instead of stdout (default: stdout)
-s str, --string str json <str> to pretty-print
-c cmd, --command cmd json <str> to pretty-print
-v, --version show program's version number and exit
```
Expand All @@ -42,19 +42,19 @@ $ pprintjson "./path/to/file.json"
Pretty print JSON from a **string** using the `pprintjson` CLI.

```bash
$ pprintjson -s '{ "a": 1, "b": "string", "c": true }'
$ pprintjson -c '{ "a": 1, "b": "string", "c": true }'
```

Pretty print JSON from a **string** with an *indent* of **1**.

```bash
$ pprintjson -s '{ "a": 1, "b": "string", "c": true }' -i 1
$ pprintjson -c '{ "a": 1, "b": "string", "c": true }' -i 1
```

Pretty print JSON from a **string** and save *output* to a file **output.json**.

```bash
$ pprintjson -s '{ "a": 1, "b": "string", "c": true }' -o ./output.json
$ pprintjson -c '{ "a": 1, "b": "string", "c": true }' -o ./output.json
```

### Module
Expand Down
6 changes: 3 additions & 3 deletions pprintjson/pprintjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pygments.formatters import TerminalFormatter
from pygments.lexers import JsonLexer

__VERSION__ = "1.2.0"
__VERSION__ = "1.2.1"


def pprintjson(
Expand Down Expand Up @@ -70,8 +70,8 @@ def cli():
args = parser.parse_args()
file = open(args.output, "w") if args.output else None

if args.string is not None:
pprintjson(loads(args.string), indent=args.indent, file=file)
if args.command is not None:
pprintjson(loads(args.command), indent=args.indent, file=file)
else:
pprintjson(load(args.file), indent=args.indent, file=file)

Expand Down

0 comments on commit d338637

Please sign in to comment.