A CLI for tangled.sh
1package knit
2
3import (
4 "errors"
5 "os"
6 "os/exec"
7)
8
9// DefaultHost is the default host for tangled.sh services
10const DefaultHost = "tangled.sh"
11
12// DefaultKnot is the default knot host
13const DefaultKnot = "knot1.tangled.sh"
14
15// ErrRequiresAuth is returned when a command requires authentication but the
16// user has not authenticated with the host
17var ErrRequiresAuth = errors.New("authentication required")
18
19func Editor() string {
20 e := os.Getenv("EDITOR")
21 if e != "" {
22 return e
23 }
24
25 options := []string{"nvim", "vim", "nano"}
26 for _, opt := range options {
27 _, err := exec.LookPath(opt)
28 if err != nil {
29 continue
30 }
31 return opt
32 }
33
34 return "vi"
35}