-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.go
90 lines (82 loc) · 1.95 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package main
import (
"internal/commands"
"github.com/urfave/cli/v2"
)
func SetupCliApp() (cli.App, error) {
cliCommands := []*cli.Command{
{Name: "create",
Usage: "Create a new application",
Action: func(c *cli.Context) error {
return commands.HandleCreateCommand(c.Args().First())
},
},
{
Name: "dev",
Usage: "This run the app in dev mode with file watching",
Action: func(c *cli.Context) error {
// handle dev
return commands.HandleDevCommand(c.Args().First())
},
},
{
Name: "build",
Usage: "This builds the app for production.",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "dts",
Usage: "Will emit .d.ts files and bundle them",
},
// &cli.BoolFlag{
// Name: "sourcemap",
// Usage: "Will emit source maps",
// },
// &cli.StringFlag{
// Name: "dist",
// Usage: "Set output directory",
// Value: "dist",
// },
},
Action: func(c *cli.Context) error {
return commands.HandleBuildCommand(c.Args().First(), c.Bool("dts"))
},
},
{
Name: "prettier",
Usage: "Will run pretty-quick",
Action: func(c *cli.Context) error {
return commands.HandlePrettierCommand()
},
},
{
Name: "lint",
Usage: "Will lint the application",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "fix",
Usage: "Will auto fix linter problems",
},
},
Action: func(c *cli.Context) error {
return commands.HandleLintCommand(c.Bool("fix"))
},
},
}
app := &cli.App{
Name: "tsdev",
Commands: cliCommands,
Usage: "Zero config modern typescript tooling",
EnableBashCompletion: true,
ArgsUsage: "Run a .ts file with zero config directly",
Action: func(c *cli.Context) error {
return commands.HandleDefault(c.Bool("watch"), c.Args().Slice())
},
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "watch",
Usage: "Run in watch mode",
},
},
}
return *app, nil
}