Make StorePathsCommand a subclass of InstallablesCommand

This allows commands like 'nix path-info', 'nix copy', 'nix verify'
etc. to work on arbitrary installables. E.g. to copy geeqie to a
binary cache:

  $ nix copy -r --to file:///tmp/binary-cache nixpkgs.geeqie

Or to get the closure size of thunderbird:

  $ nix path-info -S nixpkgs.thunderbird
This commit is contained in:
Eelco Dolstra 2017-04-25 13:20:26 +02:00
parent c769841bc4
commit 7ee81f3887
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
2 changed files with 33 additions and 24 deletions

View file

@ -44,26 +44,6 @@ private:
std::shared_ptr<Store> _store;
};
/* 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();
using StoreCommand::run;
virtual void run(ref<Store> store, Paths storePaths) = 0;
void run(ref<Store> store) override;
};
struct Installable
{
virtual std::string what() = 0;
@ -115,6 +95,25 @@ private:
Value * vSourceExpr = 0;
};
/* A command that operates on zero or more store paths. */
struct StorePathsCommand : public InstallablesCommand
{
private:
bool recursive = false;
bool all = false;
public:
StorePathsCommand();
using StoreCommand::run;
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,