Add support for machine readable output
dgzlopes opened this issue · 7 comments
Add a flag, where you can specify the desired format.
e.g --output json
or --output xml
I can solve that.
Nice @Moras-del! If you need help, feel free to ping me.
I would like to be sure. Do You want to support xml/json format only when program is used as module? E.g def measure_latency( host, port = 443, timeout = 5, runs = 1, wait = 1, human_output = False, format='json' ) -> list:
as I understand the content returned from the CLI should also be returned from the function call (when human_output=False, format='json/xml/None') in specified format, like:
'host': 'www.google.com', 'protocol': 'tcp', 'seq': '1', 'port': '443', 'timeout': '5', 'time': '200ms'
Am I correct?
Yep. So we can use tools like jq to work with the data.
Human-output should be the default, but I think having other options (e.g JSON, XML, CSV, whatever) might be useful.
Ok but measure_latency()
should also return list of json objects instead of latency points if specified? Or format should be used ONLY for working with CLI?
In my opinion: CLI only 😛
I don't want to mess with how people invoke measure_latency()
. And I don't think it's useful to get a list of JSON objects!
okay :)