-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdrcom.lua
More file actions
62 lines (53 loc) · 1.34 KB
/
drcom.lua
File metadata and controls
62 lines (53 loc) · 1.34 KB
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 lua
local drcom = require("cwnu-drcom.core")
local config = require("cwnu-drcom.config")
local function help()
print([[Usage: drcom [OPTIONS]
`cwnu-drcom` implement in lua and it provids a way to authenticate in command line.
OPTIONS:
-l: logoff.
-r: relogin.
-u: user name.
-p: password.
-n: the type of network, SNET(school net) or INET(internet)
-t: the type of logining, PC(personal computer) or MB(mobile phone)
-v: verbose
-h: show this page.]])
end
local function logoff()
end
local function relogin()
end
local login = drcom.login
local user = config.user
for i = 1, #arg do
if "-u" == arg[i] and i+1 <= #arg then
user.usr = arg[i+1]
elseif "-p" == arg[i] and i+1 <= #arg then
user.pwd = arg[i+1]
elseif "-n" == arg[i] and i+1 <= #arg then
user.net = arg[i+1]
elseif "-t" == arg[i] and i+1 <= #arg then
user.ispc = ("PC" == arg[i+1]) and "true" or "false"
elseif "-v" == arg[i] then
drcom.set_debug(true)
end
if "-h" == arg[i] then
help()
return 0
end
if "-l" == arg[i] then
logoff()
return 0
end
if "-r" == arg[i] then
relogin()
return 0
end
end
-- Login, START
if login(user) then
print("Login success!")
else
print("Login fail!")
end