google / python-fire

Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object.
Other
26.86k stars 1.44k forks source link

Make alias for arguments #429

Closed lucienne999 closed 1 year ago

lucienne999 commented 1 year ago

Hi, can fire set arguments like -u, --username in argparser? For example:

    parser.add_argument(
        "-u", "--username",
        type=str,
        default=None)
dbieber commented 1 year ago

This is not a planned feature. We do support short flags though, e.g. -u for --username if its the only arg starting with u.

I'm interested to know what syntax you would suggest for an alias feature.

lucienne999 commented 1 year ago

Thanks for your reply :).

In my example, the name of some arguments is too long. Alias will make command lines more simple. Of course, I can shorten these arguments. But for API consistency, I cannot changes their names arbitrarily. That's why i want alias these in command line.

The short flag is good! And enough for my case.