Permalink
Browse files

option handling made more clear and help output always printed

  • Loading branch information...
1 parent d7bcd17 commit 8cee715f55b60296bd94f065e98f60a196733e22 @rep committed Dec 15, 2011
Showing with 6 additions and 8 deletions.
  1. +3 −4 cli/feed.py
  2. +3 −4 cli/grabfiles.py
View
@@ -112,7 +112,7 @@ def main(opts, action, pubdata=None):
return 0
def opts():
- usage = "usage: %prog -i ident -s secret --host host -p port -c channel1 [-c channel2, ...] <action> [<data>]"
+ usage = "usage: %prog [options] publish|subscribe <publish_data>"
parser = optparse.OptionParser(usage=usage)
parser.add_option("-c", "--chan",
action="append", dest='channels', nargs=1, type='string',
@@ -132,9 +132,8 @@ def opts():
options, args = parser.parse_args()
- if len(args) < 1:
- parser.error('You need to give "subscribe" or "publish" as <action>.')
- if args[0] not in ['subscribe', 'publish']:
+ if len(args) < 1 or args[0] not in ['subscribe', 'publish'] or None in options.__dict__.values():
+ parser.print_help()
parser.error('You need to give "subscribe" or "publish" as <action>.')
action = args[0]
View
@@ -138,7 +138,7 @@ def main(opts, action, pubdata=None):
return 0
def opts():
- usage = "usage: %prog -i ident -s secret --host host -p port -c channel1 [-c channel2, ...] <action> [<data>]"
+ usage = "usage: %prog [options] publish|subscribe <publish_data>"
parser = optparse.OptionParser(usage=usage)
parser.add_option("-c", "--chan",
action="append", dest='channels', nargs=1, type='string',
@@ -164,9 +164,8 @@ def opts():
options, args = parser.parse_args()
- if len(args) < 1:
- parser.error('You need to give "subscribe" or "publish" as <action>.')
- if args[0] not in ['subscribe', 'publish']:
+ if len(args) < 1 or args[0] not in ['subscribe', 'publish'] or None in options.__dict__.values():
+ parser.print_help()
parser.error('You need to give "subscribe" or "publish" as <action>.')
action = args[0]

0 comments on commit 8cee715

Please sign in to comment.