Skip to content

Commit

Permalink
Streamline command line arguments and documentation. (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
icemac authored Dec 11, 2023
1 parent dd09978 commit 99ccc58
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Change log
0.3 (unreleased)
================

- Nothing changed yet.
- Streamline command line arguments and documentation.


0.2 (2023-12-11)
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Installation with pipx

.. code-block:: sh
pipx install .
pipx install gtimelog2tick
Usage
=====
Expand Down
19 changes: 10 additions & 9 deletions gtimelog2tick.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,7 @@ def __call__(self, value):

def show_results(
entries: Iterable[TickSyncStatus],
stdout,
verbose=0):
stdout):
totals = {
'hours': collections.defaultdict(int),
'entries': collections.defaultdict(int),
Expand All @@ -451,10 +450,12 @@ def show_results(


def _main(argv=None, stdout=sys.stdout):
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config', default='~/.gtimelog/gtimelogrc')
parser.add_argument('-v', '--verbose', action='count', default=0,
help='be more verbose (can be repeated)')
parser = argparse.ArgumentParser(
epilog='--since and --until also understand the arguments today as'
' well as yesterday')
parser.add_argument(
'-c', '--config', default='~/.gtimelog/gtimelogrc',
help='path of the config file, defaults to ~/.gtimelog/gtimelogrc')
parser.add_argument(
'--dry-run',
action='store_true',
Expand All @@ -466,8 +467,8 @@ def _main(argv=None, stdout=sys.stdout):
" minus 7 days")
parser.add_argument(
'--until', type=Date(),
help="sync logs up until specified yyyy-mm-dd date, it does _not_"
" include the specified day.")
help="sync logs until specified yyyy-mm-dd date, it does _not_"
" include the specified day, there is no default.")
args = parser.parse_args(argv)

if args.since and args.until and args.since >= args.until:
Expand All @@ -487,7 +488,7 @@ def _main(argv=None, stdout=sys.stdout):
entries = filter_timelog(entries, since=args.since, until=args.until)
entries = sync_with_tick(config, entries, dry_run=args.dry_run)
entries = log_tick_sync(entries, config['ticklog'])
show_results(entries, stdout, verbose=args.verbose)
show_results(entries, stdout)


def main(argv=None, stdout=sys.stdout):
Expand Down

0 comments on commit 99ccc58

Please sign in to comment.