-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd.go
45 lines (38 loc) · 1.4 KB
/
cmd.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
package cmd
import (
"fmt"
"github.com/kijimaD/ruins/lib/utils/consts"
"github.com/urfave/cli/v2"
)
const splash = `───────────────────────────────────────────────────────
██████ ██ ██ ██ ███ ██ ███████
██ ██ ██ ██ ██ ████ ██ ██
██████ ██ ██ ██ ██ ██ ██ ███████
██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██████ ██ ██ ████ ███████
───────────────────────────────────────────────────────
`
func NewMainApp() *cli.App {
app := cli.NewApp()
app.Name = "ruins"
app.Usage = "ruins [subcommand] [args]"
app.Description = "This is RPG!"
app.DefaultCommand = CmdPlay.Name
app.Version = consts.AppVersion
app.EnableBashCompletion = true
app.Commands = []*cli.Command{
CmdPlay,
CmdScreenshot,
}
cli.AppHelpTemplate = fmt.Sprintf(`%s
%s
`, splash, cli.AppHelpTemplate)
return app
}
func RunMainApp(app *cli.App, args ...string) error {
err := app.Run(args)
if err != nil {
return fmt.Errorf("コマンド実行が失敗した: %w", err)
}
return nil
}