[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))
def do_help(self, *args):
options = {'ins': '<instance> ', 'optional_ins': '[instance] ', 'remark': '*', 'legend': ''}
wildcards = True
if self.main_ins:
usage = self.USAGE.replace('<instance>', '[instance]') % (
'[instance] is empty or one of %s' % ', '.join(self.info))
if len(self.info) == 1:
for key in options:
options[key] = ''
wildcards = False
else:
options['legend'] = ' [instance] is empty or one of %s\n' % ', '.join(self.info)
else:
usage = self.USAGE % ('<instance> is one of %s' % ', '.join(self.info))
print(usage)
options['legend'] = ' <instance> is one of %s' % ', '.join(self.info)
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=()):
if unknown:

View File

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

View File

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

View File

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