Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamline command line arguments and documentation. #10

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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