aboutsummaryrefslogtreecommitdiff
path: root/src/nix/main.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2023-03-21 14:37:09 +0100
committerEelco Dolstra <edolstra@gmail.com>2023-03-21 14:37:09 +0100
commit233b063b08b6a82921d26fb5a86e15c2b94a72ee (patch)
treebc3ba348b15da8215f6bdb149f6c9de77caef77d /src/nix/main.cc
parent3fc4659d22fc3c8cfbffd7322fd6c034efaaa3ab (diff)
Move store docs to 'nix help-stores'
Why not 'nix help stores'? Well, 'nix help <arg>' already means 'show help on the "arg" subcommand'.
Diffstat (limited to 'src/nix/main.cc')
-rw-r--r--src/nix/main.cc32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/nix/main.cc b/src/nix/main.cc
index 6caca9c22..5981028f7 100644
--- a/src/nix/main.cc
+++ b/src/nix/main.cc
@@ -223,6 +223,14 @@ static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)
std::cout << renderMarkdownToTerminal(markdown) << "\n";
}
+static NixArgs & getNixArgs(Command & cmd)
+{
+ assert(cmd.parent);
+ MultiCommand * toplevel = cmd.parent;
+ while (toplevel->parent) toplevel = toplevel->parent;
+ return dynamic_cast<NixArgs &>(*toplevel);
+}
+
struct CmdHelp : Command
{
std::vector<std::string> subcommand;
@@ -252,12 +260,34 @@ struct CmdHelp : Command
assert(parent);
MultiCommand * toplevel = parent;
while (toplevel->parent) toplevel = toplevel->parent;
- showHelp(subcommand, dynamic_cast<NixArgs &>(*toplevel));
+ showHelp(subcommand, getNixArgs(*this));
}
};
static auto rCmdHelp = registerCommand<CmdHelp>("help");
+struct CmdHelpStores : Command
+{
+ std::string description() override
+ {
+ return "show help about store types and their settings";
+ }
+
+ std::string doc() override
+ {
+ return
+ #include "help-stores.md"
+ ;
+ }
+
+ void run() override
+ {
+ showHelp({"help-stores"}, getNixArgs(*this));
+ }
+};
+
+static auto rCmdHelpStores = registerCommand<CmdHelpStores>("help-stores");
+
void mainWrapped(int argc, char * * argv)
{
savedArgv = argv;