nix copy: Move --from / --to check

This means you now get an error message *before* stuff gets built:

  $ nix copy .#hydraJobs.vendoredCrates
  error: you must pass '--from' and/or '--to'
  Try 'nix --help' for more information.
This commit is contained in:
Eelco Dolstra 2020-04-29 15:50:59 +02:00
parent 70bcd6a55c
commit 9c4e05766b

View file

@ -80,11 +80,16 @@ struct CmdCopy : StorePathsCommand
return srcUri.empty() ? StoreCommand::createStore() : openStore(srcUri); return srcUri.empty() ? StoreCommand::createStore() : openStore(srcUri);
} }
void run(ref<Store> srcStore, StorePaths storePaths) override void run(ref<Store> store) override
{ {
if (srcUri.empty() && dstUri.empty()) if (srcUri.empty() && dstUri.empty())
throw UsageError("you must pass '--from' and/or '--to'"); throw UsageError("you must pass '--from' and/or '--to'");
StorePathsCommand::run(store);
}
void run(ref<Store> srcStore, StorePaths storePaths) override
{
ref<Store> dstStore = dstUri.empty() ? openStore() : openStore(dstUri); ref<Store> dstStore = dstUri.empty() ? openStore() : openStore(dstUri);
copyPaths(srcStore, dstStore, storePathsToSet(storePaths), copyPaths(srcStore, dstStore, storePathsToSet(storePaths),