Nix/src/nix/nar.cc
Théophane Hufschmitt 7fff625e39
Improve the error message for “multicommands” commands (#9510)
* Factor out the default `MultiCommand` behavior

All the `MultiCommand`s had (nearly) the same behavior when called
without a subcommand.
Factor out this behavior into the `NixMultiCommand` class.

* Display the list of available subcommands when none is specified

Whenever a user runs a command that excepts a subcommand, add the list
of available subcommands to the error message.

* Print the multi-command lists as Markdown lists

This takes more screen real estate, but is also much more readable than
a comma-separated list
2023-12-06 13:13:45 +00:00

26 lines
479 B
C++

#include "command.hh"
using namespace nix;
struct CmdNar : NixMultiCommand
{
CmdNar() : NixMultiCommand("nar", RegisterCommand::getCommandsFor({"nar"}))
{ }
std::string description() override
{
return "create or inspect NAR files";
}
std::string doc() override
{
return
#include "nar.md"
;
}
Category category() override { return catUtility; }
};
static auto rCmdNar = registerCommand<CmdNar>("nar");