mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 12:06:01 +01:00
Make nix help shell work by handling aliases properly
Previously, `nix help shell` failed with "Nix has no subcommand 'shell'" despite `nix shell --help` working correctly. This happened because the `shell` command is actually an alias for `env shell`, and the help system wasn't resolving aliases when looking up documentation. This patch modifies the `showHelp` function to check for and resolve aliases before generating the manpage name, ensuring that shorthand commands like `shell` get proper help documentation. Closes: #13431
This commit is contained in:
parent
de1d91f711
commit
d678b071d6
1 changed files with 8 additions and 0 deletions
|
|
@ -212,6 +212,14 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs, virtual RootArgs
|
||||||
lowdown. */
|
lowdown. */
|
||||||
static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)
|
static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)
|
||||||
{
|
{
|
||||||
|
// Check for aliases if subcommand has exactly one element
|
||||||
|
if (subcommand.size() == 1) {
|
||||||
|
auto alias = toplevel.aliases.find(subcommand[0]);
|
||||||
|
if (alias != toplevel.aliases.end()) {
|
||||||
|
subcommand = alias->second.replacement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto mdName = subcommand.empty() ? "nix" : fmt("nix3-%s", concatStringsSep("-", subcommand));
|
auto mdName = subcommand.empty() ? "nix" : fmt("nix3-%s", concatStringsSep("-", subcommand));
|
||||||
|
|
||||||
evalSettings.restrictEval = false;
|
evalSettings.restrictEval = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue