mirror of
https://github.com/r4sas/PBinCLI
synced 2025-01-24 21:44:27 +00:00
remove unused argparse json options, use configuration instead of args for json output
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
88ea07dba2
commit
c22c0f06ae
@ -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': {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user