Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions fire/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,9 @@ def _ParseKeywordArgs(args, fn_spec):
remaining_kwargs.append(args[index + 1])
else: # not _IsFlag(argument)
remaining_args.append(argument)
# Flags after a positional token belong to later commands in a chain.
remaining_args.extend(args[index + 1:])
break

return kwargs, remaining_kwargs, remaining_args

Expand Down
21 changes: 21 additions & 0 deletions fire/fire_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,27 @@ def testHelpKwargsDecorator(self):
with self.assertRaisesFireExit(0):
fire.Fire(tc.decorated_method, command=['--help'])

def testChainedKwargsWithSameParameterName(self):
class ChainKwargFoo:
def __init__(self):
self.log = []

def bar(self, param=0):
self.log.append(('bar', param))
return self

def baz(self, param=0):
self.log.append(('baz', param))
return self

def end(self):
return self.log

obj = ChainKwargFoo()
result = fire.Fire(
obj, command=['bar', '--param=3', 'baz', '--param=5', 'end'])
self.assertEqual(result, [('bar', 3), ('baz', 5)])

def testFireAsyncio(self):
self.assertEqual(fire.Fire(tc.py3.WithAsyncio,
command=['double', '--count', '10']), 20)
Expand Down