python-fire icon indicating copy to clipboard operation
python-fire copied to clipboard

Help Request - Disable NAME and SYNOPSIS Output

Open Sn3akyP3t3 opened this issue 4 years ago • 2 comments

I'm trying to find a way to disable the additional output that the fire library creates that comes after the process completes. It begins with NAME and includes SYNOPSIS. I have no need for this additional output in my scenario as it could potentially cause trouble for another external process that calls this and is examining the stdout for its own processing.

Here's an example of what I'm describing:

M:\Python\Workbench>FireHelpDocumentationExample.py --HowMuchPizza=1
()
NAME
    FireHelpDocumentationExample.py --HowMuchPizza=1

SYNOPSIS
    FireHelpDocumentationExample.py --HowMuchPizza=1 -

I would expect just: ()

An example of code I put together that was used to create this example is here.

Sn3akyP3t3 avatar Aug 05 '20 17:08 Sn3akyP3t3

Here are some ideas. Instead of defining a class (IntegrationClass) with your main method in it, just make it a function.

def run(HowMuchPizza, TipAmount=None):
  pc = ProcessClass()
  pc.orderUp(HowMuchPizza, TipAmount)

def main():
  fire.Fire(run)

Or you could even just do this (removing IntegrationClass entirely):

def main():
  pc = ProcessClass()
  fire.Fire(pc.orderUp)

dbieber avatar Aug 12 '20 14:08 dbieber

I'm not exactly sure I fully understand the why behind what is going on when using the offered solution, but the --help does show more, however it still seems to behave erratic in that I'm only seeing one paragraph of the description (Pizza lorem) and the last arg's description is cut off.

I do however now see that the NAME and SYNOPSIS output no longer show in the stdout which was the main concern I had for this ticket. I wish to understand why this happens if possible. Does it have something to do with classes calling classes?

Here is the altered code used as suggested. I see in the previous version if forgot to have the tips in the function documentation.

Sn3akyP3t3 avatar Aug 12 '20 17:08 Sn3akyP3t3