-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.go
69 lines (58 loc) · 1.34 KB
/
commands.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
package main
import (
"fmt"
"os"
"os/exec"
)
func commandHelp() {
fmt.Println("Second Brain " + Version)
fmt.Println("Developed by: Berkay Çubuk <berkay@berkaycubuk.com>")
fmt.Println("")
fmt.Println("Usage:")
fmt.Println(" sb [command] [parameters]")
fmt.Println("")
fmt.Println("Commands:")
fmt.Println(" new Create new thing")
fmt.Println(" page Create new page")
fmt.Println(" open Open a thing")
// fmt.Println(" page Open page")
fmt.Println(" git Use git inside documents folder")
fmt.Println(" help Print help")
}
func commandGit() {
docsFullPath := getHomeDir() + CONFIG_DOCS_PATH
commandArgs := []string{"-C", docsFullPath}
for i := 2; i < len(os.Args); i++ {
commandArgs = append(commandArgs, os.Args[i])
}
if len(os.Args) == 2 {
commandArgs = append(commandArgs, "status")
}
out, err := exec.Command("git", commandArgs...).Output()
if err != nil {
fmt.Printf("Unable to execute git: %v\n", err)
return
}
fmt.Println(string(out[:]))
}
func commandNew() {
if len(os.Args) == 2 {
fmt.Println("No type given, exiting.")
return
}
switch os.Args[2] {
case "page":
if len(os.Args) == 3 {
fmt.Println("No page name given, exiting.")
return
}
newPage(os.Args[3])
}
}
func commandOpen() {
if len(os.Args) == 2 {
fmt.Println("No type given, exiting.")
return
}
openPage(os.Args[2])
}