forked from lix-project/lix
Merge pull request #4541 from obsidiansystems/simpler-store-path-command
Deeper `Command` hierarchy to remove redundancy
This commit is contained in:
commit
548437c234
|
@ -118,10 +118,8 @@ void StorePathsCommand::run(ref<Store> store, std::vector<RealisedPath> paths)
|
||||||
run(store, std::move(storePaths));
|
run(store, std::move(storePaths));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StorePathCommand::run(ref<Store> store)
|
void StorePathCommand::run(ref<Store> store, std::vector<StorePath> storePaths)
|
||||||
{
|
{
|
||||||
auto storePaths = toStorePaths(store, Realise::Nothing, operateOn, installables);
|
|
||||||
|
|
||||||
if (storePaths.size() != 1)
|
if (storePaths.size() != 1)
|
||||||
throw UsageError("this command requires exactly one store path");
|
throw UsageError("this command requires exactly one store path");
|
||||||
|
|
||||||
|
|
|
@ -177,13 +177,13 @@ struct StorePathsCommand : public RealisedPathsCommand
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A command that operates on exactly one store path. */
|
/* A command that operates on exactly one store path. */
|
||||||
struct StorePathCommand : public InstallablesCommand
|
struct StorePathCommand : public StorePathsCommand
|
||||||
{
|
{
|
||||||
using StoreCommand::run;
|
using StorePathsCommand::run;
|
||||||
|
|
||||||
virtual void run(ref<Store> store, const StorePath & storePath) = 0;
|
virtual void run(ref<Store> store, const StorePath & storePath) = 0;
|
||||||
|
|
||||||
void run(ref<Store> store) override;
|
void run(ref<Store> store, std::vector<StorePath> storePaths) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A helper class for registering commands globally. */
|
/* A helper class for registering commands globally. */
|
||||||
|
|
Loading…
Reference in a new issue