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