From 6b9ba734e119cbdc92ebc0a1b28d75b405d46bb0 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 4 Sep 2008 09:04:35 +0000 Subject: 263: CLI.print_commands() now seperates Command subclasses from Application subclasses --- ipalib/cli.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'ipalib/cli.py') diff --git a/ipalib/cli.py b/ipalib/cli.py index abaef030..7ab0ae8d 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -99,12 +99,22 @@ class CLI(object): api = property(__get_api) def print_commands(self): - print 'Available Commands:' - for cmd in self.api.Command(): - print ' %s %s' % ( - to_cli(cmd.name).ljust(self.mcl), - cmd.doc, - ) + 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) + + def print_cmd(self, cmd): + print ' %s %s' % ( + to_cli(cmd.name).ljust(self.mcl), + cmd.doc, + ) + + def __contains__(self, key): assert self.__d is not None, 'you must call finalize() first' @@ -134,7 +144,7 @@ class CLI(object): self.finalize() if len(sys.argv) < 2: self.print_commands() - print 'Usage: ipa COMMAND [ARGS]' + print '\nUsage: ipa COMMAND' sys.exit(2) key = sys.argv[1] if key not in self: -- cgit