serverwatcher 6.dev41__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 CHANGED
@@ -6,6 +6,11 @@ import tty
6
6
  import asyncio
7
7
  import inspect
8
8
 
9
+ from mapres import res, ascii_colors, setGlobalMaps
10
+
11
+ setGlobalMaps(ascii_colors)
12
+
13
+
9
14
  COMMANDS = {}
10
15
 
11
16
  @dataclass
@@ -215,34 +220,34 @@ def parse_line(raw):
215
220
  def help_command(cmd):
216
221
  lines = []
217
222
  d = cmd.desc or 'No description'
218
- lines.append(f'{cmd.name}: {d}')
223
+ lines.append(res(f'<bold><yellow>{cmd.name}<reset>: <gray>{d}<reset>'))
219
224
 
220
225
  if cmd.children:
221
226
  if cmd.is_namespace:
222
- u = f'Usage: {cmd.name} <child>'
227
+ u = res(f'<aqua>Usage:<reset> <gold>{cmd.name}<reset> <dark_gray>\\<<reset>child<dark_gray>\\><reset>')
223
228
  else:
224
- u = f'Usage: {cmd.name} [child]'
229
+ u = res(f'<aqua>Usage:<reset> <gold>{cmd.name}<reset> <dark_gray>[<reset>child<dark_gray>]<reset>')
225
230
  else:
226
- u = f'Usage: {cmd.name}'
231
+ u = res(f'<aqua>Usage:<reset> <gold>{cmd.name}<reset>')
227
232
 
228
233
  if cmd.flags:
229
- u += ' [--flags]'
234
+ u += res(' <dark_gray>[<reset>--flags<dark_gray>]<reset>')
230
235
 
231
236
  lines.append(u)
232
237
 
233
238
  if cmd.flags:
234
239
  lines.append('')
235
- lines.append('\0 Flags:')
240
+ lines.append(res('\0 <light_purple>Flags:<reset>'))
236
241
  for n, fs in cmd.flags.items():
237
242
  d = fs.desc or 'No description'
238
- lines.append(f'\0 --{fs.name}: {d}')
243
+ lines.append(res(f'\0 <blue>--{fs.name}<reset>: <gray>{d}<reset>'))
239
244
 
240
245
  if cmd.children:
241
246
  lines.append('')
242
- lines.append('\0 Children:')
247
+ lines.append(res('\0 <light_purple>Children:<reset>'))
243
248
  for n, c in cmd.children.items():
244
249
  cd = c.desc or 'No description'
245
- lines.append(f'\0 {n}: {cd}')
250
+ lines.append(res(f'\0 <green>{n}<reset>: <gray>{cd}<reset>'))
246
251
 
247
252
  return '\n'.join(lines)
248
253
 
@@ -250,83 +255,92 @@ def help_child(child):
250
255
  lines = []
251
256
  d = child.desc or 'No description'
252
257
  p = child.parent.name
253
- lines.append(f'{child.name}: {d}')
254
- u = f'Usage: {p} {child.name}'
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>')
255
261
  if child.requires_arg:
256
- u += ' <arg>'
262
+ u += res(' <dark_gray>\\<<reset>arg<dark_gray>\\><reset>')
257
263
  elif child.optional_arg:
258
- u += ' [arg]'
264
+ u += res(' <dark_gray>[<reset>arg<dark_gray>]<reset>')
259
265
  if child.params:
260
- u += ' [params]'
266
+ u += res(' <dark_gray>[<reset>params<dark_gray>]<reset>')
261
267
  if child.flags:
262
- u += ' [--flags]'
268
+ u += res(' <dark_gray>[<reset>--flags<dark_gray>]<reset>')
263
269
  lines.append(u)
270
+
264
271
  if child.args_meta:
265
272
  lines.append('')
266
- lines.append('\0 Args:')
273
+ lines.append(res('\0 <light_purple>Args:<reset>'))
267
274
  for a, m in child.args_meta.items():
268
- parts = [a]
275
+ parts = [res(f'<green>{a}<reset>')]
269
276
  for pn in m.params:
270
- parts.append(f'[{pn}]')
277
+ parts.append(res(f'<dark_gray>[<reset>{pn}<dark_gray>]<reset>'))
271
278
  for fn in m.flags:
272
- parts.append(f'[--{fn}]')
279
+ parts.append(res(f'<dark_gray>[<reset>--{fn}<dark_gray>]<reset>'))
273
280
  lines.append('\0 ' + ' '.join(parts))
281
+
274
282
  if child.params:
275
283
  lines.append('')
276
- lines.append('\0 Params:')
284
+ lines.append(res('\0 <light_purple>Params:<reset>'))
277
285
  for n, ps in child.params.items():
278
286
  t = ps.type_.__name__
279
287
  d = ps.desc or 'No description'
280
- lines.append(f'\0 {n} (type={t}, default={ps.default}): {d}')
288
+ lines.append(res(f'\0 <blue>{n}<reset> (type=<gold>{t}<reset>, default=<gray>{ps.default}<reset>): <gray>{d}<reset>'))
289
+
281
290
  if child.flags:
282
291
  lines.append('')
283
- lines.append('\0 Flags:')
292
+ lines.append(res('\0 <light_purple>Flags:<reset>'))
284
293
  for n, fs in child.flags.items():
285
294
  d = fs.desc or 'No description'
286
- lines.append(f'\0 --{fs.name}: {d}')
295
+ lines.append(res(f'\0 <blue>--{fs.name}<reset>: <gray>{d}<reset>'))
296
+
287
297
  return '\n'.join(lines)
288
298
 
289
299
  def help_arg(child, meta):
