-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaio-cli
executable file
·113 lines (104 loc) · 2.92 KB
/
aio-cli
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh
_=[[
for name in luajit lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1 lua; do
: ${LUA:="$(command -v "$name")"}
done
if [ -z "$LUA" ]; then
echo >&2 "ERROR: lua interpretor not found"
exit 1
fi
LUA_PATH="${LUA_PATH:+{$LUA_PATH};}"'./?.lua;./?/init.lua;./lib/?.lua;./lib/?/init.lua;;' \
exec "$LUA" "$0" "$@"
exit $?
]] and nil
--[[--------------------------------------------------------------------------
-- Dragoon Framework - A Framework for Lua/LOVE --
-- Copyright (c) 2014-2015 TsT worldmaster.fr <[email protected]> --
--]]--------------------------------------------------------------------------
-- $0 --mod <modname1 pathtofile1> [--mod <modname2> <pathtofile2>] [-- <file> [files...]]
-- $0 {--mod ...|--code ...} [-- files...]
-- $0 --autoaliases
-- TODO: support -h|--help and help/usage text
--local argv = arg and (#arg -1) or 0
local aio = require "aio"
local cmd_shebang = aio.shebang
local cmd_luamod = aio.luamod
local cmd_rawmod = aio.rawmod
local cmd_mod = aio.mod
local cmd_code = aio.code
local cmd_codehead = aio.codehead
local cmd_shellcode = aio.shellcode
local cmd_mode = aio.mode
local cmd_vfile = aio.vfile
local cmd_autoaliases = aio.autoaliases
local cmd_icheck = aio.icheck
local cmd_icheckinit = aio.ichechinit
local cmd_require = aio.require
local cmd_luacode = aio.luacode
local cmd_finish = aio.finish
local function main(arg)
local i = 1
local function shift(n)
i=i+(n or 1)
end
while i <= #arg do
local a1 = arg[i]; i=i+1
if a1 == "--shebang" then
local file=arg[i]; shift()
cmd_shebang(file)
elseif a1 == "--luamod" then
local name=arg[i]; shift()
local file=arg[i]; shift()
cmd_luamod(name, file)
elseif a1 == "--rawmod" then
local name=arg[i]; shift()
local file=arg[i]; shift()
cmd_rawmod(name, file)
elseif a1 == "--mod" then
local name=arg[i]; shift()
local file=arg[i]; shift()
cmd_mod(name, file)
elseif a1 == "--code" then
local file=arg[i]; shift()
cmd_code(file)
elseif a1 == "--codehead" then
local n=tonumber(arg[i]); shift()
local file=arg[i]; shift()
cmd_codehead(n or 0, file)
elseif a1 == "--shellcode" then
local file=arg[i]; shift()
cmd_shellcode(file)
elseif a1 == "--mode" then
local newmode=arg[i]; shift()
cmd_mode(newmode)
elseif a1 == "--vfile" then
local filename = arg[i]; shift()
local filepath = arg[i]; shift()
cmd_vfile(filename, filepath)
elseif a1 == "--autoaliases" then
cmd_autoaliases()
elseif a1 == "--icheck" then
cmd_icheck()
elseif a1 == "--icheckinit" then
cmd_ichechinit()
elseif a1 == "--require" then
local modname = arg[i]; shift()
cmd_require(modname)
elseif a1 == "--luacode" then
local data = arg[i]; shift()
cmd_luacode(data)
elseif a1 == "--finish" then
cmd_finish()
elseif a1 == "--" then
break
else
error("error "..a1)
end
end
if i <= #arg then
for j=i,#arg,1 do
print_no_nl(cat(arg[j]))
end
end
end
main(arg)