forked from ostinelli/gin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgin
executable file
·71 lines (61 loc) · 2.25 KB
/
gin
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
#!/usr/bin/env lua
local Gin = require 'gin.core.gin'
local help_description = [[
/++++/:
NNNNNmm
mNNMNmy
.dNMMNms`
.:+sydMMMMMdyo/-`
`sdmmmNNNMMMMMNmdhhddo
`dMMNNMMMMMMMMMNdhdMMy
`dMMMNMMMMdsymMNdhdNMy
`dMMMNNho-....:shhdNMy
`dMMdo-......`.``:sNMy
`dd/........-..````-hy
`:...--.`----..`````.-
``//+- G I N .+-/`
`:..-..``-...-.`.`.``-
`hs-```-./.:`-/`.```os
`hNms-.``.-.-.````+mmy
`hNNNNh+.-:---`-smNNmy
`hNNNMMMNy+.:sdNNNNNmy`
`dNNNNMMMMMNNNNNNNNNNy`
`hNNNNNMMMMMMMMNNmNNNy`
./osyhhddddddhhyss+:`
GIN v]] .. Gin.version .. [[, a JSON-API web framework.
Usage: gin COMMAND [ARGS] [OPTIONS]
The available gin commands are:
new [name] Create a new Gin application
start Starts the Gin server
stop Stops the Gin server
console Start a Gin console
generate migration [name] Create a new migration (name is optional)
generate controller <name> Create a new controller
generate model <name> [--only] Create a new model,name is plural.if --only is set,only create model file
migrate Run all migrations that have not been run
migrate rollback Rollback one migration
Options:
--trace Shows additional logs
]]
local launcher = require 'gin.cli.launcher'
local application = require 'gin.cli.application'
local migrations = require 'gin.cli.migrations'
local console = require 'gin.cli.console'
local model_generator = require 'gin.cli.model_generator'
-- check trace
GIN_TRACE = false
if arg[#arg] == '--trace' then
table.remove(arg, #arg)
GIN_TRACE = true
end
-- check args
if arg[1] == 'new' and arg[2] then application.new(arg[2])
elseif arg[1] == 'start' then launcher.start()
elseif arg[1] == 'stop' then launcher.stop()
elseif (arg[1] == 'generate' or arg[1] == 'g') and arg[2] == 'migration' then migrations.new(arg[3])
elseif (arg[1] == 'generate' or arg[1] == 'g') and arg[2] == 'model' then model_generator.new(arg[3])
elseif arg[1] == 'migrate' and arg[2] == nil then migrations.up()
elseif arg[1] == 'migrate' and arg[2] == "rollback" then migrations.down()
elseif arg[1] == 'console' or arg[1] == 'c' then console.start()
else print(help_description)
end