Skip to content

documentation of commands/arguments #114

@sdementen

Description

@sdementen

I have some questions/comments on the "user friendliness" of fire.

With the following script fire_test.py

import fire


class Example(object):
    """this is an example module with some functions"""

    def hello(self, name, message="hello", count=3):
        """Says count times the message to the specified name

        :param name (str): the name of the person
        :param message (str): the message to say to the person
        :param count (int): the number of times the message should be repeated
        :return: the expected result
        """
        return 'Hello {name}!'.format(name=name) * count


if __name__ == '__main__':
    fire.Fire(Example)

the call to python fire_test.py hello returns

Fire trace:
1. Initial component
2. Instantiated class "Example" (fire_test.py:4)
3. Accessed property "hello" (fire_test.py:7)
4. ('The function received no value for the required argument:', 'name')

Type:        method
String form: <bound method Example.hello of <__main__.Example object at 0x0000000002A2F9E8>>
File:        c:\users\gfj138\pycharmprojects\piecash\piecash\scripts\fire_test.py
Line:        7
Docstring:   Says count times the message to the specified name.

:param name (str): the name of the person
:param message (str): the message to say to the person
:param count (int): the number of times the message should be repeated
:return: the expected result

Usage:       fire_test.py hello NAME [MESSAGE] [COUNT]
             fire_test.py hello --name NAME [--message MESSAGE] [--count COUNT]

where:

  • the fire trace looks more like a "debugging feature" than a "user feedback"
  • the same for the Type/String form/File/Line information
  • the docstring is displayed as such which make it not user friendly
  • the default values of the optional arguments are not visible

Is there some better way to document the commands and their arguments I may be missing ?
Any good practice re documentation ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions