You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you run './test_fire.py' the Calculator class is instantiated with no arguments and Fire shows you information about the result, which is a calculator object. This includes add and mul.
When you run './test_fire.py -- --help' it's providing help for the Calculator class, rather than for an instantiated Calculator object. If you change your main to 'fire.Fire(Calculator())', then the same command will now show help for the calculator object, which would include usage information for add and mul.
You'll see similar behavior if you run './test_fire.py mul -- --help' as compared to './test_fire.py mul'. The former prints help about the mul function without running it, whereas the latter runs the mul function and displays the result (615).
I'll add that if you use a separator, you can force a function to be run in order to get help for the result.
e.g. './test_fire.py - -- --help' will instantiate the Calculator object and then provide help about the result. Similarly, './test_fire.py mul - -- --help' will run the mul function and then provide help for the number 615!
Activity
dbieber commentedon Mar 6, 2017
When you run './test_fire.py' the Calculator class is instantiated with no arguments and Fire shows you information about the result, which is a calculator object. This includes
addandmul.When you run './test_fire.py -- --help' it's providing help for the Calculator class, rather than for an instantiated Calculator object. If you change your main to 'fire.Fire(Calculator())', then the same command will now show help for the calculator object, which would include usage information for
addandmul.You'll see similar behavior if you run './test_fire.py mul -- --help' as compared to './test_fire.py mul'. The former prints help about the
mulfunction without running it, whereas the latter runs themulfunction and displays the result (615).dbieber commentedon Mar 6, 2017
I'll add that if you use a separator, you can force a function to be run in order to get help for the result.
e.g. './test_fire.py - -- --help' will instantiate the Calculator object and then provide help about the result. Similarly, './test_fire.py mul - -- --help' will run the mul function and then provide help for the number 615!