do not show <instance> in help when not needed

This commit is contained in:
2021-04-09 10:28:18 +02:00
parent 3748948b5d
commit 4fb55323e3
4 changed files with 13 additions and 9 deletions

10
base.py
View File

@@ -83,7 +83,7 @@ class ServiceManager:
pkg = ''
revcmd = {}
USAGE = None
main_ins = basename(expanduser('~'))
main_ins = None
def __init__(self):
self.env = {}
@@ -137,7 +137,7 @@ class ServiceManager:
for ins in parser.sections():
section = dict(parser[ins])
if ins == 'MAIN':
ins = self.main_ins
ins = self.main_ins = basename(expanduser('~'))
command = section.get('%s_command' % self.group)
self.revcmd[command] = self.group
nr = section.get(self.group)
@@ -410,5 +410,9 @@ class ServiceManager:
raise
def usage(self):
print(self.USAGE % ', '.join(self.info))
if self.main_ins:
usage = self.USAGE.replace(' <instance>', '').replace(' [<instance>]', '') % ''
else:
usage = self.USAGE % ('<instance> is one of %s' % ', '.join(self.info))
print(usage)