/
add.go
95 lines (91 loc) · 2 KB
/
add.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package main
import (
"fmt"
"github.com/urfave/cli/v2"
)
func cmdAdd() *cli.Command {
return &cli.Command{
Name: "add",
Usage: "add items",
BashComplete: func(c *cli.Context) {
if c.NArg() > 0 {
return
}
for _, t := range []string{"tag", "note"} {
fmt.Println(t)
}
},
Subcommands: []*cli.Command{
{
Name: "tag",
Usage: "add tags",
BashComplete: func(c *cli.Context) {
if c.NArg() > 0 {
return
}
for _, t := range []string{"--title", "--parent", "--parent-uuid"} {
fmt.Println(t)
}
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "title",
Usage: "new tag title (separate multiple with commas)",
},
&cli.StringFlag{
Name: "parent",
Usage: "parent tag title to make a sub-tag of",
},
&cli.StringFlag{
Name: "parent-uuid",
Usage: "parent tag uuid to make a sub-tag of",
},
},
Action: func(c *cli.Context) error {
opts := getOpts(c)
// useStdOut = opts.useStdOut
return processAddTags(c, opts)
},
},
{
Name: "note",
Usage: "add a note",
BashComplete: func(c *cli.Context) {
addNoteOpts := []string{"--title", "--text", "--tag", "--replace"}
if c.NArg() > 0 {
return
}
for _, ano := range addNoteOpts {
fmt.Println(ano)
}
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "title",
Usage: "new note title",
},
&cli.StringFlag{
Name: "text",
Usage: "new note text",
},
&cli.StringFlag{
Name: "file",
Usage: "path to file with note content (specify --title or leave blank to use filename)",
},
&cli.StringFlag{
Name: "tag",
Usage: "associate with tag (separate multiple with commas)",
},
&cli.BoolFlag{
Name: "replace",
Usage: "replace note with same title",
},
},
Action: func(c *cli.Context) error {
opts := getOpts(c)
return processAddNotes(c, opts)
},
},
},
}
}