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"), lunatask.UserAgent("MyApp/1.0"))
 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 := lunatask.NewTask("Review pull requests").Create(context.Background(), client)
 56	if err != nil {
 57		log.Fatal(err)
 58	}
 59	if task == nil {
 60		log.Println("Task already exists")
 61	}
 62}
 63```
 64
 65### A note on duplicate handling
 66
 67Create methods return `(nil, nil)` when a matching entity already
 68exists. This is intentional API behavior on Lunatask's part because of
 69its end-to-end encryption.
 70
 71```go
 72task, err := lunatask.NewTask("Review PR").Create(ctx, client)
 73if err != nil {
 74    return err // actual error
 75}
 76if task == nil {
 77    // duplicate exists, not created
 78}
 79```
 80
 81## Contributions
 82
 83Patch requests are in [amolith/go-lunatask] on [pr.pico.sh]. You don't
 84need a new account to contribute, you don't need to fork this repo, you
 85don't need to fiddle with `git send-email`, you don't need to faff with
 86your email client to get `git request-pull` working...
 87
 88You just need:
 89
 90- Git
 91- SSH
 92- An SSH key
 93
 94```sh
 95# Clone this repo, make your changes, and commit them
 96# Create a new patch request with
 97git format-patch origin/main --stdout | ssh pr.pico.sh pr create amolith/go-lunatask
 98# After potential feedback, submit a revision to an existing patch request with
 99git format-patch origin/main --stdout | ssh pr.pico.sh pr add {prID}
100# List patch requests
101ssh pr.pico.sh pr ls amolith/go-lunatask
102```
103
104See "How do Patch Requests work?" on [pr.pico.sh]'s home page for a more
105complete example workflow.
106
107[amolith/go-lunatask]: https://pr.pico.sh/r/amolith/go-lunatask
108[pr.pico.sh]: https://pr.pico.sh
109
110## License
111
112AGPL-3.0-or-later