diff --git a/include/internal/launch.hpp.cog b/include/internal/launch.hpp.cog index a4fcdbc..330d980 100644 --- a/include/internal/launch.hpp.cog +++ b/include/internal/launch.hpp.cog @@ -12,6 +12,8 @@ using namespace cellar::commands; namespace cellar { namespace launch { + extern void popen(string); + /*[[[cog import cog diff --git a/src/launch/commands.txt b/src/launch/commands.txt index 8b6b208..6e78344 100644 --- a/src/launch/commands.txt +++ b/src/launch/commands.txt @@ -1,3 +1,4 @@ launch launch_command Launch a program in WINE. winecfg launch_winecfg Launch winecfg. regedit launch_regedit Launch regedit. +winetricks winetricks Launch winetricks. diff --git a/src/launch/launch.cpp b/src/launch/launch.cpp index a0928ea..8559d92 100644 --- a/src/launch/launch.cpp +++ b/src/launch/launch.cpp @@ -15,10 +15,9 @@ using namespace cellar; void cellar::launch::launch_program(vector args) { vector wineargs = args; wineargs[0] = "wine"; - + string winelaunch = boost::algorithm::join(wineargs, " "); - auto wine = subprocess::Popen(winelaunch); - wine.wait(); + launch::popen(winelaunch); } void cellar::launch::launch_command(int argc, vector args) { @@ -28,3 +27,9 @@ void cellar::launch::launch_command(int argc, vector args) { } launch::launch_program(args); } + +// BULLSHIT: subprocess.hpp throws linker errors if included in multiple files +void cellar::launch::popen(string argv) { + auto wine = subprocess::Popen(argv); + wine.wait(); +} diff --git a/src/launch/winetricks.cpp b/src/launch/winetricks.cpp new file mode 100644 index 0000000..f8bd91e --- /dev/null +++ b/src/launch/winetricks.cpp @@ -0,0 +1,39 @@ +#include +#include + +#include +// linker claims the one time in launch.cpp was enough, we'll believe it +//#include "subprocess.hpp" + +#include "bottles.hpp" +#include "cellar.hpp" +#include "launch.hpp" +#include "internal/launch.hpp" +#include "output.hpp" + +using namespace std; +using namespace cellar; + +void cellar::launch::winetricks(int argc, vector argv) { + if (argc == 1) { + output::error(""); + return; + } + + auto winetricks_argv = argv; + winetricks_argv[0] = "winetricks"; + string winetricks_str = boost::algorithm::join(winetricks_argv, " "); + //output::statement(winetricks_str); + launch::popen(winetricks_str); + + if (cellar::active_bottle.config.find("winetricks") == cellar::active_bottle.config.end()) { + cellar::active_bottle.config.emplace("winetricks", vector()); + } + for (string winetrick : winetricks_argv) { + if (winetrick == "winetricks") { continue; } + else if (winetrick.substr(0,1) == "-") { continue; } // opts don't get saved + else { cellar::active_bottle.config["winetricks"].push_back(winetrick); } + } + + cellar::active_bottle.save_config(); +}