290
300
  lines = []
291
301
  p = child.parent.name
292
302
  a = meta.name
293
- lines.append(f'{a}: Retrieve and print the {a} of the server')
294
- u = f'Usage: {p} {child.name} {a}'
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>')
295
306
  req = []
296
307
  opt = []
297
308
  for pn in meta.params:
298
309
  ps = child.params.get(pn)
299
310
  t = ps.type_.__name__ if ps else 'str'
300
311
  if pn in meta.required_params:
301
- req.append(f'<{pn}:{t}>')
312
+ req.append(res(f'<dark_gray>\\<<reset>{pn}:{t}<dark_gray>\\><reset>'))
302
313
  else:
303
- opt.append(f'[{pn}:{t}]')
314
+ opt.append(res(f'<dark_gray>[<reset>{pn}:{t}<dark_gray>]<reset>'))
304
315
  if req:
305
316
  u += ' ' + ' '.join(req)
306
317
  if opt:
307
318
  u += ' ' + ' '.join(opt)
308
319
  if meta.flags:
309
- u += ' [--flags]'
320
+ u += res(' <dark_gray>[<reset>--flags<dark_gray>]<reset>')
310
321
  lines.append(u)
322
+
311
323
  if meta.params:
312
324
  lines.append('')
313
- lines.append('\0 Params:')
325
+ lines.append(res('\0 <light_purple>Params:<reset>'))
314
326
  for pn in meta.params:
315
327
  ps = child.params.get(pn)
316
328
  if not ps:
317
329
  continue
318
330
  t = ps.type_.__name__
319
331
  d = ps.desc or 'No description'
320
- lines.append(f'\0 {pn} (type={t}, default={ps.default}): {d}')
332
+ lines.append(res(f'\0 <blue>{pn}<reset> (type=<gold>{t}<reset>, default=<gray>{ps.default}<reset>): <gray>{d}<reset>'))
333
+
321
334
  if meta.flags:
322
335
  lines.append('')
323
- lines.append('\0 Flags:')
336
+ lines.append(res('\0 <light_purple>Flags:<reset>'))
324
337
  for fn in meta.flags:
325
338
  fs = child.flags.get(fn)
326
339
  if not fs:
327
340
  continue
328
341
  d = fs.desc or 'No description'
329
- lines.append(f'\0 --{fn}: {d}')
342
+ lines.append(res(f'\0 <blue>--{fn}<reset>: <gray>{d}<reset>'))
343
+
330
344
  return '\n'.join(lines)
331
345
 
332
346
  def dispatch(cli, line):
@@ -335,29 +349,29 @@ def dispatch(cli, line):
335
349
  return
336
350
  cmd = COMMANDS.get(p.sub)
337
351
  if not cmd:
338
- return cli.safePrint(f'Unknown command {p.sub}')
352
+ return cli.safePrint(res(f'<red>Error:<reset> <gray>Unknown command {p.sub}<reset>'))
339
353
  if 'help' in p.flags and not p.pos:
340
354
  return cli.safePrint(help_command(cmd))
341
355
  if cmd.children:
342
356
  if not p.pos:
343
- return cli.safePrint('Missing subcommand')
357
+ return cli.safePrint(res('<red>Error:<reset> <gray>Missing subcommand<reset>'))
344
358
  else:
345
359
  return cmd.func(cli)
346
360
  cname = p.pos[0]
347
361
  child = cmd.children.get(cname)
348
362
  if not child:
349
- return cli.safePrint(f'Unknown subcommand {cname}')
363
+ return cli.safePrint(res(f'<red>Error:<reset> <gray>Unknown subcommand {cname}<reset>'))
350
364
  if 'help' in p.flags and len(p.pos) == 1:
351
365
  return cli.safePrint(help_child(child))
352
366
  if 'help' in p.flags and len(p.pos) >= 2:
353
367
  an = p.pos[1]
354
368
  meta = child.args_meta.get(an)
355
369
  if not meta:
356
- return cli.safePrint(f'Unknown argument {an}')
370
+ return cli.safePrint(res(f'<red>Error:<reset> <gray>Unknown argument {an}<reset>'))
357
371
  return cli.safePrint(help_arg(child, meta))
358
372
  arg = p.pos[1] if len(p.pos) > 1 else None
359
373
  if child.requires_arg and arg is None:
360
- 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>'))
361
375
  g = child.func.__globals__
362
376
  for n, ps in child.params.items():
363
377
  if n in p.params:
@@ -386,6 +400,7 @@ def dispatch(cli, line):
386
400
 
387
401
  class LiveCLI(cmd.Cmd):
388
402
  prompt = ''
403
+
389
404
  def safePrint(self, msg='', end='\n'):
390
405
  print(str(msg), end=end)
391
406
  def bprint(self, msg):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: serverwatcher
3
- Version: 6.dev41
3
+ Version: 6.dev43
4
4
  Summary: A HungerLib-powered Minecraft server automation engine.
5
5
  Author: iFamished
6
6
  License: GPL-3.0
@@ -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=3glLF5T3mPtsTgMzfc3-RNCCQ91v9ctMaPh1uKB9STc,12019
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.dev41.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
17
- serverwatcher-6.dev41.dist-info/METADATA,sha256=RNRyFhKFqwwihJVc-DJWfqYFbE3EwJWlA5IqKTV4xsI,2647
18
- serverwatcher-6.dev41.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
19
- serverwatcher-6.dev41.dist-info/top_level.txt,sha256=8DJAf8WmmglgtZHkp8aoTriRJ2YPcS4F3DfOIkytASo,14
20
- serverwatcher-6.dev41.dist-info/RECORD,,
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,,