summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-11-12 10:15:24 -0700
committerJason Gerard DeRose <jderose@redhat.com>2008-11-12 10:15:24 -0700
commit01a7f1f437b72c2c13c6abfb02c6dea3924fa291 (patch)
tree5ad1c742b12e87d19d001e7ba8c825ed72c1b823 /ipalib
parentf04aaff97c9c8c22b36706f2c6d4de6f23d06b95 (diff)
downloadfreeipa-01a7f1f437b72c2c13c6abfb02c6dea3924fa291.tar.gz
freeipa-01a7f1f437b72c2c13c6abfb02c6dea3924fa291.tar.xz
freeipa-01a7f1f437b72c2c13c6abfb02c6dea3924fa291.zip
Calling ./ipa with no command now calls Command.help()
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/cli.py51
1 files changed, 27 insertions, 24 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index d86647c6a..febf399d9 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -241,12 +241,16 @@ def exit_error(error):
class help(frontend.Application):
- 'Display help on a command.'
+ '''Display help on a command.'''
- takes_args = ['command']
+ takes_args = ['command?']
- def run(self, key):
- key = str(key)
+ def run(self, command):
+ textui = self.Backend.textui
+ if command is None:
+ self.print_commands()
+ return
+ key = str(command)
if key not in self.application:
print 'help: no such command %r' % key
sys.exit(2)
@@ -254,6 +258,24 @@ class help(frontend.Application):
print 'Purpose: %s' % cmd.doc
self.application.build_parser(cmd).print_help()
+ def print_commands(self):
+ std = set(self.Command) - set(self.Application)
+ print '\nStandard IPA commands:'
+ for key in sorted(std):
+ cmd = self.api.Command[key]
+ self.print_cmd(cmd)
+ print '\nSpecial CLI commands:'
+ for cmd in self.api.Application():
+ self.print_cmd(cmd)
+ print '\nUse the --help option to see all the global options'
+ print ''
+
+ def print_cmd(self, cmd):
+ print ' %s %s' % (
+ to_cli(cmd.name).ljust(self.application.mcl),
+ cmd.doc,
+ )
+
class console(frontend.Application):
"""Start the IPA interactive Python console."""
@@ -406,12 +428,9 @@ class CLI(object):
if self.api.env.mode == 'unit_test':
return
if len(self.cmd_argv) < 1:
- self.print_commands()
- print 'Usage: ipa [global-options] COMMAND'
- sys.exit(2)
+ sys.exit(self.api.Command.help())
key = self.cmd_argv[0]
if key not in self:
- self.print_commands()
print 'ipa: ERROR: unknown command %r' % key
sys.exit(2)
return self.run_cmd(self[key])
@@ -505,23 +524,7 @@ class CLI(object):
)
self.__done.add(name)
- def print_commands(self):
- std = set(self.api.Command) - set(self.api.Application)
- print '\nStandard IPA commands:'
- for key in sorted(std):
- cmd = self.api.Command[key]
- self.print_cmd(cmd)
- print '\nSpecial CLI commands:'
- for cmd in self.api.Application():
- self.print_cmd(cmd)
- print '\nUse the --help option to see all the global options'
- print ''
- def print_cmd(self, cmd):
- print ' %s %s' % (
- to_cli(cmd.name).ljust(self.mcl),
- cmd.doc,
- )
def run_cmd(self, cmd):
kw = self.parse(cmd)