1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-29 23:13:14 +02:00

nix --help: Group commands

This commit is contained in:
Eelco Dolstra 2020-05-05 15:18:23 +02:00
parent a721a0b114
commit f132d82a79
26 changed files with 125 additions and 55 deletions

View file

@ -197,17 +197,10 @@ public:
run() method. */
struct Command : virtual Args
{
private:
std::string _name;
friend class MultiCommand;
public:
virtual ~Command() { }
std::string name() { return _name; }
virtual void prepare() { };
virtual void run() = 0;
@ -221,6 +214,12 @@ public:
virtual Examples examples() { return Examples(); }
typedef int Category;
static constexpr Category catDefault = 0;
virtual Category category() { return catDefault; }
void printHelp(const string & programName, std::ostream & out) override;
};
@ -233,7 +232,10 @@ class MultiCommand : virtual Args
public:
Commands commands;
std::shared_ptr<Command> command;
std::map<Command::Category, std::string> categories;
// Selected command, if any.
std::optional<std::pair<std::string, ref<Command>>> command;
MultiCommand(const Commands & commands);