Allow the creation of command aliases
In many cases, several names are needed to invoke the same command.
It would be nice to have a way to specify an alias for a command, and have the alias mentioned in the help, without the need to define repeated entries in a command dictionary, and without the redefined function appearing several times in the help message.
For instance, doing this:
# 1.py
import clize
def foo():
"Function foo"
pass
def bar():
"Function bar"
pass
if __name__ == '__main__':
clize.run(dict(foo=foo, bar=bar, foo2=foo))
produces
Usage: 1.py command [args...]
Commands:
foo Function foo
bar Function bar
foo2 Function foo
The desired outcome (by whatever method is implemented) would be more like
Usage: 1.py command [args...]
Commands:
foo Function foo (alias: foo2)
bar Function bar
@epsy any chance of visiting this?
In 4.1.1 this works, but not in later versions.
That's odd, I thought it wasn't released yet? On a modified version of examples/multicommand.py I get this when running it on 4.1.1, 4.1.2, 4.2.0, and 4.2.1:
$ python3 -m examples.multicommands_double_spell --help
Usage: python3 -m examples.multicommands_double_spell command [args...]
A reliable to-do list utility.
Store entries at your own risk.
Commands:
add Adds an entry to the to-do list.
show Lists the existing entries.
list Lists the existing entries.
It works on master, were you perhaps running a custom version?
(I'm sorry releasing the next full version is taking so long, I'm trying to get the project in tip-top shape to support Python 3.10 and get ready for 3.11.)
That's weird, the [tool.poetry.dependencies] section of my pyproject.toml contains:
clize = {git = "https://github.com/epsy/clize.git", rev = "4.1.1"}
it a separate assignment to a new entry for the same function results in an alias.