aboutsummaryrefslogtreecommitdiff
path: root/src/nix/command.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix/command.hh')
-rw-r--r--src/nix/command.hh35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/nix/command.hh b/src/nix/command.hh
index 27c3ab7f2..34affc43d 100644
--- a/src/nix/command.hh
+++ b/src/nix/command.hh
@@ -11,6 +11,18 @@ struct Command : virtual Args
virtual std::string name() = 0;
virtual void prepare() { };
virtual void run() = 0;
+
+ struct Example
+ {
+ std::string description;
+ std::string command;
+ };
+
+ typedef std::list<Example> Examples;
+
+ virtual Examples examples() { return Examples(); }
+
+ void printHelp(const string & programName, std::ostream & out) override;
};
class Store;
@@ -18,13 +30,30 @@ class Store;
/* A command that require a Nix store. */
struct StoreCommand : virtual Command
{
- bool reserveSpace;
- StoreCommand(bool reserveSpace = true)
- : reserveSpace(reserveSpace) { };
+ std::string storeUri;
+ StoreCommand();
void run() override;
virtual void run(ref<Store>) = 0;
};
+/* A command that operates on zero or more store paths. */
+struct StorePathsCommand : public StoreCommand
+{
+private:
+
+ Paths storePaths;
+ bool recursive = false;
+ bool all = false;
+
+public:
+
+ StorePathsCommand();
+
+ virtual void run(ref<Store> store, Paths storePaths) = 0;
+
+ void run(ref<Store> store) override;
+};
+
typedef std::map<std::string, ref<Command>> Commands;
/* An argument parser that supports multiple subcommands,