diff --git a/README.md b/README.md index 0deacb4..79599ae 100644 --- a/README.md +++ b/README.md @@ -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. @@ -26,7 +26,7 @@ optional arguments: -h, --help show this help message and exit -i num, --indent num indent number of spaces at each level (default: 4) -o file, --output file write output to instead of stdout (default: stdout) - -s str, --string str json to pretty-print + -c cmd, --command cmd json to pretty-print -v, --version show program's version number and exit ``` @@ -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 diff --git a/pprintjson/pprintjson.py b/pprintjson/pprintjson.py index 9adbe1e..45b440f 100644 --- a/pprintjson/pprintjson.py +++ b/pprintjson/pprintjson.py @@ -10,7 +10,7 @@ from pygments.formatters import TerminalFormatter from pygments.lexers import JsonLexer -__VERSION__ = "1.2.0" +__VERSION__ = "1.2.1" def pprintjson( @@ -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)