Skip to content

Commit f62460e

Browse files
committed
feat(tui): add logs-path CLI command and update README
1 parent 5bf04bd commit f62460e

4 files changed

Lines changed: 116 additions & 49 deletions

File tree

justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,7 @@ tui-version:
103103
# Show toki-tui session and Milltime status
104104
tui-status:
105105
cd toki-tui && cargo run -- status
106+
107+
# Print the log notes directory path
108+
tui-logs:
109+
cd toki-tui && cargo run -- logs-path

toki-tui/README.md

Lines changed: 106 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -16,45 +16,38 @@ just tui-dev
1616

1717
# Clear saved session
1818
just tui-logout
19-
20-
# Print config path and create default config if missing
21-
just tui-config
2219
```
2320

24-
## Configuration
25-
26-
Config file: `~/.config/toki-tui/config.toml`
27-
28-
Run `just tui-config` (or `cargo run -- config-path`) to print the path and create the file with defaults if it does not exist.
21+
## CLI Commands
2922

30-
All keys are optional. If the file is missing, built-in defaults are used.
31-
32-
### Environment variables
23+
All commands are available via the binary directly (`toki-tui <command>`) or through `just`:
3324

34-
You can override config values with environment variables.
25+
| Command | `just` recipe | Description |
26+
| -------------- | -------------- | -------------------------------------------------- |
27+
| `run` | `just tui` | Run against the real toki-api server |
28+
| `dev` | `just tui-dev` | Run in dev mode with in-memory mock data |
29+
| `login` | `just tui-login` | Authenticate via browser OAuth |
30+
| `logout` | `just tui-logout` | Clear saved session and Milltime cookies |
31+
| `status` | `just tui-status` | Show current login and Milltime session status |
32+
| `config-path` | `just tui-config` | Print config path; create default file if missing |
33+
| `logs-path` | `just tui-logs` | Print the log notes directory path |
34+
| `version` | `just tui-version` | Print the current version |
3535

36-
- Prefix: `TOKI_TUI_`
37-
- Key format: uppercase snake case
38-
- Nested keys (if added later): use `__` as separator
36+
## Configuration
3937

40-
Current variables:
38+
Config file: `~/.config/toki-tui/config.toml`
4139

42-
```bash
43-
TOKI_TUI_API_URL="http://localhost:8080"
44-
TOKI_TUI_GIT_DEFAULT_PREFIX="Development"
45-
TOKI_TUI_TASK_FILTER="+work project:Toki"
46-
TOKI_TUI_AUTO_RESIZE_TIMER=true
47-
```
40+
Run `just tui-config` (or `toki-tui config-path`) to print the path and create the file with defaults if it does not exist.
4841

49-
Environment variables override values from `config.toml`.
42+
All keys are optional. If the file is missing, built-in defaults are used.
5043

5144
```toml
5245
# URL of the toki-api server. Defaults to the production instance.
5346
api_url = "https://toki-api.spinit.se"
5447

5548
# Prefix used when converting a git branch name to a time entry note,
5649
# when no conventional commit prefix (feat/fix/etc.) or ticket number is found.
57-
# Example: branch "branding/redesign" → "Utveckling: branding/redesign"
50+
# Example: branch "branding/redesign" → "Development: branding/redesign"
5851
git_default_prefix = "Utveckling"
5952

6053
# Taskwarrior filter tokens prepended before `status:pending export`.
@@ -66,6 +59,32 @@ task_filter = ""
6659
# When true (default), the timer grows large when running and shrinks when stopped.
6760
# Set to false to keep the timer at a fixed (normal) size at all times.
6861
auto_resize_timer = true
62+
63+
# Entry templates — pre-fill project, activity and note from a picker (press T).
64+
# [[template]] sections can be repeated.
65+
[[template]]
66+
name = "My project"
67+
project = "My Project"
68+
activity = "Development"
69+
note = "Working on stuff"
70+
```
71+
72+
### Entry templates
73+
74+
Define reusable presets in `config.toml`. In the timer view, press `T` to open the template picker and select one to pre-fill the current entry.
75+
76+
### Environment variables
77+
78+
Environment variables override values from `config.toml`.
79+
80+
- Prefix: `TOKI_TUI_`
81+
- Key format: uppercase snake case
82+
83+
```bash
84+
TOKI_TUI_API_URL="http://localhost:8080"
85+
TOKI_TUI_GIT_DEFAULT_PREFIX="Development"
86+
TOKI_TUI_TASK_FILTER="+work project:Toki"
87+
TOKI_TUI_AUTO_RESIZE_TIMER=true
6988
```
7089

7190
### Example: local dev setup
@@ -76,33 +95,71 @@ git_default_prefix = "Development"
7695
task_filter = "+work"
7796
```
7897

