Python Fire v0.5.0
Changelist
- Support for custom serializers with fire.Fire(serializer=your_serializer) #345
- Auto-generated help text now shows short arguments (e.g. -a) when appropriate #318
- Documentation improvements (#334, #399, #372, #383, #387)
- Default values are now shown in help for kwonly arguments #414
- Completion script fix where previously completions might not show at all #336
Highlighted change: fire.Fire(serialize=custom_serialize_fn)
#345
You can now pass a custom serialization function to fire to control how the output is serialized.
Your serialize function should accept an object as input, and may return a string as output. If it returns a string, Fire will display that string. If it returns None, Fire will display nothing. If it returns something else, Fire will use the default serialization method to convert it to text.
The default serialization remains unchanged from previous versions. Primitives and collections of primitives are serialized one item per line. Objects that define a custom __str__
function are serialized using that. Complex objects that don't define __str__
trigger their help screen rather than being serialized and displayed.