Skip to content

Commit

Permalink
cli: Print Location-* values
Browse files Browse the repository at this point in the history
Especially with POST responses, this can easily be the only information
a server sends.
  • Loading branch information
chrysn committed Jan 10, 2022
1 parent 5ef738f commit 1f03d4c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions aiocoap/cli/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ def apply_credentials(context, credentials, errfn):
def present(message, options, file=sys.stdout):
"""Write a message payload to the output, pretty printing and/or coloring
it as configured in the options."""
if not options.quiet and (message.opt.location_path or message.opt.location_query):
# FIXME: Percent encoding is completely missing; this would be done
# most easily with a CRI library
location_ref = "/" + "/".join(message.opt.location_path)
if message.opt.location_query:
location_ref += "?" + "&".join(message.opt.location_query)
print(colored(f"Location options indicate new resource: {location_ref}", options, 'green'), file=sys.stderr)

if not message.payload:
return

Expand Down

0 comments on commit 1f03d4c

Please sign in to comment.