Skip to content

Commit edfff51

Browse files
committed
docs: improve CLI documentation and argument handling
- Add comprehensive CLI Flags section to README with examples - Update AGENTS.md with markdown conventions and cleanup - Improve help text in main.go to show positional argument usage - Add argument pre-processing to support minutes before flags
1 parent 739724d commit edfff51

3 files changed

Lines changed: 56 additions & 64 deletions

File tree

AGENTS.md

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ This is critical because:
9797

9898
## Code Patterns & Conventions
9999

100+
### Markdown
101+
102+
- Write all ordered lists starting with `1.`
103+
100104
### File Structure
101105
- Multiple `.go` files organized by responsibility (model, handlers, view, database, utils, constants)
102106
- All files are in the same package (main package)
@@ -133,25 +137,6 @@ This is critical because:
133137
- **Database tests**: Create temp SQLite DB in temp dir for isolation
134138
- **Time-based tests**: Use `testing.Testing()` to skip platform-specific code (e.g., macOS notifications)
135139

136-
### Test Examples
137-
```go
138-
// Setup model with specific state
139-
m := model{
140-
progress: progress.New(...),
141-
startTime: time.Now().Unix(),
142-
targetDuration: 3600,
143-
countUpMode: true,
144-
}
145-
146-
// Trigger action
147-
newModel, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'d'}})
148-
modelTyped := newModel.(model)
149-
150-
// Assert outcomes
151-
assert.Equal(t, "", modelTyped.title, "Title should be blank after logging")
152-
assert.NoError(t, err)
153-
```
154-
155140
### Important: Test Always for User-Facing Changes
156141
- Any change to key handling must include key binding tests
157142
- Any change to UI rendering must verify View() output
@@ -255,22 +240,6 @@ Before submitting changes:
255240
- [ ] Error handling present and logged (don't silently fail)
256241
- [ ] JOURNAL.md updated for significant work
257242

258-
## Dependencies
259-
260-
### Core TUI Framework
261-
- `github.com/charmbracelet/bubbletea` v1.2.4+ - Event loop framework
262-
- `github.com/charmbracelet/bubbles` v0.20.0+ - UI components (progress, table)
263-
- `github.com/charmbracelet/lipgloss` v1.0.0+ - Terminal styling
264-
265-
### Database
266-
- `github.com/mattn/go-sqlite3` v1.14.24+ - SQLite driver
267-
268-
### Testing
269-
- `github.com/stretchr/testify` v1.10.0+ - Assertions and test helpers
270-
271-
### Language
272-
- Go 1.23.4+ (check go.mod for exact version)
273-
274243
## Documentation
275244

276245
- **JOURNAL.md**: Historical record of significant work (debugging, features, fixes)
@@ -280,24 +249,4 @@ Before submitting changes:
280249
- **README.md**: User-facing documentation (installation, usage, features)
281250
- **AGENTS.md** (this file): Developer guidelines for working in the codebase
282251

283-
## Debugging Tips
284-
285-
### Logging
286-
- Print errors with `fmt.Println()` - they appear in terminal
287-
- Use `fmt.Printf()` for debugging during development (remove before committing)
288-
- **Gotcha**: Error handling might hide issues - always check returned errors
289-
290-
### Testing Specific Features
291-
```bash
292-
# Run single test
293-
go test -run TestCountUpModePromptLogAndReset -v
294-
295-
# Run with timeout and race detector
296-
go test -race -timeout 30s -v
297-
```
298252

299-
### Common Issues
300-
- **Panic on nil**: Always check error returns and nil assertions
301-
- **Timer seems wrong**: Verify `startTime` isn't being modified
302-
- **Database errors**: Check directory exists and file permissions
303-
- **UI not updating**: Verify `cmd := m.progress.SetPercent(...)` or `tea.Batch()` returns

README.md

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A simple command-line application to run a [Pomodoro](https://www.pomodorotechni
55
## Features
66

77
- Animated progress bar
8-
- Countdown timer
8+
- Countdown timer (defaults to `25` minutes)
99
- Customizable timer duration
1010

1111
## Installation
@@ -47,6 +47,47 @@ Or specify a custom duration in minutes:
4747
tiny-timer 5
4848
```
4949

50+
## CLI Flags
51+
52+
The following command-line flags are available:
53+
54+
### Positional Arguments
55+
56+
- **`[minutes]`** - Optional duration in minutes for the timer. If not specified, defaults to 25 minutes. Can be placed before or after flags.
57+
58+
```bash
59+
tiny-timer 5
60+
tiny-timer -count-up 10
61+
```
62+
63+
### Flags
64+
65+
- **`-title <string>`** - Set an optional title for the timer session. Useful for labeling your work sessions.
66+
67+
```bash
68+
tiny-timer -title "Writing documentation"
69+
tiny-timer 30 -title "Code review"
70+
```
71+
72+
- **`-count-up`** - Enable count-up mode instead of countdown. In this mode, the timer tracks elapsed time and allows you to log tasks to the SQLite database. Default duration is 1 hour (for progress bar scaling).
73+
74+
```bash
75+
tiny-timer -count-up
76+
tiny-timer -count-up -title "Project planning"
77+
```
78+
79+
- **`-clean`** - Delete the SQLite database and exit. Useful for resetting your session history.
80+
81+
```bash
82+
tiny-timer -clean
83+
```
84+
85+
- **`-debug`** - Enable debug logging to `debug.log` file. All log output will be written to this file for troubleshooting.
86+
87+
```bash
88+
tiny-timer -debug
89+
```
90+
5091
## Development
5192

5293
### Testing Releases with GoReleaser
@@ -76,14 +117,6 @@ For a full dry-run that also validates publishing (without actually publishing):
76117
goreleaser release --snapshot --skip-publish
77118
```
78119

79-
## Dependencies
80-
81-
This project uses the following Go packages:
82-
83-
- [github.com/charmbracelet/bubbles](https://github.com/charmbracelet/bubbles)
84-
- [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea)
85-
- [github.com/charmbracelet/lipgloss](https://github.com/charmbracelet/lipgloss)
86-
87120
## License
88121

89122
This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.

main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ func main() {
2525
cleanFlag := flag.Bool("clean", false, "Delete the database and exit")
2626
debugFlag := flag.Bool("debug", false, "Enable debug logging to debug.log")
2727

28+
// Customize usage to include positional argument
29+
flag.Usage = func() {
30+
fmt.Fprintf(os.Stderr, "Usage: %s [minutes] [flags]\n\n", os.Args[0])
31+
fmt.Fprintf(os.Stderr, "Positional arguments:\n")
32+
fmt.Fprintf(os.Stderr, " minutes\n")
33+
fmt.Fprintf(os.Stderr, " \tDuration in minutes for the timer (default: 25)\n\n")
34+
fmt.Fprintf(os.Stderr, "Flags:\n")
35+
flag.PrintDefaults()
36+
}
37+
2838
// Pre-process arguments to allow positional argument (minutes) before flags
2939
// flag.Parse() stops at the first non-flag argument.
3040
// We check if the first argument is a number and move it to the end if so.

0 commit comments

Comments
 (0)