serverwatcher 6.dev42__py3-none-any.whl → 6.dev43__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 +47 -37
- {serverwatcher-6.dev42.dist-info → serverwatcher-6.dev43.dist-info}/METADATA +1 -1
- {serverwatcher-6.dev42.dist-info → serverwatcher-6.dev43.dist-info}/RECORD +6 -6
- {serverwatcher-6.dev42.dist-info → serverwatcher-6.dev43.dist-info}/WHEEL +0 -0
- {serverwatcher-6.dev42.dist-info → serverwatcher-6.dev43.dist-info}/licenses/LICENSE +0 -0
- {serverwatcher-6.dev42.dist-info → serverwatcher-6.dev43.dist-info}/top_level.txt +0 -0
serverwatcher/livecli.py
CHANGED
|
@@ -220,34 +220,34 @@ def parse_line(raw):
|
|
|
220
220
|
def help_command(cmd):
|
|
221
221
|
lines = []
|
|
222
222
|
d = cmd.desc or 'No description'
|
|
223
|
-
lines.append(f'{cmd.name}
|
|
223
|
+
lines.append(res(f'<bold><yellow>{cmd.name}<reset>: <gray>{d}<reset>'))
|
|
224
224
|
|
|
225
225
|
if cmd.children:
|
|
226
226
|
if cmd.is_namespace:
|
|
227
|
-
u = res(f'<
|
|
227
|
+
u = res(f'<aqua>Usage:<reset> <gold>{cmd.name}<reset> <dark_gray>\\<<reset>child<dark_gray>\\><reset>')
|
|
228
228
|
else:
|
|
229
|
-
u = f'Usage
|
|
229
|
+
u = res(f'<aqua>Usage:<reset> <gold>{cmd.name}<reset> <dark_gray>[<reset>child<dark_gray>]<reset>')
|
|
230
230
|
else:
|
|
231
|
-
u = f'Usage
|
|
231
|
+
u = res(f'<aqua>Usage:<reset> <gold>{cmd.name}<reset>')
|
|
232
232
|
|
|
233
233
|
if cmd.flags:
|
|
234
|
-
u += ' [
|
|
234
|
+
u += res(' <dark_gray>[<reset>--flags<dark_gray>]<reset>')
|
|
235
235
|
|
|
236
236
|
lines.append(u)
|
|
237
237
|
|
|
238
238
|
if cmd.flags:
|
|
239
239
|
lines.append('')
|
|
240
|
-
lines.append('\0 Flags
|
|
240
|
+
lines.append(res('\0 <light_purple>Flags:<reset>'))
|
|
241
241
|
for n, fs in cmd.flags.items():
|
|
242
242
|
d = fs.desc or 'No description'
|
|
243
|
-
lines.append(f'\0
|
|
243
|
+
lines.append(res(f'\0 <blue>--{fs.name}<reset>: <gray>{d}<reset>'))
|
|
244
244
|
|
|
245
245
|
if cmd.children:
|
|
246
246
|
lines.append('')
|
|
247
|
-
lines.append('\0 Children
|
|
247
|
+
lines.append(res('\0 <light_purple>Children:<reset>'))
|
|
248
248
|
for n, c in cmd.children.items():
|
|
249
249
|
cd = c.desc or 'No description'
|
|
250
|
-
lines.append(f'\0 {n}
|
|
250
|
+
lines.append(res(f'\0 <green>{n}<reset>: <gray>{cd}<reset>'))
|
|
251
251
|
|
|
252
252
|
return '\n'.join(lines)
|
|
253
253
|
|
|
@@ -255,83 +255,92 @@ def help_child(child):
|
|
|
255
255
|
lines = []
|
|
256
256
|
d = child.desc or 'No description'
|
|
257
257
|
p = child.parent.name
|
|
258
|
-
lines.append(f'{child.name}
|
|
259
|
-
|
|
258
|
+
lines.append(res(f'<bold><green>{child.name}<reset>: <gray>{d}<reset>'))
|
|
259
|
+
|
|
260
|
+
u = res(f'<aqua>Usage:<reset> <gold>{p}<reset> <green>{child.name}<reset>')
|
|
260
261
|
if child.requires_arg:
|
|
261
|
-
u += ' <arg>'
|
|
262
|
+
u += res(' <dark_gray>\\<<reset>arg<dark_gray>\\><reset>')
|
|
262
263
|
elif child.optional_arg:
|
|
263
|
-
u += ' [arg]'
|
|
264
|
+
u += res(' <dark_gray>[<reset>arg<dark_gray>]<reset>')
|
|
264
265
|
if child.params:
|
|
265
|
-
u += ' [params]'
|
|
266
|
+
u += res(' <dark_gray>[<reset>params<dark_gray>]<reset>')
|
|
266
267
|
if child.flags:
|
|
267
|
-
u += ' [
|
|
268
|
+
u += res(' <dark_gray>[<reset>--flags<dark_gray>]<reset>')
|
|
268
269
|
lines.append(u)
|
|
270
|
+
|
|
269
271
|
if child.args_meta:
|
|
270
272
|
lines.append('')
|
|
271
|
-
lines.append('\0 Args
|
|
273
|
+
lines.append(res('\0 <light_purple>Args:<reset>'))
|
|
272
274
|
for a, m in child.args_meta.items():
|
|
273
|
-
parts = [a]
|
|
275
|
+
parts = [res(f'<green>{a}<reset>')]
|
|
274
276
|
for pn in m.params:
|
|
275
|
-
parts.append(f'[{pn}]')
|
|
277
|
+
parts.append(res(f'<dark_gray>[<reset>{pn}<dark_gray>]<reset>'))
|
|
276
278
|
for fn in m.flags:
|
|
277
|
-
parts.append(f'[
|
|
279
|
+
parts.append(res(f'<dark_gray>[<reset>--{fn}<dark_gray>]<reset>'))
|
|
278
280
|
lines.append('\0 ' + ' '.join(parts))
|
|
281
|
+
|
|
279
282
|
if child.params:
|
|
280
283
|
lines.append('')
|
|
281
|
-
lines.append('\0 Params
|
|
284
|
+
lines.append(res('\0 <light_purple>Params:<reset>'))
|
|
282
285
|
for n, ps in child.params.items():
|
|
283
286
|
t = ps.type_.__name__
|
|
284
287
|
d = ps.desc or 'No description'
|
|
285
|
-
lines.append(f'\0 {n} (type
|
|
288
|
+
lines.append(res(f'\0 <blue>{n}<reset> (type=<gold>{t}<reset>, default=<gray>{ps.default}<reset>): <gray>{d}<reset>'))
|
|
289
|
+
|
|
286
290
|
if child.flags:
|
|
287
291
|
lines.append('')
|
|
288
|
-
lines.append('\0 Flags
|
|
292
|
+
lines.append(res('\0 <light_purple>Flags:<reset>'))
|
|
289
293
|
for n, fs in child.flags.items():
|
|
290
294
|
d = fs.desc or 'No description'
|
|
291
|
-
lines.append(f'\0
|
|
295
|
+
lines.append(res(f'\0 <blue>--{fs.name}<reset>: <gray>{d}<reset>'))
|
|
296
|
+
|
|
292
297
|
return '\n'.join(lines)
|
|
293
298
|
|
|
294
299
|
def help_arg(child, meta):
|
|
295
300
|
lines = []
|
|
296
301
|
p = child.parent.name
|
|
297
302
|
a = meta.name
|
|
298
|
-
lines.append(f'{a}
|
|
299
|
-
|
|
303
|
+
lines.append(res(f'<bold><aqua>{a}<reset>: <gray>Retrieve and print the {a} of the server<reset>'))
|
|
304
|
+
|
|
305
|
+
u = res(f'<aqua>Usage:<reset> <gold>{p}<reset> <green>{child.name}<reset> <aqua>{a}<reset>')
|
|
300
306
|
req = []
|
|
301
307
|
opt = []
|
|
302
308
|
for pn in meta.params:
|
|
303
309
|
ps = child.params.get(pn)
|
|
304
310
|
t = ps.type_.__name__ if ps else 'str'
|
|
305
311
|
if pn in meta.required_params:
|
|
306
|
-
req.append(f'<{pn}:{t}>')
|
|
312
|
+
req.append(res(f'<dark_gray>\\<<reset>{pn}:{t}<dark_gray>\\><reset>'))
|
|
307
313
|
else:
|
|
308
|
-
opt.append(f'[{pn}:{t}]')
|
|
314
|
+
opt.append(res(f'<dark_gray>[<reset>{pn}:{t}<dark_gray>]<reset>'))
|
|
309
315
|
if req:
|
|
310
316
|
u += ' ' + ' '.join(req)
|
|
311
317
|
if opt:
|
|
312
318
|
u += ' ' + ' '.join(opt)
|
|
313
319
|
if meta.flags:
|
|
314
|
-
u += ' [
|
|
320
|
+
u += res(' <dark_gray>[<reset>--flags<dark_gray>]<reset>')
|
|
315
321
|
lines.append(u)
|
|
322
|
+
|
|
316
323
|
if meta.params:
|
|
317
324
|
lines.append('')
|
|
318
|
-
lines.append('\0 Params
|
|
325
|
+
lines.append(res('\0 <light_purple>Params:<reset>'))
|
|
319
326
|
for pn in meta.params:
|
|
320
327
|
ps = child.params.get(pn)
|
|
321
328
|
if not ps:
|
|
322
329
|
continue
|
|
323
330
|
t = ps.type_.__name__
|
|
324
331
|
d = ps.desc or 'No description'
|
|
325
|
-
lines.append(f'\0 {pn} (type
|
|
332
|
+
lines.append(res(f'\0 <blue>{pn}<reset> (type=<gold>{t}<reset>, default=<gray>{ps.default}<reset>): <gray>{d}<reset>'))
|
|
333
|
+
|
|
326
334
|
if meta.flags:
|
|
327
335
|
lines.append('')
|
|
328
|
-
lines.append('\0 Flags
|
|
336
|
+
lines.append(res('\0 <light_purple>Flags:<reset>'))
|
|
329
337
|
for fn in meta.flags:
|
|
330
338
|
fs = child.flags.get(fn)
|
|
331
339
|
if not fs:
|
|
332
340
|
continue
|
|
333
341
|
d = fs.desc or 'No description'
|
|
334
|
-
lines.append(f'\0
|
|
342
|
+
lines.append(res(f'\0 <blue>--{fn}<reset>: <gray>{d}<reset>'))
|
|
343
|
+
|
|
335
344
|
return '\n'.join(lines)
|
|
336
345
|
|
|
337
346
|
def dispatch(cli, line):
|
|
@@ -340,29 +349,29 @@ def dispatch(cli, line):
|
|
|
340
349
|
return
|
|
341
350
|
cmd = COMMANDS.get(p.sub)
|
|
342
351
|
if not cmd:
|
|
343
|
-
return cli.safePrint(f'Unknown command {p.sub}')
|
|
352
|
+
return cli.safePrint(res(f'<red>Error:<reset> <gray>Unknown command {p.sub}<reset>'))
|
|
344
353
|
if 'help' in p.flags and not p.pos:
|
|
345
354
|
return cli.safePrint(help_command(cmd))
|
|
346
355
|
if cmd.children:
|
|
347
356
|
if not p.pos:
|
|
348
|
-
return cli.safePrint('Missing subcommand')
|
|
357
|
+
return cli.safePrint(res('<red>Error:<reset> <gray>Missing subcommand<reset>'))
|
|
349
358
|
else:
|
|
350
359
|
return cmd.func(cli)
|
|
351
360
|
cname = p.pos[0]
|
|
352
361
|
child = cmd.children.get(cname)
|
|
353
362
|
if not child:
|
|
354
|
-
return cli.safePrint(f'Unknown subcommand {cname}')
|
|
363
|
+
return cli.safePrint(res(f'<red>Error:<reset> <gray>Unknown subcommand {cname}<reset>'))
|
|
355
364
|
if 'help' in p.flags and len(p.pos) == 1:
|
|
356
365
|
return cli.safePrint(help_child(child))
|
|
357
366
|
if 'help' in p.flags and len(p.pos) >= 2:
|
|
358
367
|
an = p.pos[1]
|
|
359
368
|
meta = child.args_meta.get(an)
|
|
360
369
|
if not meta:
|
|
361
|
-
return cli.safePrint(f'Unknown argument {an}')
|
|
370
|
+
return cli.safePrint(res(f'<red>Error:<reset> <gray>Unknown argument {an}<reset>'))
|
|
362
371
|
return cli.safePrint(help_arg(child, meta))
|
|
363
372
|
arg = p.pos[1] if len(p.pos) > 1 else None
|
|
364
373
|
if child.requires_arg and arg is None:
|
|
365
|
-
return cli.safePrint(f'Subcommand {child.name} requires an argument')
|
|
374
|
+
return cli.safePrint(res(f'<red>Error:<reset> <gray>Subcommand {child.name} requires an argument<reset>'))
|
|
366
375
|
g = child.func.__globals__
|
|
367
376
|
for n, ps in child.params.items():
|
|
368
377
|
if n in p.params:
|
|
@@ -391,6 +400,7 @@ def dispatch(cli, line):
|
|
|
391
400
|
|
|
392
401
|
class LiveCLI(cmd.Cmd):
|
|
393
402
|
prompt = ''
|
|
403
|
+
|
|
394
404
|
def safePrint(self, msg='', end='\n'):
|
|
395
405
|
print(str(msg), end=end)
|
|
396
406
|
def bprint(self, msg):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
serverwatcher/__init__.py,sha256=Q_afN0XU29n48d6Gf0-LT2lLo3RiTWlHRT6rC_fYbjw,486
|
|
2
2
|
serverwatcher/__main__.py,sha256=5geaZQKgLSP1pxnpQPgFy9zAwyyPyTInlbcFxb9OiEw,3016
|
|
3
|
-
serverwatcher/livecli.py,sha256=
|
|
3
|
+
serverwatcher/livecli.py,sha256=2obYPH0Gq8KnV1HIzesm_R0mSzxX5QMHjaAeH84c17U,13546
|
|
4
4
|
serverwatcher/validator.py,sha256=aD6GHOz1S5VFC93Mj89WO9vZG1bTjhg7QZbdlvQf4wo,1778
|
|
5
5
|
serverwatcher/watcher.py,sha256=QfWuyDIPZ59yToIdX5PdPMRcJrq-kFUW8d9Q39mA0uE,13769
|
|
6
6
|
serverwatcher/watchercli.py,sha256=bWblIa1s1F-TJ6GaX7YR08EyT8tmjCXpwmpJ_GloFc0,3987
|
|
@@ -13,8 +13,8 @@ serverwatcher/defaultconfigs/messages.yaml,sha256=jSVEl-RYqPHhe5U5KLl8zfJtUBymvy
|
|
|
13
13
|
serverwatcher/defaultconfigs/watcher.yaml,sha256=GlAEKCuzFUSF6wWOqQLFL1CeuPltb1ltfYxFe_FUClw,723
|
|
14
14
|
serverwatcher/tests/test.py,sha256=CqGBdfktVIyXz6wMoa6TBbEPlPvp_lA_VSzBuxwxrfs,2551
|
|
15
15
|
serverwatcher/tests/test2.py,sha256=DcvYiidXTe3SSOpiSPQ585YBN4PXrDMs0a3ZW_TbBsg,9564
|
|
16
|
-
serverwatcher-6.
|
|
17
|
-
serverwatcher-6.
|
|
18
|
-
serverwatcher-6.
|
|
19
|
-
serverwatcher-6.
|
|
20
|
-
serverwatcher-6.
|
|
16
|
+
serverwatcher-6.dev43.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
17
|
+
serverwatcher-6.dev43.dist-info/METADATA,sha256=qb4XxVAbW5Uivm5abGIILYHXovFMTZGE4xxjS7aFwxQ,2647
|
|
18
|
+
serverwatcher-6.dev43.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
19
|
+
serverwatcher-6.dev43.dist-info/top_level.txt,sha256=8DJAf8WmmglgtZHkp8aoTriRJ2YPcS4F3DfOIkytASo,14
|
|
20
|
+
serverwatcher-6.dev43.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|