-
Notifications
You must be signed in to change notification settings - Fork 27
/
doc.go
48 lines (37 loc) · 1.04 KB
/
doc.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
/*
Package notes is a library which consists notes command.
https://github.com/rhysd/notes-cli/tree/master/cmd/notes
This library is for using notes command programmatically from Go program.
It consists structs which represent each subcommands.
1. Create Config instance with NewConfig
2. Create an instance of subcommand you want to run with config
3. Run it with .Do() method. It will return an error if some error occurs
import (
"bytes"
"fmt"
"github.com/rhysd/notes-cli"
"os"
"strings"
)
var buf bytes.Buffer
// Create user configuration
cfg, err := notes.NewConfig()
if err != nil {
panic(err)
}
// Prepare `notes list` command
cmd := ¬es.ListCmd{
Config: cfg,
Relative: true,
Out: &buf
}
// Runs the command
if err := cmd.Do(); err != nil {
fmt.Fprintln(os.Stdout, err)
}
paths := strings.Split(strings.Trim(buf.String(), "\n"), "\n")
fmt.Println("Note paths:", paths)
For usage of `notes` command, please read README of the repository.
https://github.com/rhysd/notes-cli/blob/master/README.md
*/
package notes