Skip to content

Better handling of argument name typos #84

@gerardlouw

Description

@gerardlouw

Using this minimal example of a Python-fire CLI:

import fire

def f(my_arg):
    print(my_arg)

fire.Fire(my_arg)

This is the result I get:

~ python example.py --my-arg=hello
hello
➜  ~ python example.py --myarg=hello
--myarg=hello

As you can see, a typo in the argument leads to unexpected behaviour, which can be really hard to debug.

I would suggest never treating an argument matching --[a-zA-Z0-9_-]+ as positional, without some sort of escaping by the user (perhaps similar to the escaping you require to avoid parsing ints, etc.).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions