README.md

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