Skip to content

Commit

Permalink
remove unused argparse json options, use configuration instead of arg…
Browse files Browse the repository at this point in the history
…s for json output

Signed-off-by: R4SAS <[email protected]>
  • Loading branch information
r4sas committed Jul 26, 2024
1 parent 88ea07d commit c22c0f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 5 additions & 5 deletions pbincli/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -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))
Expand All @@ -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': {
Expand Down
4 changes: 1 addition & 3 deletions pbincli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c22c0f0

Please sign in to comment.