-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathttop.nim
66 lines (58 loc) · 1.35 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
58
59
60
61
62
63
64
65
import ttop/tui
import ttop/blog
import ttop/onoff
import ttop/triggers
import strutils
import os
const NimblePkgVersion {.strdefine.} = "Unknown"
const Help = """
ttop - system monitoring tool with TUI and historical data service
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
-v, --version version number (""" & NimblePkgVersion & """)
"""
proc main() =
try:
case paramCount():
of 0:
tui()
of 1:
case paramStr(1)
of "-h", "--help":
echo Help
of "-s", "--save":
smtpSave save()
of "--on":
onoff(true)
of "--off":
onoff(false)
of "-v", "--version":
echo NimblePkgVersion
else:
when defined(debug):
if paramStr(1) == "--colors":
colors()
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, Defect:
let ex = getCurrentException()
echo ex.msg
echo ex.getStackTrace()
quit 1
when isMainModule:
main()