-
Notifications
You must be signed in to change notification settings - Fork 1
/
artisan.go
74 lines (54 loc) · 1.54 KB
/
artisan.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
package main
import (
"os"
"github.com/totoval/framework/graceful"
"github.com/totoval/framework/helpers/log"
"github.com/totoval/framework/sentry"
"totoval/bootstrap"
"github.com/urfave/cli"
"github.com/totoval/framework/console"
"totoval/database/migrations"
"github.com/totoval/framework/cmd"
command_queue "github.com/totoval/framework/cmd/commands/queue"
"github.com/totoval/framework/cmd/commands/schedule"
app_schedule "totoval/app/console"
"totoval/app/console/commands"
)
func init() {
bootstrap.Initialize()
migrations.Initialize()
command_queue.Initialize()
commands.Initialize()
schedule.Initialize()
app_schedule.Schedule(cmd.NewSchedule())
}
func main() {
cliServe()
}
func cliServe() {
app := cli.NewApp()
app.Name = "artisan"
app.Usage = "Let's work like an artisan"
app.Version = "0.5.5"
app.Commands = cmd.List()
app.Action = func(c *cli.Context) error {
console.Println(console.CODE_INFO, "COMMANDS:")
for _, cate := range app.Categories() {
categoryName := cate.Name
if categoryName == "" {
categoryName = "kernel"
}
console.Println(console.CODE_WARNING, " "+categoryName+":")
for _, cmds := range cate.Commands {
console.Println(console.CODE_SUCCESS, " "+cmds.Name+" "+console.Sprintf(console.CODE_INFO, "%s", cmds.ArgsUsage)+" "+console.Sprintf(console.CODE_WARNING, "%s", cmds.Usage))
}
}
return nil
}
if err := app.Run(os.Args); err != nil {
sentry.CaptureError(err)
log.Fatal(err.Error())
}
// totoval framework shutdown
graceful.ShutDown(true)
}