From 536188f027481ca649b9d50871784ff56597ebb0 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 19 Jul 2016 05:33:42 +0300 Subject: online_duration.py: interface update --- bin/online_duration.py | 24 +++++++++++++----------- docs/online_duration.md | 7 +++---- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/bin/online_duration.py b/bin/online_duration.py index abf8b29..476f20c 100644 --- a/bin/online_duration.py +++ b/bin/online_duration.py @@ -340,19 +340,19 @@ def _parse_grouping(s): try: return Grouping(s) except ValueError: - raise argparse.ArgumentTypeError('invalid grouping: ' + str(s)) + raise argparse.ArgumentTypeError('invalid grouping: ' + s) def _parse_database_format(s): try: return DatabaseFormat(s) except ValueError: - raise argparse.ArgumentTypeError('invalid database format: ' + str(s)) + raise argparse.ArgumentTypeError('invalid database format: ' + s) def _parse_output_format(s): try: return OutputFormat(s) except ValueError: - raise argparse.ArgumentTypeError('invalid output format: ' + str(s)) + raise argparse.ArgumentTypeError('invalid output format: ' + s) _DATE_RANGE_LIMIT_FORMAT = '%Y-%m-%dT%H:%M:%SZ' @@ -376,23 +376,25 @@ def _parse_args(args=sys.argv): type=argparse.FileType('w', encoding='utf-8'), default=sys.stdout, help='output path (standard output by default)') - parser.add_argument('--grouping', - type=_parse_grouping, default=Grouping.USER, + parser.add_argument('-g', '--grouping', + type=_parse_grouping, choices=Grouping, - help='set grouping') - parser.add_argument('--input-format', dest='db_fmt', + default=Grouping.USER, + help='group database records by date, weekday, etc.') + parser.add_argument('-i', '--input-format', dest='db_fmt', type=_parse_database_format, default=DatabaseFormat.CSV, choices=DatabaseFormat, help='specify database format') - parser.add_argument('--output-format', dest='fmt', - type=_parse_output_format, default=OutputFormat.CSV, + parser.add_argument('-o', '--output-format', dest='fmt', + type=_parse_output_format, choices=OutputFormat, + default=OutputFormat.CSV, help='specify output format') - parser.add_argument('--from', dest='date_from', + parser.add_argument('-a', '--from', dest='date_from', type=_parse_date_range_limit, default=None, help='set the date to process database records from') - parser.add_argument('--to', dest='date_to', + parser.add_argument('-b', '--to', dest='date_to', type=_parse_date_range_limit, default=None, help='set the date to process database record to') diff --git a/docs/online_duration.md b/docs/online_duration.md index 7ca7c86..85c1e76 100644 --- a/docs/online_duration.md +++ b/docs/online_duration.md @@ -10,10 +10,9 @@ Run from the top-level directory using `python -m`: ``` > python -m bin.online_duration -h -usage: online_duration.py [-h] [--grouping {user,date,weekday,hour}] - [--input-format {csv,log,null}] - [--output-format {csv,json,plot}] [--from DATE_FROM] - [--to DATE_TO] +usage: online_duration.py [-h] [-g {user,date,weekday,hour}] + [-i {csv,log,null}] [-o {csv,json,plot}] + [-a DATE_FROM] [-b DATE_TO] input [output] ``` -- cgit v1.2.3