Use `-` for stdin

This commit is contained in:
Tushar Sadhwani 2021-08-30 15:57:41 +05:30
parent d27bad0e28
commit 0a1b220639
1 changed files with 1 additions and 2 deletions

View File

@ -54,7 +54,6 @@ if __name__ == "__main__":
"path", "path",
metavar="PATH", metavar="PATH",
help="path to file, or - for stdin", help="path to file, or - for stdin",
nargs="?",
) )
parser.add_argument( parser.add_argument(
"-i", "-i",
@ -72,7 +71,7 @@ if __name__ == "__main__":
error_console = Console(stderr=True) error_console = Console(stderr=True)
try: try:
if args.path is None: if args.path == "-":
json_data = sys.stdin.read() json_data = sys.stdin.read()
else: else:
with open(args.path, "rt") as json_file: with open(args.path, "rt") as json_file: