Permalink
Browse files

salt-call shouldn't run without arguments

Reported-by: Devon Stewart <blast@hardchee.se>

Also, make sure to print proper usage.
  • Loading branch information...
1 parent 69587db commit 9ebeb74a5453663562712d8f493e3c67b973599d @SEJeff SEJeff committed Mar 18, 2012
Showing with 8 additions and 5 deletions.
  1. +8 −5 salt/cli/__init__.py
View
@@ -208,7 +208,7 @@ def __parse(self):
# Catch invalid invocations of salt such as: salt run
if len(args) <= 1:
parser.print_help()
- parser.exit()
+ parser.exit(1)
if opts['list']:
opts['tgt'] = args[0].split(',')
@@ -457,9 +457,10 @@ def __parse(self):
if v is not None:
opts[k] = v
+ # salt-cp needs arguments
if len(args) <= 1:
parser.print_help()
- parser.exit()
+ parser.exit(1)
if opts['list']:
opts['tgt'] = args[0].split(',')
@@ -635,7 +636,8 @@ def __parse(self):
'''
Parse the command line arguments
'''
- parser = optparse.OptionParser(version="%%prog %s" % VERSION)
+ usage = "%prog [options] <function> [arguments]"
+ parser = optparse.OptionParser(version='%%prog %s'.format(VERSION), usage=usage)
parser.add_option('-g',
'--grains',
@@ -710,8 +712,9 @@ def __parse(self):
opts['fun'] = args[0]
opts['arg'] = args[1:]
else:
- opts['fun'] = ''
- opts['arg'] = []
+ # salt-call should not ever be called without arguments
+ parser.print_help()
+ parser.exit(1)
verify_env([opts['pki_dir'],
opts['cachedir'],

0 comments on commit 9ebeb74

Please sign in to comment.