Skip to content

Commit da1bd91

Browse files
author
gassc
committed
dump command
1 parent a4ea5b6 commit da1bd91

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

cli.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
from core import application_db as db
1313
from core.admin import user_datastore
1414
from core.models import Role
15+
from core.api.db_interface import get_all_fishfries
16+
from datetime import datetime
17+
from pathlib import Path
18+
import json
1519

1620

1721
# ---------------------------------------------------------
@@ -123,10 +127,19 @@ def bootstrap_db():
123127
click.echo("Created user {0}".format(new_user.email))
124128
return
125129

130+
@click.command()
131+
@click.option('--path')
132+
def dump_geojson(path):
133+
fries = get_all_fishfries()
134+
out_file = Path(path) / "fishfry_{0}.geojson".format(datetime.now().strftime('%Y%d%mT%H%M%S'))
135+
with open(str(out_file), 'w') as fp:
136+
json.dump(fries, fp)
137+
click.echo("dumped fishfries to {0}".format(str(out_file)))
126138

127139
manage_db.add_command(new_user)
128140
manage_db.add_command(new_role)
129141
manage_db.add_command(bootstrap_db)
142+
manage_db.add_command(dump_geojson)
130143

131144
if __name__ == '__main__':
132145
manage_db()

0 commit comments

Comments
 (0)