-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathttop.nim
58 lines (53 loc) · 1.11 KB
/
ttop.nim
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
import ttop/tui
import ttop/blog
import ttop/onoff
import ttop/smtp
import strutils
import os
const Help = """
Usage:
run [optional-param]
Options:
-h, --help print this help
-s, --save save snapshot
--on enable system.timer (or cron) collector every 10 minutes
--on <number> enable system.timer (or cron) collector every <number> minutes
--off disable collector
--checksmtp send email (just to check configuration)
"""
proc main() =
try:
case paramCount():
of 0:
tui()
of 1:
case paramStr(1)
of "-h", "--help":
echo Help
of "-s", "--save":
smtpSend save()
of "--on":
onoff(true)
of "--off":
onoff(false)
of "--checksmtp":
smtpCheck()
else:
echo Help
quit 1
of 2:
if paramStr(1) == "--on":
onoff(true, parseUInt(paramStr(2)))
else:
echo Help
quit 1
else:
echo Help
quit 1
except CatchableError:
let ex = getCurrentException()
echo ex.msg
echo ex.getStackTrace()
quit 1
when isMainModule:
main()