[WIP] improve help message

This commit is contained in:
zolliker 2024-02-23 18:01:27 +01:00
parent 0b099bab28
commit 343e607c1b
4 changed files with 27 additions and 21 deletions

16
base.py
View File

@ -487,12 +487,20 @@ class ServiceManager:
print(str(e)) print(str(e))
def do_help(self, *args): def do_help(self, *args):
options = {'ins': '<instance> ', 'optional_ins': '[instance] ', 'remark': '*', 'legend': ''}
wildcards = True
if self.main_ins: if self.main_ins:
usage = self.USAGE.replace('<instance>', '[instance]') % ( if len(self.info) == 1:
'[instance] is empty or one of %s' % ', '.join(self.info)) for key in options:
options[key] = ''
wildcards = False
else:
options['legend'] = ' [instance] is empty or one of %s\n' % ', '.join(self.info)
else: else:
usage = self.USAGE % ('<instance> is one of %s' % ', '.join(self.info)) options['legend'] = ' <instance> is one of %s' % ', '.join(self.info)
print(usage) if wildcards:
options['legend'] += " * wildcards allowed, using '.' to replace 0 or more arbitrary characters in <instance>\n"
print(self.USAGE % options)
def treat_args(self, argdict, unknown=(), extra=()): def treat_args(self, argdict, unknown=(), extra=()):
if unknown: if unknown:

View File

@ -175,15 +175,14 @@ class FrappyManager(ServiceManager):
USAGE = """ USAGE = """
Usage: Usage:
frappy list [instance] * frappy list %(optional_ins)s
frappy start <instance> <service> <cfgfiles> frappy start %(ins)s<service> <cfgfiles>
frappy restart <instance> [<service>] [<cfgfiles>] * frappy restart %(ins)s[<service>] [<cfgfiles>] %(remark)s
frappy stop <instance> [<service>] * frappy stop %(ins)s[<service>] %(remark)s
frappy listcfg <instance> [<service> | develop] # list available cfg files frappy listcfg %(ins)s[<service> | develop] # list available cfg files
<service> is one of main, stick, addons <service> is one of main, stick, addons
%s %(legend)s
* wildcards allowed, using '.' to replace 0 or more arbitrary characters in <instance>
""" """
def config_dirs(self, ins, service): def config_dirs(self, ins, service):

View File

@ -56,7 +56,7 @@ class NicosManager(ServiceManager):
nicos gui <instance> nicos gui <instance>
nicos <instance> (the same as above) nicos <instance> (the same as above)
nicos list [<instance>] * nicos list [<instance>]
nicos start <instance> [<service>] * nicos start <instance> [<service>] *
nicos restart <instance> [<service>] * nicos restart <instance> [<service>] *
nicos stop <instance> [<service>] * nicos stop <instance> [<service>] *

View File

@ -56,17 +56,16 @@ class SeaManager(ServiceManager):
USAGE = """ USAGE = """
Usage: Usage:
sea gui <instance> sea gui %(ins)s
sea <instance> # the same as sea gui <instance> sea %(ins)s # the same as sea gui <instance>
sea cli <instance> # the same as old seacmd sea cli %(ins)s # the same as old seacmd
sea start <instance> [service] * # the same as old 'monit start sea' sea start %(ins)s[service] %(remark)s # the same as old 'monit start sea'
sea restart <instance> [service] * sea restart %(ins)s[service] %(remark)s
sea stop <instance> [service] * sea stop %(ins)s[service] %(remark)s
sea list [instance] * sea list %(optional_ins)s
[service] is empty or one of sea, graph [service] is empty or one of sea, graph
%s %(legend)s
* wildcards allowed, using '.' to replace 0 or more arbitrary characters in <instance>
""" """
def do_cli(self, ins): def do_cli(self, ins):