launching commands!
This commit is contained in:
@@ -15,6 +15,15 @@
|
||||
#include "output.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
/*[[[cog
|
||||
import cog
|
||||
|
||||
with open("src/modules.txt") as modules:
|
||||
for module in modules:
|
||||
cog.outl("#include \"internal/{0}.hpp\"".format(module.strip()))
|
||||
]]]*/
|
||||
//[[[end]]]
|
||||
|
||||
using namespace std;
|
||||
using namespace cellar;
|
||||
using json = nlohmann::json;
|
||||
|
28
src/launch/commands.cpp.cog
Normal file
28
src/launch/commands.cpp.cog
Normal file
@@ -0,0 +1,28 @@
|
||||
// vim: filetype=cpp :
|
||||
#include <map>
|
||||
|
||||
#include "launch.hpp"
|
||||
#include "internal/launch.hpp"
|
||||
#include "commands.hpp"
|
||||
#include "dll.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cellar::launch;
|
||||
using namespace cellar::commands;
|
||||
|
||||
DLL_PUBLIC map<string, CommandFunction> cellar::commands::launch_commands() {
|
||||
map<string, CommandFunction> result;
|
||||
/*[[[cog
|
||||
import cog
|
||||
|
||||
with open("src/launch/commands.txt") as commandfile:
|
||||
for line in commandfile:
|
||||
linesplit = line.strip().split(" ")
|
||||
name = linesplit[0]
|
||||
func = linesplit[1]
|
||||
|
||||
cog.outl("result.insert(pair<string,CommandFunction>(\"{0}\", &{1}));".format(name, func))
|
||||
]]]*/
|
||||
//[[[end]]]
|
||||
return result;
|
||||
}
|
3
src/launch/commands.txt
Normal file
3
src/launch/commands.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
launch launch_command
|
||||
winecfg launch_winecfg
|
||||
regedit launch_regedit
|
30
src/launch/launch.cpp
Normal file
30
src/launch/launch.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include "subprocess.hpp"
|
||||
|
||||
#include "launch.hpp"
|
||||
#include "internal/launch.hpp"
|
||||
#include "output.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cellar;
|
||||
|
||||
void cellar::launch::launch_program(vector<string> args) {
|
||||
vector<string> wineargs = args;
|
||||
wineargs[0] = "wine";
|
||||
|
||||
string winelaunch = boost::algorithm::join(wineargs, " ");
|
||||
auto wine = subprocess::Popen(winelaunch);
|
||||
wine.wait();
|
||||
}
|
||||
|
||||
void cellar::launch::launch_command(int argc, vector<string> args) {
|
||||
if (argc == 1) {
|
||||
output::error("forgot to specify a command");
|
||||
return;
|
||||
}
|
||||
launch::launch_program(args);
|
||||
}
|
27
src/launch/shortcuts.cpp
Normal file
27
src/launch/shortcuts.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "launch.hpp"
|
||||
#include "internal/launch.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void cellar::launch::launch_winecfg(int argc, vector<string> argv) {
|
||||
// cheap alias for "cellar launch winecfg"
|
||||
vector<string> launchargs;
|
||||
launchargs.push_back("cellar launch");
|
||||
launchargs.push_back("winecfg");
|
||||
|
||||
cellar::launch::launch_program(launchargs);
|
||||
}
|
||||
|
||||
void cellar::launch::launch_regedit(int argc, vector<string> argv) {
|
||||
// cheap alias for "cellar launch regedit"
|
||||
vector<string> launchargs;
|
||||
launchargs.push_back("cellar launch");
|
||||
launchargs.push_back("regedit");
|
||||
|
||||
if (argc > 1) { launchargs.push_back(argv[1]); }
|
||||
|
||||
cellar::launch::launch_program(launchargs);
|
||||
}
|
@@ -1,2 +1,3 @@
|
||||
core
|
||||
bottles
|
||||
launch
|
||||
|
Reference in New Issue
Block a user