cli + tui to publish to leaflet (wip) & manage tasks, notes & watch/read lists 馃崈
charm
leaflet
readability
golang
1---
2title: Task Automation
3sidebar_label: Taskfile
4sidebar_position: 3
5description: Using Taskfile for development workflows.
6---
7
8# Task Automation
9
10Noteleaf uses [Task](https://taskfile.dev) to automate common development workflows.
11
12## Installation
13
14### macOS
15
16```sh
17brew install go-task/tap/go-task
18```
19
20### Linux
21
22```sh
23sh -c "$(curl -fsSL https://taskfile.dev/install.sh)"
24```
25
26### Go Install
27
28```sh
29go install github.com/go-task/task/v3/cmd/task@latest
30```
31
32## Available Tasks
33
34View all tasks:
35
36```sh
37task
38# or
39task --list
40```
41
42## Common Tasks
43
44### Build Commands
45
46**task build** - Quick development build
47
48```sh
49task build
50```
51
52Output: `./tmp/noteleaf`
53
54**task build:dev** - Build with version information
55
56```sh
57task build:dev
58```
59
60Includes git commit hash and build date.
61
62**task build:rc** - Release candidate build
63
64```sh
65git tag v1.0.0-rc1
66task build:rc
67```
68
69Requires git tag with `-rc` suffix.
70
71**task build:prod** - Production build
72
73```sh
74git tag v1.0.0
75task build:prod
76```
77
78Requires clean semver tag and no uncommitted changes.
79
80### Testing Commands
81
82**task test** - Run all tests
83
84```sh
85task test
86```
87
88**task coverage** - Generate HTML coverage report
89
90```sh
91task coverage
92open coverage.html # View report
93```
94
95**task cov** - Terminal coverage summary
96
97```sh
98task cov
99```
100
101**task check** - Lint and coverage
102
103```sh
104task check
105```
106
107Runs linters and generates coverage report.
108
109### Development Commands
110
111**task dev** - Full development workflow
112
113```sh
114task dev
115```
116
117Runs:
118
1191. `task clean`
1202. `task lint`
1213. `task test`
1224. `task build`
123
124**task lint** - Run linters
125
126```sh
127task lint
128```
129
130Runs `go vet` and `go fmt`.
131
132**task run** - Build and run
133
134```sh
135task run
136```
137
138Builds then executes the binary.
139
140### Maintenance Commands
141
142**task clean** - Remove build artifacts
143
144```sh
145task clean
146```
147
148Removes:
149
150- `./tmp/` directory
151- Coverage files
152
153**task deps** - Download and tidy dependencies
154
155```sh
156task deps
157```
158
159Runs `go mod download` and `go mod tidy`.
160
161### Documentation Commands
162
163**task docs:generate** - Generate all documentation
164
165```sh
166task docs:generate
167```
168
169Generates:
170
171- Docusaurus docs (website/docs/manual)
172- Man pages (docs/manual)
173
174**task docs:man** - Generate man pages
175
176```sh
177task docs:man
178```
179
180**task docs:serve** - Start documentation server
181
182```sh
183task docs:serve
184```
185
186Starts Docusaurus development server at <http://localhost:3000>.
187
188### Version Commands
189
190**task version:show** - Display version info
191
192```sh
193task version:show
194```
195
196Shows:
197
198- Git tag
199- Git commit
200- Git describe output
201- Build date
202
203**task version:validate** - Validate git tag
204
205```sh
206task version:validate
207```
208
209Checks tag format for releases.
210
211### Utility Commands
212
213**task status** - Show Go environment
214
215```sh
216task status
217```
218
219Displays:
220
221- Go version
222- Module information
223- Dependencies
224
225## Taskfile Variables
226
227Variables injected during build:
228
229```yaml
230BINARY_NAME: noteleaf
231BUILD_DIR: ./tmp
232VERSION_PKG: github.com/stormlightlabs/noteleaf/internal/version
233GIT_COMMIT: $(git rev-parse --short HEAD)
234GIT_TAG: $(git describe --tags --exact-match)
235BUILD_DATE: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
236```
237
238## Task Dependencies
239
240Some tasks automatically trigger others:
241
242```sh
243task run
244# Automatically runs: task build
245```
246
247```sh
248task dev
249# Runs in sequence:
250# 1. task clean
251# 2. task lint
252# 3. task test
253# 4. task build
254```
255
256## Custom Workflows
257
258### Pre-commit Workflow
259
260```sh
261task lint && task test
262```
263
264### Release Preparation
265
266```sh
267task check && \
268git tag v1.0.0 && \
269task build:prod && \
270./tmp/noteleaf version
271```
272
273### Documentation Preview
274
275```sh
276task docs:generate
277task docs:serve
278```
279
280### Full CI Simulation
281
282```sh
283task clean && \
284task deps && \
285task lint && \
286task test && \
287task coverage && \
288task build:dev
289```
290
291## Taskfile Structure
292
293Location: `Taskfile.yml` (project root)
294
295Key sections:
296
297- **vars**: Build variables and git information
298- **tasks**: Command definitions with descriptions
299- **deps**: Task dependencies
300- **preconditions**: Validation before execution
301
302## Configuration
303
304Customize via `Taskfile.yml` or environment variables:
305
306```yaml
307vars:
308 BINARY_NAME: noteleaf
309 BUILD_DIR: ./tmp
310```
311
312Override at runtime:
313
314```sh
315BINARY_NAME=custom-noteleaf task build
316```
317
318## Why Task Over Make?
319
320- Cross-platform (Windows, macOS, Linux)
321- YAML syntax (more readable than Makefile)
322- Built-in variable interpolation
323- Better dependency management
324- Precondition validation
325- Native Go integration
326
327## Further Reading
328
329- [Task Documentation](https://taskfile.dev)
330- [Taskfile Schema](https://taskfile.dev/api/)
331- Project Taskfile: `Taskfile.yml`