Add CSV output for activities list
This commit is contained in:
parent
9f30d1cc48
commit
61beba151f
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3.7
|
||||
|
||||
import sys
|
||||
import click
|
||||
import csv
|
||||
from datetime import datetime
|
||||
@ -154,13 +155,20 @@ def activities():
|
||||
|
||||
@activities.command('list')
|
||||
@click.option('--search', help='Search string')
|
||||
def list_activities(search):
|
||||
@click.option('--csv/--no-csv', 'csv_output', default=False, help='CSV output')
|
||||
def list_activities(search, csv_output):
|
||||
""" List / search activities """
|
||||
|
||||
results = get_activities(search=search)
|
||||
|
||||
if csv_output:
|
||||
csv_writer = csv.writer(sys.stdout)
|
||||
|
||||
for r in results:
|
||||
click.echo('@{0[3]}: {0[2]} » {0[0]}: {0[1]}'.format(r))
|
||||
if csv_output:
|
||||
csv_writer.writerow([r[3], r[2], r[0], r[1]])
|
||||
else:
|
||||
click.echo('@{0[3]}: {0[2]} » {0[0]}: {0[1]}'.format(r))
|
||||
|
||||
|
||||
@activities.command('delete')
|
||||
|
Loading…
Reference in New Issue
Block a user