-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
77 lines (69 loc) · 1.5 KB
/
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"log"
"os"
"github.com/Comamoca/chuno"
"github.com/fatih/color"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
Name: "goma",
Usage: "Simple MarkDown renderer✨",
Commands: []*cli.Command{
{
Name: "preview",
Aliases: []string{"p"},
Usage: "Start the preview server.",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "isdark",
Value: false,
Usage: "Enable dark mode",
},
&cli.IntFlag{
Name: "port",
Value: 3535,
Usage: "Preview server port number",
},
},
Action: func(cCtx *cli.Context) error {
isDark := cCtx.Bool("isdark")
port := cCtx.Int("port")
file := cCtx.Args().Get(0)
color.Magenta("Starting the preview server...🚀")
err := chuno.LaunchPreviewServer(file, port, isDark)
if err != nil {
log.Fatal("An error occurred while starting the preview server.", err)
return err
}
return nil
},
},
{
Name: "render",
Aliases: []string{"r"},
Usage: "Convert MarkDown to HTML and output.",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "isdark",
Value: false,
Usage: "Enable dark mode",
},
},
Action: func(cCtx *cli.Context) error {
file := cCtx.Args().Get(0)
isDark := cCtx.Bool("isdark")
err := renderCmd(file, isDark)
if err != nil {
return err
}
return nil
},
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}