-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.go
70 lines (64 loc) · 1.66 KB
/
cli.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
70
package main
import (
"context"
"os"
"path/filepath"
"github.com/urfave/cli/v3"
)
func parseCli() (*cli.Command, error) {
cwd, _ := os.Getwd()
app := &cli.Command{
Name: "maretosi",
Usage: "render some markdown files to static html",
Version: VERSION,
Copyright: "Copyright ©️ 2024 dogue <https://github.com/dogue>\nBSD-3 License",
UsageText: "maretosi [options]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "input",
Aliases: []string{"i"},
Usage: "markdown source directory",
Value: filepath.Join(cwd, "content"),
DefaultText: "content",
Destination: &contentDir,
},
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Usage: "html destination directory",
Value: "public",
DefaultText: "public",
Destination: &outputDir,
},
&cli.StringFlag{
Name: "templates",
Aliases: []string{"t"},
Usage: "html templates directory",
Value: "templates",
Destination: &templDir,
},
&cli.StringFlag{
Name: "assets",
Aliases: []string{"a"},
Usage: "static assets source directory",
Value: filepath.Join(cwd, "assets"),
DefaultText: "assets",
Destination: &assetsDir,
},
&cli.BoolFlag{
Name: "no-assets",
Usage: "skip processing static assets",
Value: false,
Destination: &skipAssets,
},
},
// prevent printing help when no flags passed
Action: func(ctx context.Context, c *cli.Command) (err error) {
return
},
}
if app.IsSet("verbose") {
verbose = true
}
return app, app.Run(context.Background(), os.Args)
}