forked from timakin/qunosy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qunosy.go
42 lines (40 loc) · 1.31 KB
/
qunosy.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
package main
import (
"os"
"github.com/codegangsta/cli" // cli.goをインポート
"os/exec"
"path/filepath"
"fmt"
)
func main() {
app := cli.NewApp()
app.Name = "qunosy" // ヘルプを表示する際に使用される
app.Usage = "print arguments" // ヘルプを表示する際に使用される
app.Version = "0.1.0" // ヘルプを表示する際に使用される
absPath, _ := filepath.Abs("../qunosy")
app.Action = func(c *cli.Context) { // コマンド実行時の処理
if len(c.Args()) > 1 {
if c.Args()[0] == "reload" {
fmt.Println("Reloading qiita log ...")
reload := exec.Command("sh", absPath + "/reload.sh", c.Args()[1])
reloadOut, err := reload.Output()
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Print(string(reloadOut))
} else {
return
}
} else {
qunosy := exec.Command("sh", absPath + "/qunosy.sh")
qunosyOut, err := qunosy.Output()
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Print(string(qunosyOut))
}
}
app.Run(os.Args)
}