-
Notifications
You must be signed in to change notification settings - Fork 83
/
chocolatey.lua
121 lines (112 loc) · 4.85 KB
/
chocolatey.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
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
113
114
115
116
117
118
119
120
121
local w = require('tables').wrap
local path = require('path')
local packages = function (token)
local install = clink.get_env('chocolateyinstall')
if install then
return w(clink.find_dirs(clink.get_env('chocolateyinstall')..'/lib/*'))
:filter(function(dir)
return path.is_real_dir(dir) and clink.is_match(token, dir)
end)
:map(function (dir)
local package_name = dir:match("^(%w%.*)%.")
return package_name or dir
end)
end
end
local parser = clink.arg.new_parser
local clist_parser = parser(
"-a", "--all", "--allversions", "--all-versions",
"-i", "--includeprograms", "--include-programs",
"-l", "--lo", "--localonly", "--local-only",
"-s", "--source".. parser({"windowsfeatures", "webpi"}),
"-u", "--user",
"-p", "--password")
local cinst_parser = parser(
-- TODO: Path to packages config.
-- See https://github.com/chocolatey/choco/wiki/CommandsInstall
{"all", "packages.config"},
"--ia", "--installargs", "--installarguments", "--install-arguments",
"-i", "--ignoredependencies", "--ignore-dependencies",
"-x", "--forcedependencies", "--force-dependencies",
"-m", "--sxs", "--sidebyside", "--side-by-side",
"--allowmultiple", "--allow-multiple", "--allowmultipleversions", "--allow-multiple-versions",
"-n", "--skippowershell", "--skip-powershell",
"--notsilent", "--not-silent",
"-o", "--override", "--overrideargs", "--overridearguments", "--override-arguments",
"--params", "--parameters", "--pkgparameters", "--packageparameters", "--package-parameters",
"--pre", "--prerelease",
"-s" .. parser({"ruby", "webpi", "cygwin", "windowsfeatures", "python"}),
"--source" .. parser({"ruby", "webpi", "cygwin", "windowsfeatures", "python"}),
"--version",
"--x86", "--forcex86",
"-u", "--user",
"-p", "--password")
local cuninst_parser = parser({packages},
"-a", "--all", "--allversions", "--all-versions",
"-x", "--forcedependencies", "--force-dependencies",
"--ia", "--installargs", "--installarguments", "--install-arguments",
"-n", "--skippowershell", "--skip-powershell",
"--notsilent", "--not-silent",
"-o", "--override", "--overrideargs", "--overridearguments", "--override-arguments",
"--params", "--parameters", "--pkgparameters", "--packageparameters", "--package-parameters",
"--version")
local cup_parser = parser(
--TODO: complete locally installed packages
{packages, "all"},
"--ia", "--installargs", "--installarguments", "--install-arguments",
"-i", "--ignoredependencies", "--ignore-dependencies",
"-m", "--sxs", "--sidebyside", "--side-by-side",
"--allowmultiple", "--allow-multiple", "--allowmultipleversions", "--allow-multiple-versions",
"-n", "--skippowershell", "--skip-powershell",
"--notsilent", "--not-silent",
"-o", "--override", "--overrideargs", "--overridearguments", "--override-arguments",
"--params", "--parameters", "--pkgparameters", "--packageparameters", "--package-parameters",
"--pre", "--prerelease",
"-s" .. parser({"ruby", "webpi", "cygwin", "windowsfeatures", "python"}),
"--source" .. parser({"ruby", "webpi", "cygwin", "windowsfeatures", "python"}),
"--version",
"--x86", "--forcex86",
"-u", "--user",
"-p", "--password"):loop(1)
local sources_parser = parser({
"add"..parser(
"-n", "--name",
"-u", "--user",
"-p", "--password",
"-s", "-source"),
"disable"..parser("-n", "--name"),
"enable"..parser("-n", "--name"),
"list",
"remove"..parser("-n", "--name")})
local chocolatey_parser = parser({
--TODO: https://github.com/chocolatey/choco/wiki/CommandsReference
-- Default Options and Switches
-- new - generates files necessary for a Chocolatey package
-- pack - packages up a nuspec to a compiled nupkg
-- push - pushes a compiled nupkg
"apikey"..parser("-s", "--source", "-k", "--key", "--apikey", "--api-key"),
"setapikey"..parser("-s", "--source", "-k", "--key", "--apikey", "--api-key"),
"feature"..parser({
"list",
"disable"..parser("-n", "--name"),
"enable"..parser("-n", "--name")
}),
"install"..cinst_parser,
"list"..clist_parser,
"outdated"..parser(
"-s", "--source",
"-u", "--user",
"-p", "--password"),
"pin"..parser({"add", "remove", "list"}, "-n", "--name", "--version"),
"source"..sources_parser,
"sources"..sources_parser,
"search"..clist_parser,
"upgrade"..cup_parser,
"uninstall"..cuninst_parser
}, "/?")
clink.arg.register_parser("choco", chocolatey_parser)
clink.arg.register_parser("chocolatey", chocolatey_parser)
clink.arg.register_parser("cinst", cinst_parser)
clink.arg.register_parser("clist", clist_parser)
clink.arg.register_parser("cuninst", cuninst_parser)
clink.arg.register_parser("cup", cup_parser)