-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (41 loc) · 895 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
package main
import (
"log"
"os"
"path/filepath"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
Commands: []*cli.Command{
{
Name: "new",
Usage: "新しいページを作成します。",
Action: func(*cli.Context) error {
// プロンプトを用いて対話的にページを作成する
categoryPath := selectCategory(categoryList())
fileName := inputFileName()
newFilePath := replaceExt(
filepath.Join(categoryPath, fileName),
"",
".md")
Xopen(newFilePath)
return nil
},
},
{
Name: "edit",
Usage: "ページを選択して編集します。",
Action: func(*cli.Context) error {
path := selectCategory(categoryList())
base := selectPage(pageList(path))
Xopen(base)
return nil
},
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}