launching commands!
This commit is contained in:
parent
325413f3f2
commit
1c91618f5c
@ -54,11 +54,14 @@ add_library(bottles SHARED ${src}/bottles/bottles.cpp
|
||||
${src}/bottles/activate.cpp)
|
||||
add_dependencies(bottles cog)
|
||||
|
||||
add_library(launch SHARED ${src}/launch/launch.cpp ${src}/launch/commands.cpp
|
||||
${src}/launch/shortcuts.cpp)
|
||||
|
||||
add_custom_target(cog ALL DEPENDS ${coggedfiles})
|
||||
|
||||
add_executable(cellar ${src}/cellar.cpp ${src}/commands.cpp ${src}/fs.cpp
|
||||
${src}/version.cpp ${src}/output.cpp)
|
||||
target_link_libraries(cellar ${Boost_LIBRARIES} bottles)
|
||||
target_link_libraries(cellar ${Boost_LIBRARIES} bottles launch)
|
||||
|
||||
install(TARGETS cellar bottles
|
||||
RUNTIME DESTINATION bin
|
||||
|
@ -30,9 +30,6 @@ namespace cellar {
|
||||
};
|
||||
extern map<string, Bottle> get_bottles();
|
||||
}
|
||||
namespace commands {
|
||||
extern map<string, cellar::commands::CommandFunction> bottles_commands();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __BOTTLES_HPP
|
||||
|
@ -3,6 +3,13 @@
|
||||
#define __INTERNAL_BOTTLES_HPP
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
using namespace cellar::commands;
|
||||
|
||||
namespace cellar {
|
||||
namespace bottles {
|
||||
/*[[[cog
|
||||
@ -15,6 +22,9 @@ namespace cellar {
|
||||
]]]*/
|
||||
//[[[end]]]
|
||||
}
|
||||
namespace commands {
|
||||
extern map<string, cellar::commands::CommandFunction> bottles_commands();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __INTERNAL_BOTTLES_HPP
|
||||
|
1
include/internal/core.hpp
Normal file
1
include/internal/core.hpp
Normal file
@ -0,0 +1 @@
|
||||
// dummy file
|
30
include/internal/launch.hpp.cog
Normal file
30
include/internal/launch.hpp.cog
Normal file
@ -0,0 +1,30 @@
|
||||
// vim: filetype=cpp :
|
||||
#ifndef __INTERNAL_LAUNCH_HPP
|
||||
#define __INTERNAL_LAUNCH_HPP
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
using namespace cellar::commands;
|
||||
|
||||
namespace cellar {
|
||||
namespace launch {
|
||||
/*[[[cog
|
||||
import cog
|
||||
|
||||
with open("src/launch/commands.txt") as commandsfile:
|
||||
for line in commandsfile:
|
||||
item = line.strip().split(" ")
|
||||
cog.outl("extern void {0} (int, vector<string>);".format(item[1]))
|
||||
]]]*/
|
||||
//[[[end]]]
|
||||
}
|
||||
namespace commands {
|
||||
extern map<string,CommandFunction> launch_commands();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __INTERNAL_LAUNCH_HPP
|
16
include/launch.hpp
Normal file
16
include/launch.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef __LAUNCH_HPP
|
||||
#define __LAUNCH_HPP
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace cellar {
|
||||
namespace launch {
|
||||
extern void launch_program (vector<string>);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __LAUNCH_HPP
|
1622
include/subprocess.hpp
Normal file
1622
include/subprocess.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user