aboutsummaryrefslogtreecommitdiff
path: root/src/libcmd/command.cc
diff options
context:
space:
mode:
authorBen Burdette <bburdette@protonmail.com>2022-02-04 15:09:40 -0700
committerBen Burdette <bburdette@protonmail.com>2022-02-04 15:09:40 -0700
commitdbe3fd3735fa9aeb91720aa34dc447e5d925f3c4 (patch)
treea8b55d7fb2dbd70c10bbd521bc8458c9dbdd77c7 /src/libcmd/command.cc
parent3ddf864e1b2c5c27b2e6f7203e262c85bf760f7c (diff)
parentbd383d1b6f91c4fe7ac21c52771e92027f649fa0 (diff)
Merge branch 'master' into debug-step
Diffstat (limited to 'src/libcmd/command.cc')
-rw-r--r--src/libcmd/command.cc68
1 files changed, 51 insertions, 17 deletions
diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc
index 701976265..56288665a 100644
--- a/src/libcmd/command.cc
+++ b/src/libcmd/command.cc
@@ -54,6 +54,36 @@ void StoreCommand::run()
run(getStore());
}
+CopyCommand::CopyCommand()
+{
+ addFlag({
+ .longName = "from",
+ .description = "URL of the source Nix store.",
+ .labels = {"store-uri"},
+ .handler = {&srcUri},
+ });
+
+ addFlag({
+ .longName = "to",
+ .description = "URL of the destination Nix store.",
+ .labels = {"store-uri"},
+ .handler = {&dstUri},
+ });
+}
+
+ref<Store> CopyCommand::createStore()
+{
+ return srcUri.empty() ? StoreCommand::createStore() : openStore(srcUri);
+}
+
+ref<Store> CopyCommand::getDstStore()
+{
+ if (srcUri.empty() && dstUri.empty())
+ throw UsageError("you must pass '--from' and/or '--to'");
+
+ return dstUri.empty() ? openStore() : openStore(dstUri);
+}
+
EvalCommand::EvalCommand()
{
addFlag({
@@ -65,16 +95,33 @@ EvalCommand::EvalCommand()
extern std::function<void(const Error * error, const Env & env, const Expr & expr)> debuggerHook;
+
+
+EvalCommand::~EvalCommand()
+{
+ if (evalState)
+ evalState->printStats();
+}
+
+ref<Store> EvalCommand::getEvalStore()
+{
+ if (!evalStore)
+ evalStore = evalStoreUrl ? openStore(*evalStoreUrl) : getStore();
+ return ref<Store>(evalStore);
+}
+
ref<EvalState> EvalCommand::getEvalState()
{
if (!evalState) {
evalState =
-#if HAVE_BOEHMGC
+ #if HAVE_BOEHMGC
std::allocate_shared<EvalState>(traceable_allocator<EvalState>(),
-#else
+ searchPath, getEvalStore(), getStore())
+ #else
std::make_shared<EvalState>(
-#endif
- searchPath, getEvalStore(), getStore());
+ searchPath, getEvalStore(), getStore())
+ #endif
+ ;
if (startReplOnEvalErrors)
debuggerHook = [evalState{ref<EvalState>(evalState)}](const Error * error, const Env & env, const Expr & expr) {
// clear the screen.
@@ -113,19 +160,6 @@ ref<EvalState> EvalCommand::getEvalState()
return ref<EvalState>(evalState);
}
-EvalCommand::~EvalCommand()
-{
- if (evalState)
- evalState->printStats();
-}
-
-ref<Store> EvalCommand::getEvalStore()
-{
- if (!evalStore)
- evalStore = evalStoreUrl ? openStore(*evalStoreUrl) : getStore();
- return ref<Store>(evalStore);
-}
-
BuiltPathsCommand::BuiltPathsCommand(bool recursive)
: recursive(recursive)
{