-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.lua
executable file
·62 lines (52 loc) · 1.13 KB
/
init.lua
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
#!/usr/bin/env torchbear
require 'third-party/path_separator'
require 'third-party/sanitize'
require 'third-party/join'
require 'third-party/mklink'
require 'third-party/abs'
require 'third-party/remove_recursive'
require 'third-party/basename'
local repo = require 'repo'
_G.die = function (msg)
io.stderr:write(msg)
if string.sub(msg, #msg) ~= "\n" then
io.stderr:write("\n")
end
os.exit(1)
end
local function usage(f)
f = f or io.stderr
f:write(
'usage:\n',
string.format(' %s diff\n', argv0),
string.format(' %s help\n', argv0)
string.format(' %s patch\n', argv0),
string.format(' %s start\n', argv0),
string.format(' %s status\n', argv0),
)
os.exit(f ~= io.stderr)
end
_G.argv0 = fs.basename(table.remove(arg, 1))
local name = table.remove(arg, 1)
local command = ({
diff = require 'command/diff',
save = require 'command/patch',
start = require 'command/start',
status = require 'command/status',
help = function(arg)
if #arg ~= 0 then
usage(io.stderr)
else
usage(io.stdout)
end
return
end
})[name]
if not command then
usage()
return
end
local err = command(arg)
if err then
die(err)
end