-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
66 lines (59 loc) · 1.08 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
package main
import (
"log"
"os"
cli "github.com/urfave/cli/v2"
)
var app = cli.NewApp()
func info() {
app.Name = "go-web-app"
app.Usage = "Simple CLI for setting up Go WebAssembly frontend app."
app.Authors = []*cli.Author{{
Name: "v1rtl",
Email: "pilll.PL22@gmail.com",
}}
app.Version = "0.0.9"
}
func commands() {
app.Commands = []*cli.Command{
{
Name: "init",
Usage: "Initialize a web app",
Action: InitWebApp,
},
{
Name: "build",
Usage: "Compile Go to WebAssembly",
Action: CompileToWASMCLI,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "mode",
Value: "tinygo",
Usage: "Go compiler to use",
Aliases: []string{"m"},
},
},
},
{
Name: "dev",
Usage: "Run a development server",
Action: RunDevServer,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "port",
Value: "8080",
Usage: "Dev Server port",
Aliases: []string{"p"},
},
},
},
}
}
func main() {
info()
commands()
err := app.Run(os.Args)
if err != nil {
log.Fatalf("Failed to run go-web-app, %v", err)
}
}