summaryrefslogtreecommitdiff
path: root/tools/src/py/qpid-cluster
diff options
context:
space:
mode:
authorNuno Santos <nsantos@apache.org>2010-05-24 23:19:11 +0000
committerNuno Santos <nsantos@apache.org>2010-05-24 23:19:11 +0000
commit5e3d7c8162f1bbc7ba744ee779fa0a4339439438 (patch)
treebcaf9b380ad4c93c5c1af247c0cb491358760732 /tools/src/py/qpid-cluster
parent7981b9d46fec43ff7b6969fca20c59d8c43b25eb (diff)
downloadqpid-python-5e3d7c8162f1bbc7ba744ee779fa0a4339439438.tar.gz
Make behavior of command line tools consistent, regarding -h and --help options, as well as giving an appropriate error message for any invalid options passed on the command line
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@947858 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tools/src/py/qpid-cluster')
-rwxr-xr-xtools/src/py/qpid-cluster21
1 files changed, 15 insertions, 6 deletions
diff --git a/tools/src/py/qpid-cluster b/tools/src/py/qpid-cluster
index 7e608e4f2b..e02cca7a88 100755
--- a/tools/src/py/qpid-cluster
+++ b/tools/src/py/qpid-cluster
@@ -38,12 +38,15 @@ class Config:
self._showConn = False
self._delConn = None
-def usage ():
+def usage (short=False):
print "Usage: qpid-cluster [OPTIONS] [broker-addr]"
print
print " broker-addr is in the form: [username/password@] hostname | ip-address [:<port>]"
print " ex: localhost, 10.1.1.7:10000, broker-host:10000, guest/guest@localhost"
print
+ if short:
+ return
+
print "Options:"
print " --timeout seconds (10) Maximum time to wait for broker connection"
print " -C [--all-connections] View client connections to all cluster members"
@@ -244,11 +247,14 @@ def main(argv=None):
try:
config = Config()
try:
- longOpts = ("stop=", "all-stop", "force", "connections=", "all-connections" "del-connection=", "numeric", "timeout=")
- (optlist, encArgs) = getopt.gnu_getopt(argv[1:], "s:kfCc:d:n", longOpts)
- except:
- usage()
- return 1
+ longOpts = ("help", "stop=", "all-stop", "force", "connections=", "all-connections" "del-connection=", "numeric", "timeout=")
+ (optlist, encArgs) = getopt.gnu_getopt(argv[1:], "hs:kfCc:d:n", longOpts)
+ except Exception, e:
+ usage (short=True)
+ # make output match optparse-based tools' output, for consistent scripting
+ msg = str(e).replace('option', 'no such option:').replace('not recognized', '')
+ print "qpid-config: error:", msg
+ sys.exit (1)
try:
encoding = locale.getpreferredencoding()
@@ -258,6 +264,9 @@ def main(argv=None):
count = 0
for opt in optlist:
+ if opt[0] == "-h" or opt[0] == "--help":
+ usage()
+ sys.exit(1)
if opt[0] == "--timeout":
config._connTimeout = int(opt[1])
if config._connTimeout == 0: