Skip to content

Commit

Permalink
enable both formats
Browse files Browse the repository at this point in the history
  • Loading branch information
kouk committed Oct 27, 2016
1 parent 982e283 commit 5ddbfbd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mgship/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging

from mgship import mgship
from mgship.destination import csv
from mgship.destination import csv, json
from mgship.cliparam import DateTime, Loglevel
from mgship.util import utctimestamp, validate_past
from mgship.log import logger
Expand Down Expand Up @@ -34,11 +34,14 @@ def to_timestamp(ctx, param, value):


@main.command()
@click.option('--format', default='csv', type=click.Choice(['json', 'csv']),
help='the output format')
@click.option('--begin', default=None, type=DateTime(),
callback=to_timestamp,
help='when to start archiving, as unix timestamp')
def archive(*args, **kwargs):
mgship.Archive(csv.Destination(), *args, **kwargs).ship()
def archive(format, *args, **kwargs):
dest = csv.Destination() if format == 'csv' else json.Destination()
mgship.Archive(dest, *args, **kwargs).ship()


if __name__ == "__main__":
Expand Down

0 comments on commit 5ddbfbd

Please sign in to comment.