-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.lua
executable file
·65 lines (53 loc) · 1.48 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
63
64
65
#!/usr/bin/env torchbear
require 'third-party.path_separator'
require 'third-party.basename'
require 'third-party.sanitize'
require 'third-party.join'
require 'third-party.remove_file'
log = require 'third-party.log'
require 'modules.mod'
-- This should really be refactored
require 'utils.fetch'
-- This should really be refactored
require 'utils.get_table_from'
-- Machu Picchu
-- a general-purpose package manager
require 'configs.config'
local argv0 = fs.basename(table.remove(arg, 1))
local function usage(f)
if not f then
f = io.stderr
end
f:write(
string.format('usage: mp unpack\n', argv0),
string.format('usage: mp refresh\n', argv0),
string.format('usage: mp upgrade <package-name>\n', argv0),
string.format('usage: mp install <package-name>\n', argv0),
string.format('usage: mp search <package-name>\n', argv0),
string.format('usage: mp uninstall <package-name>\n', argv0),
string.format('usage: mp [help]\n', argv0)
)
os.exit(f ~= io.stderr)
end
local cmd = table.remove(arg, 1)
if cmd == nil then
usage(io.stdout)
return
end
-- FIXME
package_name = table.remove(arg, 1)
if cmd == "install" or cmd == "search"
or cmd == "uninstall" or cmd == "upgrade" then
if package_name == "" or package_name == nil then
usage()
return
end
end
if #arg ~= 0 then
usage()
end
if cmd ~= "refresh" and not fs.exists(config["app_store_path"]) then
log.error("You have to first run: ./mp refresh")
return
end
(modules[cmd] or usage)()