diff --git a/pbincli/actions.py b/pbincli/actions.py index fdeae46..f1b3aaa 100644 --- a/pbincli/actions.py +++ b/pbincli/actions.py @@ -21,14 +21,14 @@ def send(args, api_client, settings=None): if args.text: text = args.text elif args.stdin: - if not args.json: print("Reading text from stdin…") + if not settings['json']: print("Reading text from stdin…") text = args.stdin.read() elif not args.file: PBinCLIError("Nothing to send!") else: text = "" - if not args.json: print("Preparing paste…") + if not settings['json']: print("Preparing paste…") paste = Paste(args.debug) if args.verbose: print("Used server: {}".format(api_client.getServer())) @@ -68,10 +68,10 @@ def send(args, api_client, settings=None): # If we use dry option, exit now if args.dry: - if not args.json: print("Dry mode: paste will not be uploaded. Exiting…") + if not settings['json']: print("Dry mode: paste will not be uploaded. Exiting…") sys.exit(0) - if not args.json: print("Uploading paste…") + if not settings['json']: print("Uploading paste…") result = api_client.post(request) if args.debug: print("Response:\t{}\n".format(result)) @@ -80,7 +80,7 @@ def send(args, api_client, settings=None): if not result['status']: # return code is zero passphrase = paste.getHash() - if args.json: # JSON output + if settings['json']: # JSON output response = { 'status': result['status'], 'result': { diff --git a/pbincli/cli.py b/pbincli/cli.py index 77ef4c9..2d8e198 100755 --- a/pbincli/cli.py +++ b/pbincli/cli.py @@ -91,7 +91,7 @@ def main(): send_parser.add_argument("-L", "--mirrors", default=argparse.SUPPRESS, help="Comma-separated list of mirrors of service with scheme (default: None)") send_parser.add_argument("-v", "--verbose", default=False, action="store_true", help="Enable verbose output") send_parser.add_argument("-d", "--debug", default=False, action="store_true", help="Enable debug output. Includes verbose output") - send_parser.add_argument("--json", default=False, action="store_true", help="Print result in JSON format") + send_parser.add_argument("--json", default=argparse.SUPPRESS, action="store_true", help="Print result in JSON format") send_parser.add_argument("--dry", default=False, action="store_true", help="Invoke dry run") send_parser.add_argument("stdin", help="Input paste text from stdin", nargs="?", type=argparse.FileType("r"), default=sys.stdin) send_parser.set_defaults(func=pbincli.actions.send) @@ -116,7 +116,6 @@ def main(): ## get_parser.add_argument("-v", "--verbose", default=False, action="store_true", help="Enable verbose output") get_parser.add_argument("-d", "--debug", default=False, action="store_true", help="Enable debug output. Includes verbose output") - get_parser.add_argument("--json", default=False, action="store_true", help="Print result in JSON format") get_parser.set_defaults(func=pbincli.actions.get) # a delete command @@ -136,7 +135,6 @@ def main(): ## delete_parser.add_argument("-v", "--verbose", default=False, action="store_true", help="Enable verbose output") delete_parser.add_argument("-d", "--debug", default=False, action="store_true", help="Enable debug output. Includes verbose output") - delete_parser.add_argument("--json", default=False, action="store_true", help="Print result in JSON format") delete_parser.set_defaults(func=pbincli.actions.delete) # Add argcomplete trigger