Skip to content

Commit

Permalink
--quite options yields TypeError - fixed!
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtin committed Jan 14, 2020
1 parent 1e356dc commit 9b31b51
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cli4/cli4.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ def run_command(cf, method, command, params=None, content=None, files=None):
def write_results(results, output):
"""dump the results"""

if output is None:
return

if len(results) == 1:
results = results[0]

Expand All @@ -175,6 +178,8 @@ def write_results(results, output):
pass
else:
# anything more complex (dict, list, etc) should be dumped as JSON/YAML
if output is None:
results = None
if output == 'json':
try:
results = json.dumps(results,
Expand All @@ -196,9 +201,10 @@ def write_results(results, output):
writer.close()
return

sys.stdout.write(results)
if not results.endswith('\n'):
sys.stdout.write('\n')
if results:
sys.stdout.write(results)
if not results.endswith('\n'):
sys.stdout.write('\n')

def do_it(args):
"""Cloudflare API via command line"""
Expand Down

0 comments on commit 9b31b51

Please sign in to comment.