mirror of
https://github.com/erkin/ponysay.git
synced 2025-02-07 13:36:43 +01:00
fix unrecognised option warning + print at most 5 warnings about unrecognised options, than just say how many more there are
Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
parent
7344a522f9
commit
dc9dc4b7a7
1 changed files with 8 additions and 2 deletions
10
ponysay.py
10
ponysay.py
|
@ -1519,8 +1519,11 @@ class ArgParser():
|
|||
dontget = 0
|
||||
self.rc = True
|
||||
|
||||
self.unrecognisedCount = 0
|
||||
def unrecognised(arg):
|
||||
sys.stderr.write('%s: warning: unrecognised option %s\n' % (self.__program, arg))
|
||||
self.unrecognisedCount += 1
|
||||
if self.unrecognisedCount <= 5:
|
||||
sys.stderr.write('%s: warning: unrecognised option %s\n' % (self.__program, arg))
|
||||
self.rc = False
|
||||
|
||||
while len(deque) != 0:
|
||||
|
@ -1586,7 +1589,7 @@ class ArgParser():
|
|||
dashed = True
|
||||
break
|
||||
else:
|
||||
unrecognised(arg)
|
||||
unrecognised(narg)
|
||||
else:
|
||||
self.files.append(arg)
|
||||
|
||||
|
@ -1616,6 +1619,9 @@ class ArgParser():
|
|||
|
||||
self.message = ' '.join(self.files) if len(self.files) > 0 else None
|
||||
|
||||
if self.unrecognisedCount > 5:
|
||||
sys.stderr.write('%s: warning: %i more unrecognised %s\n' % (self.unrecognisedCount - 5, 'options' if self.unrecognisedCount == 6 else 'options'))
|
||||
|
||||
return self.rc
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue