# HG changeset patch
# User Pascal Volk <user@localhost.localdomain.org>
# Date 1391458949 0
# Node ID 74ee0a62039c19cf3d703a782c766f309279df41
# Parent  6be7e9085e94d12d3e14278b3a043cc7d29ccf2c
VMM/cli: Make sure that there is at least one argument.

diff -r 6be7e9085e94 -r 74ee0a62039c VirtualMailManager/cli/main.py
--- a/VirtualMailManager/cli/main.py	Sun Feb 02 17:10:43 2014 +0000
+++ b/VirtualMailManager/cli/main.py	Mon Feb 03 20:22:29 2014 +0000
@@ -14,8 +14,8 @@
 from VirtualMailManager.config import BadOptionError, ConfigValueError
 from VirtualMailManager.cli import w_err
 from VirtualMailManager.cli.handler import CliHandler
-from VirtualMailManager.constants import EX_SUCCESS, EX_USER_INTERRUPT, \
-     INVALID_ARGUMENT
+from VirtualMailManager.constants import EX_MISSING_ARGS, EX_SUCCESS, \
+     EX_USER_INTERRUPT, INVALID_ARGUMENT
 from VirtualMailManager.cli.subcommands import RunContext, setup_parser
 
 
@@ -34,8 +34,12 @@
         return handler
 
 
-def run():
+def run(argv):
     parser = setup_parser()
+    if len(argv) < 2:
+        parser.print_usage()
+        parser.exit(status=EX_MISSING_ARGS,
+                   message=_('You must specify a subcommand at least.') + '\n')
     args = parser.parse_args()
     handler = _get_handler()
     run_ctx = RunContext(args, handler)
diff -r 6be7e9085e94 -r 74ee0a62039c VirtualMailManager/constants.py
--- a/VirtualMailManager/constants.py	Sun Feb 02 17:10:43 2014 +0000
+++ b/VirtualMailManager/constants.py	Mon Feb 03 20:22:29 2014 +0000
@@ -32,6 +32,7 @@
 # exit codes
 
 EX_SUCCESS = 0
+EX_MISSING_ARGS = 1
 EX_USER_INTERRUPT = 3
 
 
diff -r 6be7e9085e94 -r 74ee0a62039c vmm
--- a/vmm	Sun Feb 02 17:10:43 2014 +0000
+++ b/vmm	Mon Feb 03 20:22:29 2014 +0000
@@ -15,4 +15,4 @@
     # Otherwise just remove /usr/local/sbin from sys.path
     sys.path.remove(sys.path[0])
     from VirtualMailManager.cli.main import run
-    sys.exit(run())
+    sys.exit(run(sys.argv))