-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
48 lines (38 loc) · 820 Bytes
/
main.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 main
import (
"fmt"
"io/ioutil"
"log"
"os"
"time"
"github.com/everdev/mack"
"github.com/russross/blackfriday"
)
func main() {
args := os.Args[1:]
if len(args) == 0 {
log.Println("At least one argument is required")
return
}
title := ""
if len(args) > 1 {
title = args[1]
} else {
now := time.Now()
title = now.Format("2006-01-02 15:04:05")
}
inputFile := args[0]
content, err := ioutil.ReadFile(inputFile)
if err != nil {
log.Println(err)
return
}
formattedContent := string(blackfriday.MarkdownCommon([]byte(content)))
command := fmt.Sprintf(`create note title "%s" with html "%s" notebook {"Buffer"}`, title, formattedContent)
if err = mack.Tell("Evernote", command); err != nil {
log.Println(err)
} else {
log.Println("Note saved successfully")
return
}
}