serverwatcher 6.dev14__py3-none-any.whl → 6.dev15__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 +97 -84
- serverwatcher/watchercli.py +91 -136
- {serverwatcher-6.dev14.dist-info → serverwatcher-6.dev15.dist-info}/METADATA +1 -1
- {serverwatcher-6.dev14.dist-info → serverwatcher-6.dev15.dist-info}/RECORD +8 -8
- {serverwatcher-6.dev14.dist-info → serverwatcher-6.dev15.dist-info}/WHEEL +0 -0
- {serverwatcher-6.dev14.dist-info → serverwatcher-6.dev15.dist-info}/licenses/LICENSE +0 -0
- {serverwatcher-6.dev14.dist-info → serverwatcher-6.dev15.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
|
|
4
7
|
|
|
5
|
-
#
|
|
6
|
-
|
|
8
|
+
# ---------------------------------------------------------------------------
|
|
9
|
+
# DSL core
|
|
10
|
+
# ---------------------------------------------------------------------------
|
|
11
|
+
|
|
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
|
|
|
@@ -76,15 +84,15 @@ class CommandSpec:
|
|
|
76
84
|
self,
|
|
77
85
|
name,
|
|
78
86
|
func,
|
|
79
|
-
requires_children=False,
|
|
80
|
-
requires_arguments=False,
|
|
81
|
-
requires_params=False,
|
|
82
|
-
requires_flags=False,
|
|
83
|
-
has_arguments=False,
|
|
87
|
+
requires_children: bool = False,
|
|
88
|
+
requires_arguments: bool = False,
|
|
89
|
+
requires_params: bool = False,
|
|
90
|
+
requires_flags: bool = False,
|
|
91
|
+
has_arguments: bool = False,
|
|
84
92
|
):
|
|
85
93
|
if has_arguments and requires_children:
|
|
86
94
|
raise ValueError(
|
|
87
|
-
f
|
|
95
|
+
f'Command \'{name}\' cannot both have arguments and require children'
|
|
88
96
|
)
|
|
89
97
|
|
|
90
98
|
self.name = name
|
|
@@ -95,8 +103,8 @@ class CommandSpec:
|
|
|
95
103
|
self.requires_flags = requires_flags
|
|
96
104
|
self.has_arguments = has_arguments
|
|
97
105
|
|
|
98
|
-
self.children = {}
|
|
99
|
-
self.description = getattr(func,
|
|
106
|
+
self.children: dict[str, ChildSpec] = {}
|
|
107
|
+
self.description = getattr(func, '__description__', None)
|
|
100
108
|
|
|
101
109
|
def child(self, name, **meta):
|
|
102
110
|
def deco(func):
|
|
@@ -119,39 +127,38 @@ class CommandDSL:
|
|
|
119
127
|
command = CommandDSL()
|
|
120
128
|
|
|
121
129
|
|
|
122
|
-
#
|
|
123
|
-
#
|
|
124
|
-
#
|
|
130
|
+
# ---------------------------------------------------------------------------
|
|
131
|
+
# Help generation
|
|
132
|
+
# ---------------------------------------------------------------------------
|
|
125
133
|
|
|
126
134
|
def generate_help(cmd: CommandSpec) -> str:
|
|
127
|
-
lines = []
|
|
128
|
-
|
|
129
|
-
lines.append(f"{cmd.name}: {cmd.description or 'No description'}")
|
|
135
|
+
lines: list[str] = []
|
|
136
|
+
lines.append(f'{cmd.name}: {cmd.description or 'No description'}')
|
|
130
137
|
|
|
131
138
|
if cmd.children:
|
|
132
|
-
lines.append(
|
|
133
|
-
lines.append(
|
|
139
|
+
lines.append('')
|
|
140
|
+
lines.append('Children:')
|
|
134
141
|
for cname, child in cmd.children.items():
|
|
135
|
-
lines.append(f
|
|
142
|
+
lines.append(f' {cname}: {child.description or 'No description'}')
|
|
136
143
|
|
|
137
144
|
if child.params:
|
|
138
|
-
lines.append(
|
|
145
|
+
lines.append(' Params:')
|
|
139
146
|
for pname, pspec in child.params.items():
|
|
140
147
|
lines.append(
|
|
141
|
-
f
|
|
148
|
+
f' {pname} (CLI: {pspec.name}, type={pspec.type_.__name__}, default={pspec.default})'
|
|
142
149
|
)
|
|
143
150
|
|
|
144
151
|
if child.flags:
|
|
145
|
-
lines.append(
|
|
152
|
+
lines.append(' Flags:')
|
|
146
153
|
for fname, fspec in child.flags.items():
|
|
147
|
-
lines.append(f
|
|
154
|
+
lines.append(f' --{fspec.name}')
|
|
148
155
|
|
|
149
|
-
return
|
|
156
|
+
return '\n'.join(lines)
|
|
150
157
|
|
|
151
158
|
|
|
152
|
-
#
|
|
153
|
-
#
|
|
154
|
-
#
|
|
159
|
+
# ---------------------------------------------------------------------------
|
|
160
|
+
# Parsing + dispatch
|
|
161
|
+
# ---------------------------------------------------------------------------
|
|
155
162
|
|
|
156
163
|
@dataclass
|
|
157
164
|
class ParsedArgs:
|
|
@@ -168,15 +175,15 @@ def parse_line(raw: str) -> ParsedArgs:
|
|
|
168
175
|
|
|
169
176
|
parts = raw.split()
|
|
170
177
|
sub = parts[0]
|
|
171
|
-
positional = []
|
|
172
|
-
flags = {}
|
|
173
|
-
params = {}
|
|
178
|
+
positional: list[str] = []
|
|
179
|
+
flags: dict[str, bool] = {}
|
|
180
|
+
params: dict[str, str] = {}
|
|
174
181
|
|
|
175
182
|
for token in parts[1:]:
|
|
176
|
-
if token.startswith(
|
|
183
|
+
if token.startswith('--'):
|
|
177
184
|
flags[token[2:]] = True
|
|
178
|
-
elif
|
|
179
|
-
key, value = token.split(
|
|
185
|
+
elif ':' in token:
|
|
186
|
+
key, value = token.split(':', 1)
|
|
180
187
|
params[key.lower()] = value
|
|
181
188
|
else:
|
|
182
189
|
positional.append(token)
|
|
@@ -191,82 +198,88 @@ def dispatch(cli, line: str):
|
|
|
191
198
|
|
|
192
199
|
cmd = COMMANDS.get(parsed.subcommand)
|
|
193
200
|
if cmd is None:
|
|
194
|
-
return cli.safePrint(f
|
|
201
|
+
return cli.safePrint(f'Unknown command \'{parsed.subcommand}\'')
|
|
195
202
|
|
|
196
203
|
if cmd.requires_children and not cmd.children:
|
|
197
|
-
return cli.safePrint(f
|
|
204
|
+
return cli.safePrint(f'Command \'{cmd.name}\' requires children')
|
|
198
205
|
|
|
199
206
|
cmd.func()
|
|
200
207
|
|
|
201
208
|
if not parsed.positional:
|
|
202
209
|
if cmd.requires_arguments:
|
|
203
|
-
return cli.safePrint(f
|
|
204
|
-
return cli.safePrint(
|
|
210
|
+
return cli.safePrint(f'Command \'{cmd.name}\' requires an argument')
|
|
211
|
+
return cli.safePrint('Missing subcommand')
|
|
205
212
|
|
|
206
213
|
child_name = parsed.positional[0]
|
|
207
214
|
child = cmd.children.get(child_name)
|
|
208
215
|
if child is None:
|
|
209
|
-
return cli.safePrint(f
|
|
216
|
+
return cli.safePrint(f'Unknown subcommand \'{child_name}\'')
|
|
210
217
|
|
|
211
218
|
arg = parsed.positional[1] if len(parsed.positional) > 1 else None
|
|
212
219
|
|
|
213
220
|
if child.requires_arguments and arg is None:
|
|
214
|
-
return cli.safePrint(f
|
|
221
|
+
return cli.safePrint(f'Subcommand \'{child.name}\' requires an argument')
|
|
215
222
|
|
|
216
|
-
|
|
223
|
+
# Inject param/flag functions into child.func globals
|
|
224
|
+
g = child.func.__globals__
|
|
217
225
|
|
|
226
|
+
# Params: use provided value or default, then call original func(value)
|
|
218
227
|
for pname, pspec in child.params.items():
|
|
219
228
|
if pname in parsed.params:
|
|
220
|
-
|
|
229
|
+
raw_value = parsed.params[pname]
|
|
230
|
+
try:
|
|
231
|
+
converted = pspec.type_(raw_value)
|
|
232
|
+
except Exception:
|
|
233
|
+
converted = pspec.default
|
|
234
|
+
else:
|
|
235
|
+
converted = pspec.default
|
|
221
236
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return pspec.default
|
|
237
|
+
def make_param_func(func=pspec.func, value=converted):
|
|
238
|
+
def wrapper():
|
|
239
|
+
return func(value)
|
|
240
|
+
return wrapper
|
|
227
241
|
|
|
228
|
-
|
|
229
|
-
else:
|
|
230
|
-
wrappers[pname] = lambda pspec=pspec: pspec.default
|
|
242
|
+
g[pname] = make_param_func()
|
|
231
243
|
|
|
232
|
-
|
|
244
|
+
# Flags: presence → True, absence → False
|
|
245
|
+
for fname, fspec in child.flags.items():
|
|
233
246
|
present = fname in parsed.flags
|
|
234
|
-
wrappers[fname] = lambda present=present: present
|
|
235
247
|
|
|
236
|
-
|
|
248
|
+
def make_flag_func(func=fspec.func, present=present):
|
|
249
|
+
def wrapper():
|
|
250
|
+
return present
|
|
251
|
+
return wrapper
|
|
237
252
|
|
|
253
|
+
g[fname] = make_flag_func()
|
|
238
254
|
|
|
239
|
-
|
|
240
|
-
# BASE LiveCLI (reusable)
|
|
241
|
-
# -------------------------
|
|
255
|
+
return child.func(cli, arg)
|
|
242
256
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
import asyncio
|
|
257
|
+
|
|
258
|
+
# ---------------------------------------------------------------------------
|
|
259
|
+
# Base LiveCLI
|
|
260
|
+
# ---------------------------------------------------------------------------
|
|
248
261
|
|
|
249
262
|
class LiveCLI(cmd.Cmd):
|
|
250
|
-
prompt =
|
|
263
|
+
prompt = ''
|
|
251
264
|
|
|
252
|
-
def safePrint(self, msg=
|
|
265
|
+
def safePrint(self, msg: object = '', end: str = '\n') -> None:
|
|
253
266
|
print(str(msg), end=end)
|
|
254
267
|
|
|
255
|
-
def bprint(self, msg):
|
|
268
|
+
def bprint(self, msg: object) -> None:
|
|
256
269
|
self.safePrint(msg)
|
|
257
270
|
|
|
258
|
-
def read_line_raw(self):
|
|
271
|
+
def read_line_raw(self) -> str:
|
|
259
272
|
fd = sys.stdin.fileno()
|
|
260
273
|
old = termios.tcgetattr(fd)
|
|
261
274
|
try:
|
|
262
275
|
tty.setraw(fd)
|
|
263
|
-
chars = []
|
|
276
|
+
chars: list[str] = []
|
|
264
277
|
while True:
|
|
265
278
|
ch = sys.stdin.read(1)
|
|
266
|
-
if ch in (
|
|
279
|
+
if ch in ('\r', '\n'):
|
|
267
280
|
break
|
|
268
281
|
chars.append(ch)
|
|
269
|
-
return
|
|
282
|
+
return ''.join(chars)
|
|
270
283
|
finally:
|
|
271
284
|
termios.tcsetattr(fd, termios.TCSADRAIN, old)
|
|
272
285
|
|
|
@@ -280,5 +293,5 @@ class LiveCLI(cmd.Cmd):
|
|
|
280
293
|
if stop:
|
|
281
294
|
break
|
|
282
295
|
|
|
283
|
-
def onecmd(self, line):
|
|
296
|
+
def onecmd(self, line: str):
|
|
284
297
|
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=ncACuZw5U6pzPjJevUttzyIcYrYcWFWSNzFsB2gApIw,8564
|
|
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.dev15.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
18
|
+
serverwatcher-6.dev15.dist-info/METADATA,sha256=kGDyPA8TBY8dwi5EN18Cqk0GSI22orLvs6JmWr1ALt8,2647
|
|
19
|
+
serverwatcher-6.dev15.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
20
|
+
serverwatcher-6.dev15.dist-info/top_level.txt,sha256=8DJAf8WmmglgtZHkp8aoTriRJ2YPcS4F3DfOIkytASo,14
|
|
21
|
+
serverwatcher-6.dev15.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|