79-
## Testing
98+
## Log notes
99+
100+
Attach a freeform markdown log file to any time entry. Log files are stored in `~/.local/share/toki-tui/logs/` and linked to entries via a tag embedded in the note (`[log:XXXXXX]`). The tag is hidden in all display locations — only the clean summary is shown.
101+
102+
Run `just tui-logs` (or `toki-tui logs-path`) to print the log directory path.
103+
104+
## Key bindings
105+
106+
### Timer view
107+
108+
| Key | Action |
109+
| -------------------- | ----------------------------- |
110+
| `Space` | Start / stop timer |
111+
| `Ctrl+S` | Save (with options) |
112+
| `Ctrl+R` | Resume last entry |
113+
| `Ctrl+X` | Clear current entry |
114+
| `Enter` | Edit description |
115+
| `P` | Edit project / activity |
116+
| `N` | Edit note (description editor) |
117+
| `T` | Open template picker |
118+
| `H` | Switch to history view |
119+
| `S` | Switch to statistics view |
120+
| `X` | Toggle timer size |
121+
| `Z` | Zen mode (hide UI chrome) |
122+
| `Tab / ↑↓ / j/k` | Navigate |
123+
| `Q` | Quit |
124+
125+
### Description editor (note / `N`)
126+
127+
| Key | Action |
128+
| -------------------- | ----------------------------- |
129+
| `Ctrl+L` | Add / edit log file |
130+
| `Ctrl+R` | Remove linked log file |
131+
| `Ctrl+D` | Change working directory |
132+
| `Ctrl+G` | Git: copy/paste branch or commit |
133+
| `Ctrl+T` | Taskwarrior: pick a task |
134+
| `Ctrl+X` | Clear note |
135+
| `Ctrl+←/→` | Word-boundary navigation |
136+
| `Ctrl+Backspace` | Delete word back |
137+
| `Enter` | Confirm |
138+
| `Esc` | Cancel |
139+
140+
### History view
141+
142+
| Key | Action |
143+
| -------------------- | ----------------------------- |
144+
| `↑↓` | Navigate entries |
145+
| `Enter` | Edit entry |
146+
| `Ctrl+R` | Resume entry (copy to timer) |
147+
| `Ctrl+L` | Open linked log file |
148+
| `H / Esc` | Back to timer view |
149+
| `Q` | Quit |
150+
151+
**While editing a history entry:**
152+
153+
| Key | Action |
154+
| -------------------- | ----------------------------- |
155+
| `Tab` | Next field |
156+
| `P / A` | Change project / activity |
157+
| `Esc` | Save and exit edit mode |
80158

81-
Run the TUI test suite with:
159+
## Testing
82160

83161
```bash
84-
cargo test -p toki-tui
162+
SQLX_OFFLINE=true cargo test -p toki-tui
85163
```
86164

87-
The current tests focus on the most stable and useful layers first:
88-
89-
- app and state behavior
90-
- parsing and text input helpers
91-
- runtime action handling with the dev backend
92-
- focused Ratatui render assertions for important UI states
93-
94-
## Standard key bindings
95-
96-
| Key | Action |
97-
| -------------- | ------------------ |
98-
| `Space` | Start / stop timer |
99-
| `Ctrl+S` | Save (options) |
100-
| `Ctrl+X` | Clear |
101-
| `Tab / ↑↓ / j/k` | Navigate |
102-
| `H` | History view |
103-
| `P` | Project |
104-
| `N` | Note |
105-
| `T` | Toggle timer size |
106-
| `S` | Stats |
107-
| `Esc` | Exit / cancel |
108-
| `Q` | Quit |
165+
Tests cover app and state behavior, text input helpers, runtime action handling, and focused Ratatui render assertions.

toki-tui/src/cli.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pub enum Commands {
2020
Logout,
2121
/// Print config path and create default file if missing
2222
ConfigPath,
23+
/// Print the log notes directory path
24+
LogsPath,
2325
/// Print the current version
2426
Version,
2527
/// Show current login and Milltime session status

toki-tui/src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ async fn main() -> Result<()> {
3232
let path = config::TokiConfig::ensure_exists()?;
3333
println!("{}", path.display());
3434
}
35+
Commands::LogsPath => {
36+
let path = log_notes::log_dir()?;
37+
println!("{}", path.display());
38+
}
3539
Commands::Version => {
3640
println!("{}", env!("CARGO_PKG_VERSION"));
3741
}

0 commit comments

Comments
 (0)