diff --git a/fire/helptext.py b/fire/helptext.py index 5098b26b..331b6649 100644 --- a/fire/helptext.py +++ b/fire/helptext.py @@ -524,6 +524,8 @@ def _GetArgDefault(flag, spec): for arg, default in zip(args_with_defaults, spec.defaults): if arg == flag: return repr(default) + if flag in spec.kwonlydefaults: + return repr(spec.kwonlydefaults[flag]) return '' diff --git a/fire/helptext_test.py b/fire/helptext_test.py index 03ade4a5..14e0874a 100644 --- a/fire/helptext_test.py +++ b/fire/helptext_test.py @@ -296,6 +296,18 @@ def testHelpTextKeywordOnlyArgumentsWithoutDefault(self): self.assertIn('NAME\n double', output) self.assertIn('FLAGS\n --count=COUNT (required)', output) + @testutils.skipIf( + six.PY2, + 'Python 2 does not support required name-only arguments.') + def testHelpTextFunctionMixedDefaults(self): + component = tc.py3.HelpTextComponent().identity + t = trace.FireTrace(component, name='FunctionMixedDefaults') + output = helptext.HelpText(component, trace=t) + self.assertIn('NAME\n FunctionMixedDefaults', output) + self.assertIn('FunctionMixedDefaults ', output) + self.assertIn('--alpha=ALPHA (required)', output) + self.assertIn('--beta=BETA\n Default: \'0\'', output) + def testHelpScreen(self): component = tc.ClassWithDocstring() t = trace.FireTrace(component, name='ClassWithDocstring')