Skip to content

Commit

Permalink
checking if any session to delete exists!
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonak-Adipta-Kalita committed Jul 29, 2024
1 parent c9eb42f commit 761eb71
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions flomo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,14 @@ def tracking():
@flomo.command(aliases=["d"])
@click.argument("session_ids", nargs=-1)
def delete(session_ids: Tuple):
# TODO: Handling scenario where there is no session left to delete.
"""
Delete sessions.
"""
click.confirm("Are you sure you want to delete the session(s)?", abort=True)
try:
db = tracker.Tracker()
if not db.get_sessions():
raise errors.NoSessionsError()
click.confirm("Are you sure you want to delete the session(s)?", abort=True)
db.delete_session(session_ids)
db.conn.close()
if len(session_ids) == 0:
Expand All @@ -115,6 +116,7 @@ def delete(session_ids: Tuple):
except (
errors.DBFileNotFoundError,
errors.NoSessionError,
errors.NoSessionsError
) as e:
helpers.error_log(str(e))
print(e)
Expand Down

0 comments on commit 761eb71

Please sign in to comment.