Skip to content

Commit

Permalink
continue without args continues last entry
Browse files Browse the repository at this point in the history
  • Loading branch information
staff0rd committed Oct 16, 2015
1 parent 9d8a6e9 commit afb515c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions toggl.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,14 @@ def find_by_description(self, description):
return entry
return None

def get_latest(self):
"""
Returns the latest entry
"""
if len(self.time_entries) == 0:
return None
return self.time_entries[len(self.time_entries)-1]

def next(self):
"""
Returns the next time entry object.
Expand Down Expand Up @@ -999,9 +1007,11 @@ def _continue_entry(self, args):
to restart. If a description appears multiple times in your history,
then we restart the newest one.
"""
entry = None
if len(args) == 0:
CLI().print_help()
entry = TimeEntryList().find_by_description(args[0])
entry = TimeEntryList().get_latest()
else:
entry = TimeEntryList().find_by_description(args[0])
if entry:
entry.continue_entry()
Logger.info("%s continued at %s" % (entry.get('description'),
Expand Down

0 comments on commit afb515c

Please sign in to comment.