-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (47 loc) · 1007 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
49
50
51
52
53
package main
import (
"fmt"
"log"
"os"
"github.com/urfave/cli/v2"
)
func main() {
ss := cli.StringSlice{}
app := &cli.App{
Name: "mdbox",
Usage: "markdown utilities",
Commands: []*cli.Command{
{
Name: "mv",
Usage: "move a file somewhere else, updates backlinks",
Flags: []cli.Flag{
&cli.StringSliceFlag{
Name: "exts",
Destination: &ss,
Required: false,
Value: cli.NewStringSlice(".markdown", ".md"),
},
},
Action: func(c *cli.Context) error {
args := c.Args().Slice()
if len(args) < 2 {
return fmt.Errorf("wrong number of arguments, expected <source> <destination>")
}
pwd, err := os.Getwd()
if err != nil {
log.Fatal("error getting current directory")
}
return mv(mvParams{
pwd: pwd,
src: args[0],
dst: args[1],
fileExts: ss.Value(),
})
},
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}