serverwatcher 6.dev18__py3-none-any.whl → 6.dev19__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/livecli.py +48 -49
- serverwatcher/watchercli.py +36 -6
- {serverwatcher-6.dev18.dist-info → serverwatcher-6.dev19.dist-info}/METADATA +1 -1
- {serverwatcher-6.dev18.dist-info → serverwatcher-6.dev19.dist-info}/RECORD +7 -7
- {serverwatcher-6.dev18.dist-info → serverwatcher-6.dev19.dist-info}/WHEEL +0 -0
- {serverwatcher-6.dev18.dist-info → serverwatcher-6.dev19.dist-info}/licenses/LICENSE +0 -0
- {serverwatcher-6.dev18.dist-info → serverwatcher-6.dev19.dist-info}/top_level.txt +0 -0
serverwatcher/livecli.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# livecli.py
|
|
2
|
+
|
|
1
3
|
from dataclasses import dataclass
|
|
2
4
|
import cmd
|
|
3
5
|
import sys
|
|
@@ -136,57 +138,51 @@ class CommandDSL:
|
|
|
136
138
|
command = CommandDSL()
|
|
137
139
|
|
|
138
140
|
|
|
139
|
-
def
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
def generate_child_help(child: ChildSpec) -> str:
|
|
166
|
-
lines = []
|
|
167
|
-
lines.append(f'{child.name}: {child.description or "No description"}')
|
|
168
|
-
lines.append(f'Usage: {child.name} [arg] [--flags] [params]')
|
|
141
|
+
def generate_help(obj):
|
|
142
|
+
if isinstance(obj, CommandSpec):
|
|
143
|
+
lines = []
|
|
144
|
+
lines.append(f'{obj.name}: {obj.description or "No description"}')
|
|
145
|
+
lines.append(f'Usage: {obj.name} [child] [arg] [--flags] [params]')
|
|
146
|
+
|
|
147
|
+
if obj.children:
|
|
148
|
+
lines.append('')
|
|
149
|
+
lines.append('Children:')
|
|
150
|
+
for cname, child in obj.children.items():
|
|
151
|
+
lines.append(f' {cname}: {child.description or "No description"}')
|
|
152
|
+
|
|
153
|
+
if obj.flags:
|
|
154
|
+
lines.append('')
|
|
155
|
+
lines.append('Flags:')
|
|
156
|
+
for fname in obj.flags:
|
|
157
|
+
lines.append(f' --{fname}')
|
|
158
|
+
|
|
159
|
+
if obj.params:
|
|
160
|
+
lines.append('')
|
|
161
|
+
lines.append('Params:')
|
|
162
|
+
for pname, pspec in obj.params.items():
|
|
163
|
+
lines.append(f' {pname} (type={pspec.type_.__name__}, default={pspec.default})')
|
|
164
|
+
|
|
165
|
+
return '\n'.join(lines)
|
|
169
166
|
|
|
170
|
-
if
|
|
171
|
-
lines
|
|
172
|
-
lines.append('
|
|
173
|
-
|
|
174
|
-
lines.append(f' --{fname}')
|
|
167
|
+
if isinstance(obj, ChildSpec):
|
|
168
|
+
lines = []
|
|
169
|
+
lines.append(f'{obj.name}: {obj.description or "No description"}')
|
|
170
|
+
lines.append(f'Usage: {obj.name} [arg] [--flags] [params]')
|
|
175
171
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
172
|
+
if obj.flags:
|
|
173
|
+
lines.append('')
|
|
174
|
+
lines.append('Flags:')
|
|
175
|
+
for fname in obj.flags:
|
|
176
|
+
lines.append(f' --{fname}')
|
|
181
177
|
|
|
182
|
-
|
|
178
|
+
if obj.params:
|
|
179
|
+
lines.append('')
|
|
180
|
+
lines.append('Params:')
|
|
181
|
+
for pname, pspec in obj.params.items():
|
|
182
|
+
lines.append(f' {pname} (type={pspec.type_.__name__}, default={pspec.default})')
|
|
183
183
|
|
|
184
|
+
return '\n'.join(lines)
|
|
184
185
|
|
|
185
|
-
def generate_help(obj):
|
|
186
|
-
if isinstance(obj, CommandSpec):
|
|
187
|
-
return generate_command_help(obj)
|
|
188
|
-
if isinstance(obj, ChildSpec):
|
|
189
|
-
return generate_child_help(obj)
|
|
190
186
|
return 'No help available'
|
|
191
187
|
|
|
192
188
|
|
|
@@ -230,14 +226,17 @@ def dispatch(cli, line: str):
|
|
|
230
226
|
if cmd is None:
|
|
231
227
|
return cli.safePrint(f'Unknown command {parsed.subcommand}')
|
|
232
228
|
|
|
233
|
-
if 'help' in parsed.flags:
|
|
229
|
+
if 'help' in parsed.flags and not parsed.positional:
|
|
234
230
|
return cli.safePrint(generate_help(cmd))
|
|
235
231
|
|
|
236
232
|
cmd.func()
|
|
237
233
|
|
|
234
|
+
if not cmd.children:
|
|
235
|
+
if 'help' in parsed.flags:
|
|
236
|
+
return cli.safePrint(generate_help(cmd))
|
|
237
|
+
return
|
|
238
|
+
|
|
238
239
|
if not parsed.positional:
|
|
239
|
-
if cmd.requires_arguments:
|
|
240
|
-
return cli.safePrint(f'Command {cmd.name} requires an argument')
|
|
241
240
|
return cli.safePrint('Missing subcommand')
|
|
242
241
|
|
|
243
242
|
child_name = parsed.positional[0]
|
serverwatcher/watchercli.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# watchercli.py
|
|
2
|
+
|
|
1
3
|
from hungerlib import utils
|
|
2
4
|
from mapres import res, ascii_colors, setGlobalMaps
|
|
3
5
|
from .watcher import ServerWatcher
|
|
@@ -18,15 +20,23 @@ class WatcherCLI(LiveCLI):
|
|
|
18
20
|
self.safePrint(res('<yellow>-------- <aqua>ServerWatcher CLI <yellow>--------'))
|
|
19
21
|
self.safePrint(res('<yellow>-----------------------------------'))
|
|
20
22
|
self.safePrint('')
|
|
23
|
+
|
|
21
24
|
|
|
22
25
|
@command('stats', requires_children=True)
|
|
23
26
|
def stats():
|
|
24
|
-
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
stats.__description__ = 'Retrieve and print server statistics'
|
|
30
|
+
|
|
25
31
|
|
|
26
32
|
@stats.child('get', requires_arguments=False)
|
|
27
33
|
def stats_get(self, arg=None):
|
|
28
|
-
|
|
34
|
+
pass
|
|
29
35
|
|
|
36
|
+
stats_get.__description__ = 'Retrieve and print all or specific server statistics'
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def stats_get(self, arg=None):
|
|
30
40
|
self.watcher.server.refresh()
|
|
31
41
|
|
|
32
42
|
if arg is not None:
|
|
@@ -66,26 +76,37 @@ def stats_get(self, arg=None):
|
|
|
66
76
|
else:
|
|
67
77
|
return
|
|
68
78
|
|
|
79
|
+
|
|
69
80
|
@stats.get.param('rounding', type=int, default=2)
|
|
70
81
|
def rounding(value):
|
|
71
82
|
return value
|
|
72
83
|
|
|
84
|
+
|
|
73
85
|
@stats.get.param('mode', type=str, default='current')
|
|
74
86
|
def mode(value):
|
|
75
87
|
return value
|
|
76
88
|
|
|
89
|
+
|
|
77
90
|
@stats.get.flag('raw')
|
|
78
91
|
def raw():
|
|
79
92
|
return True
|
|
80
93
|
|
|
94
|
+
|
|
81
95
|
@command('view', requires_children=True)
|
|
82
96
|
def view():
|
|
83
|
-
|
|
97
|
+
pass
|
|
98
|
+
|
|
99
|
+
view.__description__ = 'Switch terminal view'
|
|
100
|
+
|
|
84
101
|
|
|
85
102
|
@view.child('cli')
|
|
86
103
|
def view_cli(self):
|
|
87
|
-
|
|
104
|
+
pass
|
|
105
|
+
|
|
106
|
+
view_cli.__description__ = 'Switch to CLI view'
|
|
107
|
+
|
|
88
108
|
|
|
109
|
+
def view_cli(self):
|
|
89
110
|
self.watcher.router.disableOriginOutput()
|
|
90
111
|
self.outputMode = 'cli'
|
|
91
112
|
self.buffer.enabled = True
|
|
@@ -94,10 +115,15 @@ def view_cli(self):
|
|
|
94
115
|
for msg in self.buffer.captured:
|
|
95
116
|
self.safePrint(msg)
|
|
96
117
|
|
|
118
|
+
|
|
97
119
|
@view.child('watcher')
|
|
98
120
|
def view_watcher(self):
|
|
99
|
-
|
|
121
|
+
pass
|
|
122
|
+
|
|
123
|
+
view_watcher.__description__ = 'Switch to Watcher view'
|
|
100
124
|
|
|
125
|
+
|
|
126
|
+
def view_watcher(self):
|
|
101
127
|
self.watcher.router.enableOriginOutput()
|
|
102
128
|
self.outputMode = 'both'
|
|
103
129
|
utils.clearTerminal()
|
|
@@ -105,9 +131,13 @@ def view_watcher(self):
|
|
|
105
131
|
for msg in self.watcher.router.buffer.captured:
|
|
106
132
|
self.safePrint(msg)
|
|
107
133
|
|
|
134
|
+
|
|
108
135
|
@command('clear')
|
|
109
136
|
def clear():
|
|
110
|
-
|
|
137
|
+
pass
|
|
138
|
+
|
|
139
|
+
clear.__description__ = 'Clear the CLI terminal'
|
|
140
|
+
|
|
111
141
|
|
|
112
142
|
@clear.flag('no-buffer')
|
|
113
143
|
def no_buffer():
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
serverwatcher/__init__.py,sha256=Q_afN0XU29n48d6Gf0-LT2lLo3RiTWlHRT6rC_fYbjw,486
|
|
2
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=GC-OBSL-EkGRFyuHLx8wjgsDh6d7y2OEr_SIQxGX-WU,8815
|
|
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=Wi2oxniLkgHcCauWqbNTOsFl2KnlJUMOtzLkNegzcbM,3522
|
|
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.dev19.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
18
|
+
serverwatcher-6.dev19.dist-info/METADATA,sha256=L2IulN0arZlbNuS4cqPBUrh39UK_AOiELkk7mcVhvVo,2647
|
|
19
|
+
serverwatcher-6.dev19.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
20
|
+
serverwatcher-6.dev19.dist-info/top_level.txt,sha256=8DJAf8WmmglgtZHkp8aoTriRJ2YPcS4F3DfOIkytASo,14
|
|
21
|
+
serverwatcher-6.dev19.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|