Skip to content
Open
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
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ Use this flag to specify a message to display under the timer. Make sure to surr
$ timer 1h30m -m "Review the pull requests"
```

### Logs

Every timer you start will be logged and inserted in a DB (SQLite).
Feel free to access this file with any DB management app.
File's location: `$HOME/timer_cli_personal_logs.db`

## Contributing

Contributions are always welcome!
Expand All @@ -54,6 +60,19 @@ If you have a suggestion that would make this better, please fork the repo and c
- Push to the Branch (`git push origin feature/AmazingFeature`)
- Open a Pull Request

## Development

#### How to start locally:
- Build the project with your changes - `poetry build`
- Install deps - `poetry install`
- Run the project `poetry run timer -m "%message here%" 1m`
- Repeat each time you make changes

###### more traditional way to start:
- (optional) Init your venv - `python -m venv venv`
- (optional) Activate your venv - `source venv/bin/activate`
- Run timer with the flags - `python timer/__main__.py -m 'test message for local dev' 1h38m`

## License

This code is distributed under the [Apache-2.0](https://choosealicense.com/licenses/apache-2.0/) license. See `LICENSE` for more information.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "timer-cli"
version = "0.1.2"
version = "0.1.3"
description = "A simple CLI tool for starting a countdown timer."
license = "Apache-2.0"
authors = ["Kush Makkapati <kush.makkapati@icloud.com>"]
Expand Down
27 changes: 27 additions & 0 deletions timer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import math
import re
import os
import sys
import time
import sqlite3
from typing import List, Optional, Tuple, Union

import click
Expand Down Expand Up @@ -135,6 +137,31 @@ def main(duration: Optional[str], no_bell: bool, message: str) -> None:

time_difference_secs = target_time - start_time - 1

#TODO: add time + message in timer_personal_logs.db
# OR in text file
# OR send it somewhere (Slack, obsidian, Gdrive, Notion)

home_dir = os.path.expanduser("~")
db_path = os.path.join(home_dir, "timer_cli_personal_logs.db")
conn = sqlite3.connect(db_path)
cursor = conn.cursor()

create_query = '''
CREATE TABLE IF NOT EXISTS task_logs (timestamp TEXT, duration TEXT, message TEXT);
'''
insert_query = '''
INSERT INTO task_logs (timestamp, duration, message) VALUES (datetime('now', 'localtime'), ?, ?)
'''

try:
cursor.execute(create_query)
cursor.execute(insert_query, (countdown_time_string, message))
conn.commit()
except sqlite3.Error as e:
print(f"An error occurred: {e}")
finally:
conn.close()

try:
with Live(display, screen=True) as live:
time.sleep(1)
Expand Down