summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/sbin/bcfg2-admin9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/sbin/bcfg2-admin b/src/sbin/bcfg2-admin
index 8790cadee..24e9eaac4 100755
--- a/src/sbin/bcfg2-admin
+++ b/src/sbin/bcfg2-admin
@@ -11,6 +11,7 @@ from Bcfg2.Bcfg2Py3k import StringIO
log = logging.getLogger('bcfg2-admin')
+
def mode_import(modename):
"""Load Bcfg2.Server.Admin.<mode>."""
modname = modename.capitalize()
@@ -18,10 +19,12 @@ def mode_import(modename):
(modname)).Server.Admin, modname)
return getattr(mod, modname)
+
def get_modes():
"""Get all available modes, except for the base mode."""
return [x.lower() for x in Bcfg2.Server.Admin.__all__ if x != 'mode']
+
def create_description():
"""Create the description string from the list of modes."""
modes = get_modes()
@@ -35,13 +38,15 @@ def create_description():
pass
return description.getvalue()
+
def main():
optinfo = dict()
optinfo.update(Bcfg2.Options.CLI_COMMON_OPTIONS)
optinfo.update(Bcfg2.Options.SERVER_COMMON_OPTIONS)
setup = Bcfg2.Options.OptionParser(optinfo)
# override default help message to include description of all modes
- setup.hm = "%s\n%s" % (setup.buildHelpMessage(), create_description())
+ setup.hm = "Usage:\n\n%s\n%s" % (setup.buildHelpMessage(),
+ create_description())
setup.parse(sys.argv[1:])
if setup['debug']:
@@ -80,7 +85,7 @@ def main():
if hasattr(mode, 'bcore'):
mode.bcore.shutdown()
else:
- log.error("Unknown mode %s" % setup['args'][0])
+ log.error("Error: Unknown mode '%s'\n" % setup['args'][0])
print(create_description())
raise SystemExit(1)