diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2011-03-02 13:37:07 +0000 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2011-03-02 13:37:07 +0000 |
commit | 1df25181222459bd92ad64296b6bec05b842b981 (patch) | |
tree | e28d1ccbdf91b63082db2c355561f11ac5b2d744 /pykolab/cli | |
parent | 8c754a5f9eed2ecb2d6257d3932c9c436f0eefa1 (diff) | |
download | pykolab-1df25181222459bd92ad64296b6bec05b842b981.tar.gz |
Bail out with a message on --help if no command is given on the CLI
Diffstat (limited to 'pykolab/cli')
-rw-r--r-- | pykolab/cli/__init__.py | 10 |
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')) |