create and remove respect dryrun

This commit is contained in:
Nicholas O'Connor 2017-07-05 16:36:49 -07:00
parent 738606b851
commit b979bb7a0a
2 changed files with 16 additions and 7 deletions

View File

@ -7,6 +7,7 @@
#include <tclap/CmdLine.h>
#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<string> 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")) {
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");
if (!dryrun) {
setenv("WINEPREFIX", fullbottlepath.c_str(), 1);
launch::popen("wineboot -u");
}
}
}
}

View File

@ -6,6 +6,7 @@
#include <boost/filesystem/path.hpp>
#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<string> argv) {
return;
}
fs::recursive_remove(fullbottlepath);
output::statement("removing " + fullbottlepath, true);
if (!dryrun) { fs::recursive_remove(fullbottlepath); }
}