From 2d645197eb21a783de57cf10366db58fd41866fe Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Fri, 15 Jul 2011 10:39:23 +0400 Subject: Add possibility to call commands without subcommands. --- bin/nova-manage | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index a845ab7a9..da285042f 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -925,6 +925,9 @@ class VersionCommands(object): print _("%s (%s)") %\ (version.version_string(), version.version_string_with_vcs()) + def __call__(self): + self.list() + class VolumeCommands(object): """Methods for dealing with a cloud in an odd state""" @@ -1379,14 +1382,19 @@ def main(): command_object = fn() actions = methods_of(command_object) if len(argv) < 1: - print script_name + " category action []" - print _("Available actions for %s category:") % category - for k, _v in actions: - print "\t%s" % k - sys.exit(2) - action = argv.pop(0) - matches = lazy_match(action, actions) - action, fn = matches[0] + if hasattr(command_object, '__call__'): + action = '__call__' + fn = command_object.__call__ + else: + print script_name + " category action []" + print _("Available actions for %s category:") % category + for k, _v in actions: + print "\t%s" % k + sys.exit(2) + else: + action = argv.pop(0) + matches = lazy_match(action, actions) + action, fn = matches[0] # For not decorated methods options = getattr(fn, 'options', '') -- cgit