1<!--
2SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
3
4SPDX-License-Identifier: CC0-1.0
5-->
6
7# go-lunatask
8
9[][godocs.io]
10[][pkg.go.dev]
11[](https://goreportcard.com/report/git.secluded.site/go-lunatask)
12
13[](https://api.reuse.software/info/git.secluded.site/go-lunatask)
14[](https://liberapay.com/Amolith/)
15
16[godocs.io]: https://godocs.io/git.secluded.site/go-lunatask
17[pkg.go.dev]: https://pkg.go.dev/git.secluded.site/go-lunatask
18
19Go client library for [Lunatask]'s [public API].
20
21[Lunatask]: https://lunatask.app
22[public API]: https://lunatask.app/api
23
24## Usage
25
26Generate an access token in the Lunatask desktop app under `Settings` →
27`Access tokens`.
28
29```sh
30go get git.secluded.site/go-lunatask@latest
31```
32
33See the module documentation on [godocs.io] or [pkg.go.dev] for more
34detail.
35
36```go
37package main
38
39import (
40 "context"
41 "log"
42 "os"
43
44 "git.secluded.site/go-lunatask"
45)
46
47func main() {
48 client := lunatask.NewClient(os.Getenv("LUNATASK_TOKEN"), lunatask.UserAgent("MyApp/1.0"))
49
50 // Verify credentials
51 if _, err := client.Ping(context.Background()); err != nil {
52 log.Fatal(err)
53 }
54
55 // Create a task
56 task, err := client.NewTask("Review pull requests").Create(context.Background())
57 if err != nil {
58 log.Fatal(err)
59 }
60 if task == nil {
61 log.Println("Task already exists")
62 }
63}
64```
65
66### A note on duplicate handling
67
68Create methods return `(nil, nil)` when a matching entity already
69exists. This is intentional API behavior on Lunatask's part because of
70its end-to-end encryption.
71
72```go
73task, err := client.NewTask("Review PR").Create(ctx)
74if err != nil {
75 return err // actual error
76}
77if task == nil {
78 // duplicate exists, not created
79}
80```
81
82## Contributions
83
84Patch requests are in [amolith/go-lunatask] on [pr.pico.sh]. You don't
85need a new account to contribute, you don't need to fork this repo, you
86don't need to fiddle with `git send-email`, you don't need to faff with
87your email client to get `git request-pull` working...
88
89You just need:
90
91- Git
92- SSH
93- An SSH key
94
95```sh
96# Clone this repo, make your changes, and commit them
97# Create a new patch request with
98git format-patch origin/main --stdout | ssh pr.pico.sh pr create amolith/go-lunatask
99# After potential feedback, submit a revision to an existing patch request with
100git format-patch origin/main --stdout | ssh pr.pico.sh pr add {prID}
101# List patch requests
102ssh pr.pico.sh pr ls amolith/go-lunatask
103```
104
105See "How do Patch Requests work?" on [pr.pico.sh]'s home page for a more
106complete example workflow.
107
108[amolith/go-lunatask]: https://pr.pico.sh/r/amolith/go-lunatask
109[pr.pico.sh]: https://pr.pico.sh
110
111## License
112
113AGPL-3.0-or-later