cli: add option to output locations to gpx files

This commit is contained in:
Sean Breckenridge 2023-04-14 15:52:36 -07:00
parent 02c738594f
commit 87c13defd1
3 changed files with 56 additions and 2 deletions

View file

@ -542,6 +542,14 @@ def query_hpi_functions(
pprint(item)
else:
pprint(list(res))
elif output == 'gpx':
from my.location.common import locations_to_gpx
# can ignore the mypy warning here, locations_to_gpx yields any errors
# if you didnt pass it something that matches the LocationProtocol
for exc in list(locations_to_gpx(res, sys.stdout)): # type: ignore[arg-type]
click.echo(str(exc), err=True)
sys.stdout.flush()
else:
res = list(res) # type: ignore[assignment]
# output == 'repl'
@ -681,7 +689,7 @@ def module_install_cmd(user: bool, parallel: bool, modules: Sequence[str]) -> No
@click.option('-o',
'--output',
default='json',
type=click.Choice(['json', 'pprint', 'repl']),
type=click.Choice(['json', 'pprint', 'repl', 'gpx']),
help='what to do with the result [default: json]')
@click.option('-s',
'--stream',