From b979bb7a0a8d78234509448cb366d35cef1af22e Mon Sep 17 00:00:00 2001 From: Nicholas O'Connor Date: Wed, 5 Jul 2017 16:36:49 -0700 Subject: [PATCH] create and remove respect dryrun --- src/bottles/create.cpp | 19 +++++++++++++------ src/bottles/remove.cpp | 4 +++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/bottles/create.cpp b/src/bottles/create.cpp index d652802..e62e478 100644 --- a/src/bottles/create.cpp +++ b/src/bottles/create.cpp @@ -7,6 +7,7 @@ #include #include "bottles.hpp" +#include "cellar.hpp" #include "internal/bottles.hpp" #include "internal/launch.hpp" #include "fs.hpp" @@ -58,22 +59,28 @@ void cellar::bottles::create_bottle(int argc, vector argv) { } if (fullbottlepath != homepath + "/.wine.template") { + output::statement("copying template bottle to " + fullbottlepath, true); + // all this gets skipped if we're creating the template bottle if (boost::filesystem::exists(homepath + "/.wine.template")) { - fs::recursive_copy(homepath + "/.wine.template", fullbottlepath); - return; + if (!dryrun) { + fs::recursive_copy(homepath + "/.wine.template", fullbottlepath); + return; + } } else { - output::error("no template bottle"); + output::error("no template bottle, create one using \"cellar create template\""); return; } } else { if (boost::filesystem::exists(homepath + "/.wine")) { output::statement("using existing bottle at ~/.wine as template bottle"); - fs::recursive_copy(homepath + "/.wine", fullbottlepath); + if (!dryrun) { fs::recursive_copy(homepath + "/.wine", fullbottlepath); } } else { output::statement("creating template bottle from scratch"); - setenv("WINEPREFIX", fullbottlepath.c_str(), 1); - launch::popen("wineboot -u"); + if (!dryrun) { + setenv("WINEPREFIX", fullbottlepath.c_str(), 1); + launch::popen("wineboot -u"); + } } } } diff --git a/src/bottles/remove.cpp b/src/bottles/remove.cpp index 9d1c6d5..0556401 100644 --- a/src/bottles/remove.cpp +++ b/src/bottles/remove.cpp @@ -6,6 +6,7 @@ #include #include "bottles.hpp" +#include "cellar.hpp" #include "internal/bottles.hpp" #include "fs.hpp" #include "output.hpp" @@ -34,5 +35,6 @@ void cellar::bottles::remove_bottle(int argc, vector argv) { return; } - fs::recursive_remove(fullbottlepath); + output::statement("removing " + fullbottlepath, true); + if (!dryrun) { fs::recursive_remove(fullbottlepath); } }