-
Notifications
You must be signed in to change notification settings - Fork 83
/
net.lua
89 lines (80 loc) · 2.39 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
85
86
87
88
89
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 use_flags = flags("/user:", "/u:", "/smartcard", "/savecred", "/delete", "/d",
"/persistent:yes", "/p:yes", "/persistent:no", "/p:no")
if use_flags.hideflags then
use_flags:hideflags("/u:", "/d", "/p:yes", "/p:no")
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" .. use_flags,
"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