Enhance CLI commands, fix bugs, and improve code quality by HamidMusayev · Pull Request #214 · caarlos0/tasktimer · GitHub
Skip to content

Enhance CLI commands, fix bugs, and improve code quality#214

Open
HamidMusayev wants to merge 4 commits into
caarlos0:mainfrom
HamidMusayev:main
Open

Enhance CLI commands, fix bugs, and improve code quality#214
HamidMusayev wants to merge 4 commits into
caarlos0:mainfrom
HamidMusayev:main

Conversation

@HamidMusayev

@HamidMusayev HamidMusayev commented May 25, 2026

Copy link
Copy Markdown

This merge request also Closes #56

new: contribution
Bug fixes:
- Fix tt report showing wrong end date and negative duration for running tasks
  by treating zero EndAt as time.Now() (markdown.go)
- Fix panic when pressing r on an empty task list (main.go)
- Fix empty task being created on blank Enter keypress (main.go)
- Fix temp file accumulation in tt edit by adding defer os.Remove (edit.go)
- Fix file descriptor leak in tt from-json by adding defer tmp.Close (fromjson.go)

Code quality:
- Change model.Bytes() to return ([]byte, error) instead of log.Fatalln on error
- Extract setTask helper in store.go to eliminate triplicated serialize-and-store pattern
- Extract effectiveEndAt helper in project_timer.go; capture time.Now() once per call
- Remove debug log.Println calls throughout the TUI Update loop
- Fix typo: newRerportCmd -> newReportCmd
- Replace deprecated ioutil.TempFile with os.CreateTemp
- Restrict exported JSON file permissions from 0o666 to 0o644
- Improve EDITOR missing error message to be platform-neutral
…ilters, list stats

New CLI commands:
- tt start <title>: stop any running task and immediately start a new one
- tt stop: stop all running or paused tasks and print what was stopped
- tt pause: freeze the current task's timer (time stops accumulating)
- tt resume: continue a paused task from where it left off

True pause/resume (same task entry, not a new one) required a data model
extension: Task gains PausedAt and PausedFor fields (backwards-compatible
via omitempty). CloseTasks now finalizes paused tasks at their pause time
so paused-dead time is never counted.

TUI changes:
- p key: toggle pause/resume on the active task; paused tasks show [paused]
- d key: delete the selected task (no confirmation, consistent with tool ethos)
- Item description now uses taskDuration which is pause-aware

Report improvements:
- --since and --until flags (YYYY-MM-DD) filter tasks by start date
- Total time in the report header reflects the filtered set only
- Paused tasks render as "paused" instead of "in progress" in the end column

List improvements:
- -v / --verbose flag shows task count and total time per project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Resume timer on existing task

1 participant