shudo 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
shudo-0.1.0/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Himanshu Sinha
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
shudo-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.2
2
+ Name: shudo
3
+ Version: 0.1.0
4
+ Summary: ShuDo — a CLI programming productivity tool (notes, kanban tasks, pomodoro)
5
+ License: MIT
6
+ Keywords: productivity,notes,tasks,kanban,pomodoro,cli
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE.md
10
+
11
+ # ShuDo
12
+
13
+ A terminal-based programming productivity tool: **notes**, **kanban tasks**, and **pomodoro timer**.
14
+
15
+ Built with Python's `curses` and SQLite.
16
+
17
+ ## Requirements
18
+
19
+ - Python 3.8+
20
+ - A terminal that supports curses (Linux, macOS, WSL on Windows)
shudo-0.1.0/README.md ADDED
@@ -0,0 +1,10 @@
1
+ # ShuDo
2
+
3
+ A terminal-based programming productivity tool: **notes**, **kanban tasks**, and **pomodoro timer**.
4
+
5
+ Built with Python's `curses` and SQLite.
6
+
7
+ ## Requirements
8
+
9
+ - Python 3.8+
10
+ - A terminal that supports curses (Linux, macOS, WSL on Windows)
@@ -0,0 +1,19 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64.0,<77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "shudo"
7
+ version = "0.1.0"
8
+ description = "ShuDo — a CLI programming productivity tool (notes, kanban tasks, pomodoro)"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ keywords = ["productivity", "notes", "tasks", "kanban", "pomodoro", "cli"]
12
+ license = {text = "MIT"}
13
+
14
+ [project.scripts]
15
+ shudo = "shudo.shudo:cli"
16
+
17
+ [tool.setuptools.packages.find]
18
+ include = ["shudo*"]
19
+
shudo-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """ShuDo — a CLI programming productivity tool."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,6 @@
1
+ """Entry point for `python -m shudo`."""
2
+ import curses
3
+ from shudo.shudo import main
4
+
5
+ if __name__ == "__main__":
6
+ curses.wrapper(main)
@@ -0,0 +1,270 @@
1
+ # db.py
2
+ import sqlite3
3
+ import os
4
+ import json
5
+
6
+ def _get_default_db_path():
7
+ """Return the default database path in the user's config directory."""
8
+ home = os.path.expanduser("~")
9
+ data_dir = os.path.join(home, ".shudo")
10
+ os.makedirs(data_dir, exist_ok=True)
11
+ return os.path.join(data_dir, "shudo.db")
12
+
13
+
14
+ class Database:
15
+ def __init__(self, db_path=None):
16
+ if db_path is None:
17
+ db_path = _get_default_db_path()
18
+ self.conn = sqlite3.connect(db_path)
19
+ self.conn.row_factory = sqlite3.Row
20
+ self.c = self.conn.cursor()
21
+
22
+ def init_db(self):
23
+ """Create tables if they don't exist"""
24
+ self.c.executescript("""
25
+ CREATE TABLE IF NOT EXISTS notes (
26
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
27
+ title TEXT NOT NULL,
28
+ content TEXT NOT NULL,
29
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
30
+ updated_at TEXT NOT NULL DEFAULT (datetime('now'))
31
+ );
32
+
33
+ CREATE TABLE IF NOT EXISTS tasks (
34
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
35
+ task TEXT NOT NULL,
36
+ priority TEXT NOT NULL DEFAULT 'medium'
37
+ CHECK(priority IN ('high', 'medium', 'low')),
38
+ status TEXT NOT NULL DEFAULT 'ready'
39
+ CHECK(status IN ('ready', 'ongoing', 'done')),
40
+ due_date TEXT,
41
+ subtasks TEXT NOT NULL DEFAULT '[]',
42
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
43
+ updated_at TEXT NOT NULL DEFAULT (datetime('now')),
44
+ archived INTEGER NOT NULL DEFAULT 0
45
+ );
46
+
47
+ CREATE TABLE IF NOT EXISTS pomodoros (
48
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
49
+ task_id INTEGER,
50
+ work_minutes INTEGER NOT NULL DEFAULT 25,
51
+ rest_minutes INTEGER NOT NULL DEFAULT 5,
52
+ completed_at TEXT NOT NULL DEFAULT (datetime('now')),
53
+ FOREIGN KEY (task_id) REFERENCES tasks(id)
54
+ );
55
+
56
+ CREATE TABLE IF NOT EXISTS config (
57
+ key TEXT PRIMARY KEY,
58
+ value TEXT NOT NULL
59
+ );
60
+ """)
61
+ self.conn.commit()
62
+
63
+ # Migration: add columns if missing (for existing databases)
64
+ try:
65
+ self.c.execute("ALTER TABLE tasks ADD COLUMN updated_at TEXT NOT NULL DEFAULT (datetime('now'))")
66
+ except sqlite3.OperationalError:
67
+ pass # column already exists
68
+ try:
69
+ self.c.execute("ALTER TABLE tasks ADD COLUMN archived INTEGER NOT NULL DEFAULT 0")
70
+ except sqlite3.OperationalError:
71
+ pass # column already exists
72
+ self.conn.commit()
73
+
74
+ def add_note(self, title, content):
75
+ self.c.execute("INSERT INTO notes (title, content, updated_at) VALUES (?, ?, datetime('now'))",
76
+ (title, content))
77
+ self.conn.commit()
78
+ return self.c.lastrowid
79
+
80
+ def update_note(self, note_id, title, content):
81
+ self.c.execute(
82
+ "UPDATE notes SET title = ?, content = ?, updated_at = datetime('now') WHERE id = ?",
83
+ (title, content, note_id))
84
+ self.conn.commit()
85
+
86
+ def get_notes(self):
87
+ self.c.execute("SELECT id, title, content, created_at, updated_at FROM notes ORDER BY updated_at DESC")
88
+ return self.c.fetchall()
89
+
90
+ def search_notes_by_keyword(self, keyword):
91
+ pattern = f"%{keyword}%"
92
+ self.c.execute("SELECT id, title, content, created_at, updated_at FROM notes WHERE title LIKE ? OR content LIKE ? ORDER BY updated_at DESC",
93
+ (pattern, pattern))
94
+ return self.c.fetchall()
95
+
96
+ def delete_note(self, note_id):
97
+ self.c.execute("DELETE FROM notes WHERE id = ?", (note_id,))
98
+ self.conn.commit()
99
+
100
+ def add_task(self, task, priority="medium", due_date=None):
101
+ self.c.execute("INSERT INTO tasks (task, priority, status, due_date, updated_at) VALUES (?, ?, ?, ?, datetime('now'))",
102
+ (task, priority, "ready", due_date))
103
+ self.conn.commit()
104
+ return self.c.lastrowid
105
+
106
+ def get_tasks(self, include_archived=False):
107
+ if include_archived:
108
+ self.c.execute("""
109
+ SELECT id, task, priority, status, due_date, subtasks, created_at, updated_at, archived
110
+ FROM tasks
111
+ ORDER BY
112
+ CASE status
113
+ WHEN 'ready' THEN 1
114
+ WHEN 'ongoing' THEN 2
115
+ WHEN 'done' THEN 3
116
+ END,
117
+ CASE priority
118
+ WHEN 'high' THEN 1
119
+ WHEN 'medium' THEN 2
120
+ WHEN 'low' THEN 3
121
+ END,
122
+ due_date ASC NULLS LAST,
123
+ created_at DESC
124
+ """)
125
+ else:
126
+ self.c.execute("""
127
+ SELECT id, task, priority, status, due_date, subtasks, created_at, updated_at, archived
128
+ FROM tasks
129
+ WHERE archived = 0
130
+ ORDER BY
131
+ CASE status
132
+ WHEN 'ready' THEN 1
133
+ WHEN 'ongoing' THEN 2
134
+ WHEN 'done' THEN 3
135
+ END,
136
+ CASE priority
137
+ WHEN 'high' THEN 1
138
+ WHEN 'medium' THEN 2
139
+ WHEN 'low' THEN 3
140
+ END,
141
+ due_date ASC NULLS LAST,
142
+ created_at DESC
143
+ """)
144
+ return self.c.fetchall()
145
+
146
+ def search_tasks_by_keyword(self, keyword):
147
+ pattern = f"%{keyword}%"
148
+ self.c.execute("""
149
+ SELECT id, task, priority, status, due_date, subtasks, created_at, updated_at, archived
150
+ FROM tasks
151
+ WHERE archived = 0
152
+ AND (task LIKE ? OR subtasks LIKE ?)
153
+ ORDER BY
154
+ CASE status
155
+ WHEN 'ready' THEN 1
156
+ WHEN 'ongoing' THEN 2
157
+ WHEN 'done' THEN 3
158
+ END,
159
+ CASE priority
160
+ WHEN 'high' THEN 1
161
+ WHEN 'medium' THEN 2
162
+ WHEN 'low' THEN 3
163
+ END,
164
+ due_date ASC NULLS LAST,
165
+ created_at DESC
166
+ """, (pattern, pattern))
167
+ return self.c.fetchall()
168
+
169
+ def get_archived_tasks(self):
170
+ self.c.execute("""
171
+ SELECT id, task, priority, status, due_date, subtasks, created_at, updated_at, archived
172
+ FROM tasks
173
+ WHERE archived = 1
174
+ ORDER BY updated_at DESC
175
+ """)
176
+ return self.c.fetchall()
177
+
178
+ def get_task_by_id(self, task_id):
179
+ self.c.execute("SELECT id, task, priority, status, due_date, subtasks, updated_at FROM tasks WHERE id = ?", (task_id,))
180
+ return self.c.fetchone()
181
+
182
+ def update_task_status(self, task_id, new_status):
183
+ self.c.execute("UPDATE tasks SET status = ?, updated_at = datetime('now') WHERE id = ?", (new_status, task_id))
184
+ self.conn.commit()
185
+
186
+ def update_task(self, task_id, task_name, subtasks):
187
+ self.c.execute(
188
+ "UPDATE tasks SET task = ?, subtasks = ?, updated_at = datetime('now') WHERE id = ?",
189
+ (task_name, json.dumps(subtasks), task_id)
190
+ )
191
+ self.conn.commit()
192
+
193
+ def archive_task(self, task_id):
194
+ self.c.execute("UPDATE tasks SET archived = 1, updated_at = datetime('now') WHERE id = ?", (task_id,))
195
+ self.conn.commit()
196
+
197
+ def unarchive_task(self, task_id):
198
+ self.c.execute("UPDATE tasks SET archived = 0, updated_at = datetime('now') WHERE id = ?", (task_id,))
199
+ self.conn.commit()
200
+
201
+ def archive_old_done_tasks(self):
202
+ """Archive tasks that are done and last modified more than 1 day ago."""
203
+ self.c.execute("""
204
+ UPDATE tasks SET archived = 1, updated_at = datetime('now')
205
+ WHERE status = 'done'
206
+ AND archived = 0
207
+ AND updated_at < datetime('now', '-1 day')
208
+ """)
209
+ self.conn.commit()
210
+ return self.c.rowcount
211
+
212
+ def delete_task(self, task_id):
213
+ self.c.execute("DELETE FROM tasks WHERE id = ?", (task_id,))
214
+ self.conn.commit()
215
+
216
+ def add_pomo_session(self, task_id, work_minutes=25, rest_minutes=5):
217
+ self.c.execute(
218
+ "INSERT INTO pomodoros (task_id, work_minutes, rest_minutes) VALUES (?, ?, ?)",
219
+ (task_id, work_minutes, rest_minutes))
220
+ self.conn.commit()
221
+ return self.c.lastrowid
222
+
223
+ def get_pomo_stats(self, task_id=None):
224
+ if task_id is None:
225
+ self.c.execute("""
226
+ SELECT COUNT(*) as total_sessions,
227
+ COALESCE(SUM(work_minutes), 0) as total_minutes
228
+ FROM pomodoros
229
+ """)
230
+ else:
231
+ self.c.execute("""
232
+ SELECT COUNT(*) as total_sessions,
233
+ COALESCE(SUM(work_minutes), 0) as total_minutes
234
+ FROM pomodoros WHERE task_id = ?
235
+ """, (task_id,))
236
+ return self.c.fetchone()
237
+
238
+ def get_pomo_sessions_all(self):
239
+ self.c.execute("""
240
+ SELECT p.id, p.work_minutes, p.completed_at, t.task
241
+ FROM pomodoros p
242
+ LEFT JOIN tasks t ON p.task_id = t.id
243
+ ORDER BY p.completed_at DESC
244
+ """)
245
+ return self.c.fetchall()
246
+
247
+ def get_pomo_daily_avg(self):
248
+ """Average work minutes per day (only days with sessions)."""
249
+ self.c.execute("""
250
+ SELECT ROUND(AVG(day_total), 1) as daily_avg_minutes
251
+ FROM (
252
+ SELECT DATE(completed_at) as day, SUM(work_minutes) as day_total
253
+ FROM pomodoros
254
+ GROUP BY day
255
+ )
256
+ """)
257
+ row = self.c.fetchone()
258
+ return row["daily_avg_minutes"] if row and row["daily_avg_minutes"] else 0
259
+
260
+ def get_config(self, key, default=""):
261
+ self.c.execute("SELECT value FROM config WHERE key = ?", (key,))
262
+ row = self.c.fetchone()
263
+ return row["value"] if row else default
264
+
265
+ def set_config(self, key, value):
266
+ self.c.execute(
267
+ "INSERT OR REPLACE INTO config (key, value) VALUES (?, ?)",
268
+ (key, str(value))
269
+ )
270
+ self.conn.commit()
@@ -0,0 +1,180 @@
1
+ #!/usr/bin/env python3
2
+ """ShuDo - a cli programming productivity tool"""
3
+
4
+ import curses
5
+ import time
6
+
7
+ from shudo.db import Database
8
+ from shudo.views.notes_view import NotesView
9
+ from shudo.views.tasks_view import TasksView
10
+ from shudo.views.pomo_view import PomoView
11
+
12
+ class ShuDoApp:
13
+ """Main application controller."""
14
+
15
+ VIEW_NAMES = ["Notes", "Tasks", "Pomo"]
16
+
17
+ def __init__(self, stdscr):
18
+ self.stdscr = stdscr
19
+ self.db = Database()
20
+ self.db.init_db() # ensure tables exist before views query them
21
+ archived_count = self.db.archive_old_done_tasks()
22
+ if archived_count:
23
+ self.toast_message = f"Archived {archived_count} old done task(s)"
24
+ self.toast_time = time.time()
25
+ self.current_view = 0
26
+ self.running = True
27
+ self.command_str = "[tab] switch views [q] quit"
28
+ self.toast_message = ""
29
+ self.toast_time = 0.0
30
+ self.toast_duration = 2
31
+
32
+ self.views = [
33
+ NotesView(self),
34
+ TasksView(self),
35
+ PomoView(self),
36
+ ]
37
+
38
+ curses.start_color()
39
+ curses.use_default_colors()
40
+
41
+ curses.init_pair(1, curses.COLOR_RED, -1)
42
+ curses.init_pair(2, curses.COLOR_GREEN, -1)
43
+ curses.init_pair(3, curses.COLOR_YELLOW, -1)
44
+ curses.init_pair(4, curses.COLOR_BLUE, -1)
45
+ curses.init_pair(5, curses.COLOR_MAGENTA, -1)
46
+ curses.init_pair(6, curses.COLOR_CYAN, -1)
47
+ curses.init_pair(7, curses.COLOR_WHITE, -1)
48
+
49
+
50
+ curses.curs_set(0)
51
+ self.stdscr.keypad(True)
52
+ self.stdscr.nodelay(True)
53
+
54
+
55
+ @property
56
+ def width(self):
57
+ return self.stdscr.getmaxyx()[1]
58
+
59
+ @property
60
+ def height(self):
61
+ return self.stdscr.getmaxyx()[0]
62
+
63
+ def draw_header(self):
64
+ h = self.stdscr
65
+ x = 1
66
+ for ch in "ShuDo | ":
67
+ h.addch(0, x, ch, curses.color_pair(2) | curses.A_BOLD)
68
+ x += 1
69
+ for i, name in enumerate(self.VIEW_NAMES):
70
+ if i == self.current_view:
71
+ tab = f" {name} "
72
+ view_colors = [3, 4, 1] # Notes=yellow, Tasks=blue, Pomo=red
73
+ attr = curses.color_pair(view_colors[i]) | curses.A_BOLD
74
+ else:
75
+ tab = f" {name} "
76
+ attr = curses.A_DIM
77
+ for ch in tab:
78
+ if x < self.width:
79
+ h.addch(0, x, ch, attr)
80
+ x += 1
81
+ h.hline(0, x, ' ', self.width - x)
82
+
83
+ def draw_command_string(self):
84
+ """Draw the last-line commands bar."""
85
+ y = self.height - 2
86
+ msg = self.command_str
87
+ self.stdscr.hline(y, 0, ' ', self.width)
88
+ if msg:
89
+ self.stdscr.addstr(y, 1, msg, curses.color_pair(2) | curses.A_DIM)
90
+
91
+ def draw_toast_message(self):
92
+ """Draw a toast message or pomodoro mini status."""
93
+ y = self.height - 1
94
+ self.stdscr.hline(y, 0, ' ', self.width)
95
+
96
+ # check if a toast message is still active
97
+ if time.time() - self.toast_time <= self.toast_duration and self.toast_message:
98
+ self.stdscr.addstr(y, 1, self.toast_message, curses.color_pair(2))
99
+ return
100
+
101
+ self.toast_message = ""
102
+
103
+ # show pomodoro mini status if running in background
104
+ pomo = self.views[2]
105
+ mini = pomo.mini_status()
106
+ if mini:
107
+ self.stdscr.addstr(y, 1, mini, curses.color_pair(2))
108
+
109
+ def set_toast_message(self, message):
110
+ self.toast_message = message
111
+ self.toast_time = time.time()
112
+
113
+ def run(self):
114
+ while self.running:
115
+ # tick background timers
116
+ self.views[2].tick()
117
+
118
+ self.stdscr.erase()
119
+ self.draw_header()
120
+
121
+ self.views[self.current_view].render(
122
+ self.stdscr, 2, self.height - 3
123
+ )
124
+
125
+ self.draw_command_string()
126
+ self.draw_toast_message()
127
+ self.stdscr.refresh()
128
+
129
+ key = self.stdscr.getch()
130
+
131
+ if key == -1:
132
+ time.sleep(0.05)
133
+ continue
134
+ elif key == ord('q'):
135
+ self.running = False
136
+ elif key == ord('\t'):
137
+ self.current_view = (self.current_view + 1) % len(self.VIEW_NAMES)
138
+ elif key == 27: #escape
139
+ self.running = False
140
+ else:
141
+ self.views[self.current_view].handle_key(key)
142
+
143
+ def prompt(self, label, default=""):
144
+ curses.curs_set(1)
145
+ self.stdscr.nodelay(False)
146
+
147
+ y = self.height - 1
148
+ self.stdscr.hline(y, 0, ' ', self.width)
149
+ self.stdscr.addstr(y, 1, label + default, curses.color_pair(2))
150
+
151
+ curses.echo()
152
+ result = self.stdscr.getstr(y, 1 + len(label), 60).decode("utf-8")
153
+ curses.noecho()
154
+
155
+ curses.curs_set(0)
156
+ self.stdscr.nodelay(True)
157
+
158
+ if not result and default:
159
+ return default
160
+
161
+ return result.strip()
162
+
163
+ def main(stdscr):
164
+ app = ShuDoApp(stdscr)
165
+ app.run()
166
+
167
+
168
+ def cli():
169
+ """Entry point for the 'shudo' console script."""
170
+ import sys
171
+ # On Windows, curses may not be available
172
+ if sys.platform == "win32":
173
+ print("ShuDo requires a Unix-like terminal with curses support.")
174
+ print("Try using Windows Subsystem for Linux (WSL) or a terminal like Git Bash with winpty.")
175
+ sys.exit(1)
176
+ curses.wrapper(main)
177
+
178
+
179
+ if __name__ == "__main__":
180
+ cli()
File without changes