Description
It's not uncommon for commandline tools to take different actions when invoked under different names. An extreme example of this is busybox
which implements a slew of standard POSIX shell utilities. Its FAQ says:
If the Busybox executable is renamed to one of the commands it supports, it will act as that command automatically:
ln -s busybox pwd
./pwd
Given that Rust does not encourage dynamic linking if a project wants to create multiple binaries with a shared core of functionality there aren't many other good options. Even with dynamic linking on the table, being able to easily produce and distribute statically-linked binaries is a big selling point of writing commandline tools in Rust.
Describe the solution you'd like
Some way to specify an aliased name for bin
targets that cargo would honor as part of the build would be helpful. As a strawman, perhaps:
[[bin]]
name = "mybin"
aliases = ["anothername"]
Would ask cargo to install this binary as both mybin
and anothername
. Ideally this would happen via hardlinks, but on platforms where they're not available copying the binary to the aliased names seems acceptable.
Notes
This came up while discussing feature additions to ripgrep
. The rg
command is not amenable to subcommands given how it handles commandline arguments so adding new functionality that isn't part of searching means adding awkward options.