serverwatcher 6.dev14__py3-none-any.whl → 6.dev16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- serverwatcher/__main__.py +5 -5
- serverwatcher/livecli.py +108 -77
- serverwatcher/watchercli.py +91 -136
- {serverwatcher-6.dev14.dist-info → serverwatcher-6.dev16.dist-info}/METADATA +1 -1
- {serverwatcher-6.dev14.dist-info → serverwatcher-6.dev16.dist-info}/RECORD +8 -8
- {serverwatcher-6.dev14.dist-info → serverwatcher-6.dev16.dist-info}/WHEEL +0 -0
- {serverwatcher-6.dev14.dist-info → serverwatcher-6.dev16.dist-info}/licenses/LICENSE +0 -0
- {serverwatcher-6.dev14.dist-info → serverwatcher-6.dev16.dist-info}/top_level.txt +0 -0
serverwatcher/__main__.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
from mapres import rprint, setGlobalMaps, ascii_colors
|
|
2
1
|
import time
|
|
3
2
|
import asyncio
|
|
4
3
|
import threading
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
from mapres import rprint, setGlobalMaps, ascii_colors
|
|
6
6
|
|
|
7
7
|
from hungerlib.validator import (
|
|
8
8
|
ValidationError,
|
|
@@ -14,12 +14,12 @@ from hungerlib.validator import (
|
|
|
14
14
|
|
|
15
15
|
from .watcher import ServerWatcher
|
|
16
16
|
from .validator import validate_all
|
|
17
|
+
from .watchercli import WatcherCLI
|
|
17
18
|
|
|
18
19
|
|
|
19
|
-
# mapres setup
|
|
20
20
|
setGlobalMaps(ascii_colors)
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
def pretty_report(report: str) -> str:
|
|
24
24
|
lines = report.splitlines()
|
|
25
25
|
out = []
|
|
@@ -43,7 +43,7 @@ def pretty_report(report: str) -> str:
|
|
|
43
43
|
out.append(line)
|
|
44
44
|
return '\n'.join(out)
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
def main():
|
|
48
48
|
try:
|
|
49
49
|
validate_all()
|
serverwatcher/livecli.py
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
# livecli.py
|
|
2
|
-
|
|
3
1
|
from dataclasses import dataclass
|
|
2
|
+
import cmd
|
|
3
|
+
import sys
|
|
4
|
+
import termios
|
|
5
|
+
import tty
|
|
6
|
+
import asyncio
|
|
7
|
+
|
|
8
|
+
# ---------------------------------------------------------------------------
|
|
9
|
+
# DSL core
|
|
10
|
+
# ---------------------------------------------------------------------------
|
|
4
11
|
|
|
5
|
-
|
|
6
|
-
COMMANDS: dict[str, "CommandSpec"] = {}
|
|
12
|
+
COMMANDS: dict[str, 'CommandSpec'] = {}
|
|
7
13
|
|
|
8
14
|
|
|
9
15
|
@dataclass
|
|
@@ -11,11 +17,13 @@ class ParamSpec:
|
|
|
11
17
|
name: str
|
|
12
18
|
type_: type
|
|
13
19
|
default: object
|
|
20
|
+
func: callable
|
|
14
21
|
|
|
15
22
|
|
|
16
23
|
@dataclass
|
|
17
24
|
class FlagSpec:
|
|
18
25
|
name: str
|
|
26
|
+
func: callable
|
|
19
27
|
|
|
20
28
|
|
|
21
29
|
class ChildSpec:
|
|
@@ -23,15 +31,15 @@ class ChildSpec:
|
|
|
23
31
|
self,
|
|
24
32
|
name,
|
|
25
33
|
func,
|
|
26
|
-
requires_children=False,
|
|
27
|
-
requires_arguments=False,
|
|
28
|
-
requires_params=False,
|
|
29
|
-
requires_flags=False,
|
|
30
|
-
has_arguments=False,
|
|
34
|
+
requires_children: bool = False,
|
|
35
|
+
requires_arguments: bool = False,
|
|
36
|
+
requires_params: bool = False,
|
|
37
|
+
requires_flags: bool = False,
|
|
38
|
+
has_arguments: bool = False,
|
|
31
39
|
):
|
|
32
40
|
if has_arguments and requires_children:
|
|
33
41
|
raise ValueError(
|
|
34
|
-
f
|
|
42
|
+
f'Child \'{name}\' cannot both have arguments and require children'
|
|
35
43
|
)
|
|
36
44
|
|
|
37
45
|
self.name = name
|
|
@@ -42,23 +50,23 @@ class ChildSpec:
|
|
|
42
50
|
self.requires_flags = requires_flags
|
|
43
51
|
self.has_arguments = has_arguments
|
|
44
52
|
|
|
45
|
-
self.params = {}
|
|
46
|
-
self.flags = {}
|
|
47
|
-
self.children = {}
|
|
53
|
+
self.params: dict[str, ParamSpec] = {}
|
|
54
|
+
self.flags: dict[str, FlagSpec] = {}
|
|
55
|
+
self.children: dict[str, 'ChildSpec'] = {}
|
|
48
56
|
|
|
49
|
-
self.description = getattr(func,
|
|
57
|
+
self.description = getattr(func, '__description__', None)
|
|
50
58
|
|
|
51
59
|
def param(self, name, type=str, default=None):
|
|
52
60
|
def deco(func):
|
|
53
|
-
pyname = name.replace(
|
|
54
|
-
self.params[pyname] = ParamSpec(name, type, default)
|
|
61
|
+
pyname = name.replace('-', '_')
|
|
62
|
+
self.params[pyname] = ParamSpec(name, type, default, func)
|
|
55
63
|
return func
|
|
56
64
|
return deco
|
|
57
65
|
|
|
58
66
|
def flag(self, name):
|
|
59
67
|
def deco(func):
|
|
60
|
-
pyname = name.replace(
|
|
61
|
-
self.flags[pyname] = FlagSpec(name)
|
|
68
|
+
pyname = name.replace('-', '_')
|
|
69
|
+
self.flags[pyname] = FlagSpec(name, func)
|
|
62
70
|
return func
|
|
63
71
|
return deco
|
|
64
72
|
|
|
@@ -95,9 +103,26 @@ class CommandSpec:
|
|
|
95
103
|
self.requires_flags = requires_flags
|
|
96
104
|
self.has_arguments = has_arguments
|
|
97
105
|
|
|
98
|
-
self.children = {}
|
|
106
|
+
self.children: dict[str, ChildSpec] = {}
|
|
107
|
+
self.params: dict[str, ParamSpec] = {}
|
|
108
|
+
self.flags: dict[str, FlagSpec] = {}
|
|
109
|
+
|
|
99
110
|
self.description = getattr(func, "__description__", None)
|
|
100
111
|
|
|
112
|
+
def param(self, name, type=str, default=None):
|
|
113
|
+
def deco(func):
|
|
114
|
+
pyname = name.replace("-", "_")
|
|
115
|
+
self.params[pyname] = ParamSpec(name, type, default, func)
|
|
116
|
+
return func
|
|
117
|
+
return deco
|
|
118
|
+
|
|
119
|
+
def flag(self, name):
|
|
120
|
+
def deco(func):
|
|
121
|
+
pyname = name.replace("-", "_")
|
|
122
|
+
self.flags[pyname] = FlagSpec(name, func)
|
|
123
|
+
return func
|
|
124
|
+
return deco
|
|
125
|
+
|
|
101
126
|
def child(self, name, **meta):
|
|
102
127
|
def deco(func):
|
|
103
128
|
child = ChildSpec(name, func, **meta)
|
|
@@ -107,6 +132,7 @@ class CommandSpec:
|
|
|
107
132
|
return deco
|
|
108
133
|
|
|
109
134
|
|
|
135
|
+
|
|
110
136
|
class CommandDSL:
|
|
111
137
|
def __call__(self, name, **meta):
|
|
112
138
|
def deco(func):
|
|
@@ -119,39 +145,38 @@ class CommandDSL:
|
|
|
119
145
|
command = CommandDSL()
|
|
120
146
|
|
|
121
147
|
|
|
122
|
-
#
|
|
123
|
-
#
|
|
124
|
-
#
|
|
148
|
+
# ---------------------------------------------------------------------------
|
|
149
|
+
# Help generation
|
|
150
|
+
# ---------------------------------------------------------------------------
|
|
125
151
|
|
|
126
152
|
def generate_help(cmd: CommandSpec) -> str:
|
|
127
|
-
lines = []
|
|
128
|
-
|
|
129
|
-
lines.append(f"{cmd.name}: {cmd.description or 'No description'}")
|
|
153
|
+
lines: list[str] = []
|
|
154
|
+
lines.append(f'{cmd.name}: {cmd.description or 'No description'}')
|
|
130
155
|
|
|
131
156
|
if cmd.children:
|
|
132
|
-
lines.append(
|
|
133
|
-
lines.append(
|
|
157
|
+
lines.append('')
|
|
158
|
+
lines.append('Children:')
|
|
134
159
|
for cname, child in cmd.children.items():
|
|
135
|
-
lines.append(f
|
|
160
|
+
lines.append(f' {cname}: {child.description or 'No description'}')
|
|
136
161
|
|
|
137
162
|
if child.params:
|
|
138
|
-
lines.append(
|
|
163
|
+
lines.append(' Params:')
|
|
139
164
|
for pname, pspec in child.params.items():
|
|
140
165
|
lines.append(
|
|
141
|
-
f
|
|
166
|
+
f' {pname} (CLI: {pspec.name}, type={pspec.type_.__name__}, default={pspec.default})'
|
|
142
167
|
)
|
|
143
168
|
|
|
144
169
|
if child.flags:
|
|
145
|
-
lines.append(
|
|
170
|
+
lines.append(' Flags:')
|
|
146
171
|
for fname, fspec in child.flags.items():
|
|
147
|
-
lines.append(f
|
|
172
|
+
lines.append(f' --{fspec.name}')
|
|
148
173
|
|
|
149
|
-
return
|
|
174
|
+
return '\n'.join(lines)
|
|
150
175
|
|
|
151
176
|
|
|
152
|
-
#
|
|
153
|
-
#
|
|
154
|
-
#
|
|
177
|
+
# ---------------------------------------------------------------------------
|
|
178
|
+
# Parsing + dispatch
|
|
179
|
+
# ---------------------------------------------------------------------------
|
|
155
180
|
|
|
156
181
|
@dataclass
|
|
157
182
|
class ParsedArgs:
|
|
@@ -168,15 +193,15 @@ def parse_line(raw: str) -> ParsedArgs:
|
|
|
168
193
|
|
|
169
194
|
parts = raw.split()
|
|
170
195
|
sub = parts[0]
|
|
171
|
-
positional = []
|
|
172
|
-
flags = {}
|
|
173
|
-
params = {}
|
|
196
|
+
positional: list[str] = []
|
|
197
|
+
flags: dict[str, bool] = {}
|
|
198
|
+
params: dict[str, str] = {}
|
|
174
199
|
|
|
175
200
|
for token in parts[1:]:
|
|
176
|
-
if token.startswith(
|
|
201
|
+
if token.startswith('--'):
|
|
177
202
|
flags[token[2:]] = True
|
|
178
|
-
elif
|
|
179
|
-
key, value = token.split(
|
|
203
|
+
elif ':' in token:
|
|
204
|
+
key, value = token.split(':', 1)
|
|
180
205
|
params[key.lower()] = value
|
|
181
206
|
else:
|
|
182
207
|
positional.append(token)
|
|
@@ -191,82 +216,88 @@ def dispatch(cli, line: str):
|
|
|
191
216
|
|
|
192
217
|
cmd = COMMANDS.get(parsed.subcommand)
|
|
193
218
|
if cmd is None:
|
|
194
|
-
return cli.safePrint(f
|
|
219
|
+
return cli.safePrint(f'Unknown command \'{parsed.subcommand}\'')
|
|
195
220
|
|
|
196
221
|
if cmd.requires_children and not cmd.children:
|
|
197
|
-
return cli.safePrint(f
|
|
222
|
+
return cli.safePrint(f'Command \'{cmd.name}\' requires children')
|
|
198
223
|
|
|
199
224
|
cmd.func()
|
|
200
225
|
|
|
201
226
|
if not parsed.positional:
|
|
202
227
|
if cmd.requires_arguments:
|
|
203
|
-
return cli.safePrint(f
|
|
204
|
-
return cli.safePrint(
|
|
228
|
+
return cli.safePrint(f'Command \'{cmd.name}\' requires an argument')
|
|
229
|
+
return cli.safePrint('Missing subcommand')
|
|
205
230
|
|
|
206
231
|
child_name = parsed.positional[0]
|
|
207
232
|
child = cmd.children.get(child_name)
|
|
208
233
|
if child is None:
|
|
209
|
-
return cli.safePrint(f
|
|
234
|
+
return cli.safePrint(f'Unknown subcommand \'{child_name}\'')
|
|
210
235
|
|
|
211
236
|
arg = parsed.positional[1] if len(parsed.positional) > 1 else None
|
|
212
237
|
|
|
213
238
|
if child.requires_arguments and arg is None:
|
|
214
|
-
return cli.safePrint(f
|
|
239
|
+
return cli.safePrint(f'Subcommand \'{child.name}\' requires an argument')
|
|
215
240
|
|
|
216
|
-
|
|
241
|
+
# Inject param/flag functions into child.func globals
|
|
242
|
+
g = child.func.__globals__
|
|
217
243
|
|
|
244
|
+
# Params: use provided value or default, then call original func(value)
|
|
218
245
|
for pname, pspec in child.params.items():
|
|
219
246
|
if pname in parsed.params:
|
|
220
|
-
|
|
247
|
+
raw_value = parsed.params[pname]
|
|
248
|
+
try:
|
|
249
|
+
converted = pspec.type_(raw_value)
|
|
250
|
+
except Exception:
|
|
251
|
+
converted = pspec.default
|
|
252
|
+
else:
|
|
253
|
+
converted = pspec.default
|
|
221
254
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return pspec.default
|
|
255
|
+
def make_param_func(func=pspec.func, value=converted):
|
|
256
|
+
def wrapper():
|
|
257
|
+
return func(value)
|
|
258
|
+
return wrapper
|
|
227
259
|
|
|
228
|
-
|
|
229
|
-
else:
|
|
230
|
-
wrappers[pname] = lambda pspec=pspec: pspec.default
|
|
260
|
+
g[pname] = make_param_func()
|
|
231
261
|
|
|
232
|
-
|
|
262
|
+
# Flags: presence → True, absence → False
|
|
263
|
+
for fname, fspec in child.flags.items():
|
|
233
264
|
present = fname in parsed.flags
|
|
234
|
-
wrappers[fname] = lambda present=present: present
|
|
235
265
|
|
|
236
|
-
|
|
266
|
+
def make_flag_func(func=fspec.func, present=present):
|
|
267
|
+
def wrapper():
|
|
268
|
+
return present
|
|
269
|
+
return wrapper
|
|
237
270
|
|
|
271
|
+
g[fname] = make_flag_func()
|
|
238
272
|
|
|
239
|
-
|
|
240
|
-
# BASE LiveCLI (reusable)
|
|
241
|
-
# -------------------------
|
|
273
|
+
return child.func(cli, arg)
|
|
242
274
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
import asyncio
|
|
275
|
+
|
|
276
|
+
# ---------------------------------------------------------------------------
|
|
277
|
+
# Base LiveCLI
|
|
278
|
+
# ---------------------------------------------------------------------------
|
|
248
279
|
|
|
249
280
|
class LiveCLI(cmd.Cmd):
|
|
250
|
-
prompt =
|
|
281
|
+
prompt = ''
|
|
251
282
|
|
|
252
|
-
def safePrint(self, msg=
|
|
283
|
+
def safePrint(self, msg: object = '', end: str = '\n') -> None:
|
|
253
284
|
print(str(msg), end=end)
|
|
254
285
|
|
|
255
|
-
def bprint(self, msg):
|
|
286
|
+
def bprint(self, msg: object) -> None:
|
|
256
287
|
self.safePrint(msg)
|
|
257
288
|
|
|
258
|
-
def read_line_raw(self):
|
|
289
|
+
def read_line_raw(self) -> str:
|
|
259
290
|
fd = sys.stdin.fileno()
|
|
260
291
|
old = termios.tcgetattr(fd)
|
|
261
292
|
try:
|
|
262
293
|
tty.setraw(fd)
|
|
263
|
-
chars = []
|
|
294
|
+
chars: list[str] = []
|
|
264
295
|
while True:
|
|
265
296
|
ch = sys.stdin.read(1)
|
|
266
|
-
if ch in (
|
|
297
|
+
if ch in ('\r', '\n'):
|
|
267
298
|
break
|
|
268
299
|
chars.append(ch)
|
|
269
|
-
return
|
|
300
|
+
return ''.join(chars)
|
|
270
301
|
finally:
|
|
271
302
|
termios.tcsetattr(fd, termios.TCSADRAIN, old)
|
|
272
303
|
|
|
@@ -280,5 +311,5 @@ class LiveCLI(cmd.Cmd):
|
|
|
280
311
|
if stop:
|
|
281
312
|
break
|
|
282
313
|
|
|
283
|
-
def onecmd(self, line):
|
|
314
|
+
def onecmd(self, line: str):
|
|
284
315
|
return dispatch(self, line)
|
serverwatcher/watchercli.py
CHANGED
|
@@ -1,198 +1,153 @@
|
|
|
1
|
-
# watchercli.py
|
|
2
|
-
|
|
3
|
-
from .livecli import (
|
|
4
|
-
LiveCLI,
|
|
5
|
-
command,
|
|
6
|
-
COMMANDS,
|
|
7
|
-
generate_help,
|
|
8
|
-
)
|
|
9
1
|
from hungerlib import utils
|
|
10
|
-
from mapres import res,
|
|
2
|
+
from mapres import res, ascii_colors, setGlobalMaps
|
|
11
3
|
from .watcher import ServerWatcher
|
|
4
|
+
from .livecli import LiveCLI, command
|
|
12
5
|
|
|
13
|
-
setGlobalMaps(
|
|
6
|
+
setGlobalMaps(ascii_colors)
|
|
14
7
|
|
|
15
8
|
|
|
16
|
-
# -------------------------
|
|
17
|
-
# WatcherCLI
|
|
18
|
-
# -------------------------
|
|
19
|
-
|
|
20
9
|
class WatcherCLI(LiveCLI):
|
|
21
10
|
def __init__(self, watcher: ServerWatcher):
|
|
22
11
|
super().__init__()
|
|
23
12
|
self.watcher = watcher
|
|
24
13
|
self.buffer = utils.Buffer(enabled=True)
|
|
25
|
-
self.outputMode =
|
|
14
|
+
self.outputMode = 'both'
|
|
26
15
|
|
|
27
|
-
def printHeader(self):
|
|
28
|
-
self.safePrint(res(
|
|
29
|
-
self.safePrint(res(
|
|
30
|
-
self.safePrint(res(
|
|
31
|
-
self.safePrint(
|
|
16
|
+
def printHeader(self) -> None:
|
|
17
|
+
self.safePrint(res('<yellow>-----------------------------------'))
|
|
18
|
+
self.safePrint(res('<yellow>-------- <aqua>ServerWatcher CLI <yellow>--------'))
|
|
19
|
+
self.safePrint(res('<yellow>-----------------------------------'))
|
|
20
|
+
self.safePrint('\n')
|
|
32
21
|
|
|
33
22
|
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
23
|
+
# ---------------------------------------------------------------------------
|
|
24
|
+
# stats command
|
|
25
|
+
# ---------------------------------------------------------------------------
|
|
37
26
|
|
|
38
|
-
@command(
|
|
27
|
+
@command('stats', requires_children=True)
|
|
39
28
|
def stats():
|
|
40
|
-
__description__ =
|
|
41
|
-
|
|
29
|
+
__description__ = 'Retrieve and print server statistics'
|
|
42
30
|
|
|
43
|
-
@stats.child("get", requires_arguments=False)
|
|
44
|
-
def stats_get(self: WatcherCLI, arg=None, **kwargs):
|
|
45
|
-
__description__ = "Retrieve and print all or specific server statistics"
|
|
46
31
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
formatted = kwargs["formatted"]
|
|
51
|
-
no_formatted = kwargs["no_formatted"]
|
|
32
|
+
@stats.child('get', requires_arguments=False)
|
|
33
|
+
def stats_get(self, arg=None):
|
|
34
|
+
__description__ = 'Retrieve and print all or specific server statistics'
|
|
52
35
|
|
|
53
36
|
self.watcher.server.refresh()
|
|
54
37
|
|
|
55
|
-
if arg is None:
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
38
|
+
if arg is not None:
|
|
39
|
+
gb = not raw()
|
|
40
|
+
if formatted():
|
|
41
|
+
fmt = True
|
|
42
|
+
elif no_formatted():
|
|
43
|
+
fmt = False
|
|
44
|
+
else:
|
|
45
|
+
fmt = True
|
|
46
|
+
|
|
47
|
+
unit = ''
|
|
48
|
+
match arg:
|
|
49
|
+
case 'ram':
|
|
50
|
+
value = self.watcher.server.getRAM(rounding=rounding(), gb=gb)
|
|
51
|
+
name = 'RAM'
|
|
52
|
+
unit = ' GB' if gb else ' MB'
|
|
53
|
+
case 'cpu':
|
|
54
|
+
value = self.watcher.server.getCPU(rounding=rounding())
|
|
55
|
+
name = 'CPU'
|
|
56
|
+
unit = '%'
|
|
57
|
+
case 'uptime':
|
|
58
|
+
value = self.watcher.server.getUptime(formatted=fmt)
|
|
59
|
+
name = 'Uptime'
|
|
60
|
+
unit = '' if fmt else 'ms'
|
|
61
|
+
case 'tps':
|
|
62
|
+
value = self.watcher.server.getTPS(rounding=rounding(), mode=mode())
|
|
63
|
+
name = 'TPS'
|
|
64
|
+
case 'players':
|
|
65
|
+
value = self.watcher.server.getPlayers()
|
|
66
|
+
name = 'Players'
|
|
67
|
+
case 'version':
|
|
68
|
+
value = self.watcher.server.version
|
|
69
|
+
name = 'Minecraft version'
|
|
70
|
+
case 'platform':
|
|
71
|
+
value = self.watcher.server.platform
|
|
72
|
+
name = 'Server platform'
|
|
73
|
+
case _:
|
|
74
|
+
return self.safePrint('Unknown stat')
|
|
75
|
+
|
|
76
|
+
self.bprint(f'{name}: {value}{unit}')
|
|
77
|
+
else:
|
|
78
|
+
return # later: print all stats for `stats get`
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@stats.get.param('rounding', type=int, default=2)
|
|
82
|
+
def rounding(value: int):
|
|
83
|
+
__description__ = 'placeholder'
|
|
95
84
|
return value
|
|
96
85
|
|
|
97
86
|
|
|
98
|
-
@stats.get.param(
|
|
99
|
-
def mode(value):
|
|
87
|
+
@stats.get.param('mode', type=str, default='current')
|
|
88
|
+
def mode(value: str):
|
|
100
89
|
return value
|
|
101
90
|
|
|
102
91
|
|
|
103
|
-
@stats.get.flag(
|
|
92
|
+
@stats.get.flag('raw')
|
|
104
93
|
def raw():
|
|
105
|
-
|
|
94
|
+
__description__ = 'placeholder'
|
|
95
|
+
return True # DSL overrides with presence/absence
|
|
106
96
|
|
|
107
97
|
|
|
108
|
-
@stats.get.flag(
|
|
98
|
+
@stats.get.flag('formatted')
|
|
109
99
|
def formatted():
|
|
110
|
-
return True
|
|
100
|
+
return True # DSL overrides with presence/absence
|
|
111
101
|
|
|
112
102
|
|
|
113
|
-
@stats.get.flag(
|
|
103
|
+
@stats.get.flag('no-formatted')
|
|
114
104
|
def no_formatted():
|
|
115
|
-
return False
|
|
105
|
+
return False # DSL overrides with presence/absence
|
|
116
106
|
|
|
117
107
|
|
|
118
|
-
#
|
|
108
|
+
# ---------------------------------------------------------------------------
|
|
119
109
|
# view command
|
|
120
|
-
#
|
|
110
|
+
# ---------------------------------------------------------------------------
|
|
121
111
|
|
|
122
|
-
@command(
|
|
112
|
+
@command('view', requires_children=True)
|
|
123
113
|
def view():
|
|
124
|
-
__description__ =
|
|
114
|
+
__description__ = 'Switch terminal view'
|
|
125
115
|
|
|
126
116
|
|
|
127
|
-
@view.child(
|
|
128
|
-
def view_cli(self
|
|
129
|
-
__description__ =
|
|
117
|
+
@view.child('cli')
|
|
118
|
+
def view_cli(self):
|
|
119
|
+
__description__ = 'Switch to CLI view'
|
|
130
120
|
|
|
131
121
|
self.watcher.router.disableOriginOutput()
|
|
132
|
-
self.outputMode =
|
|
122
|
+
self.outputMode = 'cli'
|
|
123
|
+
self.buffer.enabled = True
|
|
133
124
|
utils.clearTerminal()
|
|
134
125
|
self.printHeader()
|
|
135
126
|
for msg in self.buffer.captured:
|
|
136
127
|
self.safePrint(msg)
|
|
137
128
|
|
|
138
129
|
|
|
139
|
-
@view.child(
|
|
140
|
-
def view_watcher(self
|
|
141
|
-
__description__ =
|
|
130
|
+
@view.child('watcher')
|
|
131
|
+
def view_watcher(self):
|
|
132
|
+
__description__ = 'Switch to Watcher view'
|
|
142
133
|
|
|
143
134
|
self.watcher.router.enableOriginOutput()
|
|
144
|
-
self.outputMode =
|
|
135
|
+
self.outputMode = 'both'
|
|
145
136
|
utils.clearTerminal()
|
|
146
137
|
self.printHeader()
|
|
147
138
|
for msg in self.watcher.router.buffer.captured:
|
|
148
139
|
self.safePrint(msg)
|
|
149
140
|
|
|
150
141
|
|
|
151
|
-
#
|
|
142
|
+
# ---------------------------------------------------------------------------
|
|
152
143
|
# clear command
|
|
153
|
-
#
|
|
144
|
+
# ---------------------------------------------------------------------------
|
|
154
145
|
|
|
155
|
-
@command(
|
|
146
|
+
@command('clear')
|
|
156
147
|
def clear():
|
|
157
|
-
__description__ =
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
@clear.child("buffer")
|
|
161
|
-
def clear_buffer(self: WatcherCLI, arg=None, **kwargs):
|
|
162
|
-
__description__ = "Clear or keep the CLI buffer"
|
|
163
|
-
|
|
164
|
-
no_buffer = kwargs["no_buffer"]
|
|
165
|
-
|
|
166
|
-
if not no_buffer():
|
|
167
|
-
self.buffer.clear()
|
|
168
|
-
|
|
169
|
-
utils.clearTerminal()
|
|
170
|
-
self.printHeader()
|
|
148
|
+
__description__ = 'Clear the CLI terminal'
|
|
171
149
|
|
|
172
150
|
|
|
173
|
-
@
|
|
151
|
+
@clear.flag('no-buffer')
|
|
174
152
|
def no_buffer():
|
|
175
|
-
return
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
# -------------------------
|
|
179
|
-
# help command
|
|
180
|
-
# -------------------------
|
|
181
|
-
|
|
182
|
-
@command("help", requires_arguments=True)
|
|
183
|
-
def help():
|
|
184
|
-
__description__ = "Show help for a command"
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
@help.child("command", requires_arguments=True)
|
|
188
|
-
def help_command(self: WatcherCLI, cmd_name=None, **kwargs):
|
|
189
|
-
__description__ = "Show help for a specific command"
|
|
190
|
-
|
|
191
|
-
if cmd_name is None:
|
|
192
|
-
return self.safePrint("Usage: help command <name>")
|
|
193
|
-
|
|
194
|
-
cmd = COMMANDS.get(cmd_name)
|
|
195
|
-
if not cmd:
|
|
196
|
-
return self.safePrint(f"Unknown command '{cmd_name}'")
|
|
197
|
-
|
|
198
|
-
self.safePrint(generate_help(cmd))
|
|
153
|
+
return False # DSL overrides with presence/absence
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
serverwatcher/__init__.py,sha256=Q_afN0XU29n48d6Gf0-LT2lLo3RiTWlHRT6rC_fYbjw,486
|
|
2
|
-
serverwatcher/__main__.py,sha256=
|
|
2
|
+
serverwatcher/__main__.py,sha256=5geaZQKgLSP1pxnpQPgFy9zAwyyPyTInlbcFxb9OiEw,3016
|
|
3
3
|
serverwatcher/cli.py,sha256=b77rWfjQuqHiRGaVQj-O5EygJGdufMasRBUUqKcasAM,9887
|
|
4
|
-
serverwatcher/livecli.py,sha256=
|
|
4
|
+
serverwatcher/livecli.py,sha256=On5uuXXbX-jbHkIYpmg56pwDV1T6fipsRVvS3uvjvxc,9044
|
|
5
5
|
serverwatcher/validator.py,sha256=aD6GHOz1S5VFC93Mj89WO9vZG1bTjhg7QZbdlvQf4wo,1778
|
|
6
6
|
serverwatcher/watcher.py,sha256=ZiocJpeyhKTGOwYYak36MXNEFpLnpdl9v6BnMPGrBmM,13593
|
|
7
|
-
serverwatcher/watchercli.py,sha256=
|
|
7
|
+
serverwatcher/watchercli.py,sha256=xJGtwT2x67P0ql-v2uIYnbYfzPuPlf-Nx_oE1XN6qkQ,4394
|
|
8
8
|
serverwatcher/configclasses/__init__.py,sha256=YS0KhxtAJGdMcaiFstqTRNxIPLnR7s9v3Tkt5h2uKE4,182
|
|
9
9
|
serverwatcher/configclasses/config.py,sha256=1Upor55QFE4UIOqL9ZYa4U5kbda48GG9HWdRXg8mb_Y,2418
|
|
10
10
|
serverwatcher/configclasses/messages.py,sha256=iOkCvwagngW4aeWD5I6hi6cqqDkzEsFJsLHSuqK-P1s,3467
|
|
@@ -14,8 +14,8 @@ serverwatcher/defaultconfigs/messages.yaml,sha256=jSVEl-RYqPHhe5U5KLl8zfJtUBymvy
|
|
|
14
14
|
serverwatcher/defaultconfigs/watcher.yaml,sha256=GlAEKCuzFUSF6wWOqQLFL1CeuPltb1ltfYxFe_FUClw,723
|
|
15
15
|
serverwatcher/tests/test.py,sha256=EPJXmIJ4lLfuT-xFuAqrh52O_yYTQdQl17Djzr72v18,3711
|
|
16
16
|
serverwatcher/tests/test2.py,sha256=pDFB3LTZZXdrkofCF9tDGlkUzNXq3AzK225Ww6H2EAw,1702
|
|
17
|
-
serverwatcher-6.
|
|
18
|
-
serverwatcher-6.
|
|
19
|
-
serverwatcher-6.
|
|
20
|
-
serverwatcher-6.
|
|
21
|
-
serverwatcher-6.
|
|
17
|
+
serverwatcher-6.dev16.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
18
|
+
serverwatcher-6.dev16.dist-info/METADATA,sha256=Yf6AL47n65FatpJ64jPTAd7I7ivVYyUN4EC9osHxYKs,2647
|
|
19
|
+
serverwatcher-6.dev16.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
20
|
+
serverwatcher-6.dev16.dist-info/top_level.txt,sha256=8DJAf8WmmglgtZHkp8aoTriRJ2YPcS4F3DfOIkytASo,14
|
|
21
|
+
serverwatcher-6.dev16.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|