Add usage message when no arguments.

This commit is contained in:
Guido van Rossum 1998-04-06 14:45:26 +00:00
parent f4b44fa6ef
commit 8053d89f7b
4 changed files with 16 additions and 0 deletions

View File

@ -19,9 +19,13 @@ def main():
opts, args = getopt.getopt(sys.argv[1:], "v") opts, args = getopt.getopt(sys.argv[1:], "v")
except getopt.error, msg: except getopt.error, msg:
print msg print msg
return
for o, a in opts: for o, a in opts:
if o == '-v': if o == '-v':
verbose = verbose + 1 verbose = verbose + 1
if not args:
print "Usage:", sys.argv[0], "file_or_directory ..."
return
for arg in args: for arg in args:
check(arg) check(arg)

View File

@ -19,9 +19,13 @@ def main():
opts, args = getopt.getopt(sys.argv[1:], "v") opts, args = getopt.getopt(sys.argv[1:], "v")
except getopt.error, msg: except getopt.error, msg:
print msg print msg
return
for o, a in opts: for o, a in opts:
if o == '-v': if o == '-v':
verbose = verbose + 1 verbose = verbose + 1
if not args:
print "Usage:", sys.argv[0], "file_or_directory ..."
return
for arg in args: for arg in args:
check(arg) check(arg)

View File

@ -19,9 +19,13 @@ def main():
opts, args = getopt.getopt(sys.argv[1:], "v") opts, args = getopt.getopt(sys.argv[1:], "v")
except getopt.error, msg: except getopt.error, msg:
print msg print msg
return
for o, a in opts: for o, a in opts:
if o == '-v': if o == '-v':
verbose = verbose + 1 verbose = verbose + 1
if not args:
print "Usage:", sys.argv[0], "file_or_directory ..."
return
for arg in args: for arg in args:
check(arg) check(arg)

View File

@ -16,6 +16,7 @@ def main():
opts, args = getopt.getopt(sys.argv[1:], "qv") opts, args = getopt.getopt(sys.argv[1:], "qv")
except getopt.error, msg: except getopt.error, msg:
print msg print msg
return
for o, a in opts: for o, a in opts:
if o == '-v': if o == '-v':
verbose = verbose + 1 verbose = verbose + 1
@ -23,6 +24,9 @@ def main():
if o == '-q': if o == '-q':
quiet = 1 quiet = 1
verbose = 0 verbose = 0
if not args:
print "Usage:", sys.argv[0], "file_or_directory ..."
return
for arg in args: for arg in args:
check(arg) check(arg)