forked from vladimir-kotikov/clink-completions
-
Notifications
You must be signed in to change notification settings - Fork 3
/
net.lua
84 lines (76 loc) · 2.24 KB
/
net.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
local clink_version = require('clink_version')
local function args(...)
if clink_version.new_api then
return clink.argmatcher()
:addflags("/?")
:addarg(...)
:addarg()
:nofiles()
:loop()
else
return clink.arg.new_parser({...}, "/?")
end
end
local function flags(...)
if clink_version.new_api then
return clink.argmatcher()
:addflags("/?", ...)
:addarg({})
:loop()
else
return clink.arg.new_parser("/?", ...)
end
end
local function flagsnofiles(...)
if clink_version.new_api then
return flags(...):nofiles()
else
return clink.arg.new_parser({}, "/?", ...)
end
end
local helpflag = flagsnofiles()
local time_parser
if clink_version.new_api then
time_parser = clink.argmatcher()
:addflags("/domain", "/domain:", "/rtsdomain", "/rtsdomain:", "/set", "/?")
:addarg({})
:loop()
else
time_parser = flags("/domain", "/rtsdomain", "/set", "/?")
end
local net_table =
{
"accounts" .. flags("/forcelogoff:", "/forcelogoff:no", "/domain",
"/maxpwage:", "/maxpwage:unlimited", "/minpwage:",
"/minpwlen:","/uniquepw:"),
"computer" .. args("*" .. flagsnofiles("/add", "/del")),
"config" .. args("server", "workstation"),
"continue" .. helpflag,
"file" .. helpflag,
"group" .. helpflag,
"helpmsg" .. helpflag,
"localgroup" .. helpflag,
"pause" .. helpflag,
"session" .. flags("/delete", "/list"),
"share" .. helpflag,
"start" .. helpflag,
"statistics" .. args("server", "workstation"),
"stop" .. helpflag,
"time" .. time_parser,
"use" .. flags("/user:", "/smartcard", "/savecred", "/delete",
"/persistent:yes", "/persistent:no"),
"user" .. helpflag,
"view" .. flags("/cache", "/all", "/domain")
}
local help_table =
{
"help" .. args(net_table, "names", "services", "syntax")
}
if clink_version.new_api then
clink.argmatcher("net")
:addflags("/?")
:addarg(net_table, help_table)
else
clink.arg.register_parser("net", clink.arg.new_parser(net_table), "/?")
clink.arg.register_parser("net", clink.arg.new_parser(help_table))
end