summaryrefslogtreecommitdiffstats
path: root/pykolab/cli/__init__.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-03-02 13:37:07 +0000
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-03-02 13:37:07 +0000
commit1df25181222459bd92ad64296b6bec05b842b981 (patch)
treee28d1ccbdf91b63082db2c355561f11ac5b2d744 /pykolab/cli/__init__.py
parent8c754a5f9eed2ecb2d6257d3932c9c436f0eefa1 (diff)
downloadpykolab-1df25181222459bd92ad64296b6bec05b842b981.tar.gz
Bail out with a message on --help if no command is given on the CLI
Diffstat (limited to 'pykolab/cli/__init__.py')
-rw-r--r--pykolab/cli/__init__.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/pykolab/cli/__init__.py b/pykolab/cli/__init__.py
index 40fb20b..defa462 100644
--- a/pykolab/cli/__init__.py
+++ b/pykolab/cli/__init__.py
@@ -47,7 +47,11 @@ class Cli(object):
self.conf.finalize_conf()
# The first argument has to be a command
- action = self.conf.args.pop(0)
+ try:
+ action = self.conf.args.pop(0)
+ except IndexError, e:
+ self.no_command()
+
action_function = action.replace('-','_')
action_components = action.split('-')
@@ -66,6 +70,10 @@ class Cli(object):
self.print_usage()
+ def no_command(self):
+ print >> sys.stderr, _("No command given, see --help for details")
+ sys.exit(1)
+
def action_list_domains(self):
ldap_con = ldap.initialize(self.conf.get('ldap', 'uri'))
ldap_con.bind_s(self.conf.get('ldap', 'bind_dn'), self.conf.get('ldap', 'bind_pw'))