cogged bottle command code, should be easier to add commands
This commit is contained in:
parent
30d0787a62
commit
91e7ba7990
@ -35,11 +35,11 @@ foreach(cogfile ${cogfiles})
|
||||
set(coggedfiles ${coggedfiles} "${thisfile}")
|
||||
endforeach(cogfile)
|
||||
|
||||
add_library(bottles SHARED ${src}/bottles/bottles.cpp)
|
||||
add_library(bottles SHARED ${src}/bottles/bottles.cpp
|
||||
${src}/bottles/active.cpp ${src}/bottles/commands.cpp)
|
||||
|
||||
add_custom_target(cog ALL DEPENDS ${coggedfiles})
|
||||
|
||||
add_executable(cellar ${src}/cellar.cpp ${src}/commands.cpp ${src}/fs.cpp
|
||||
${src}/version.cpp)
|
||||
add_dependencies(cellar cog)
|
||||
target_link_libraries(cellar ${Boost_LIBRARIES} bottles)
|
||||
|
12
include/internal/bottles.hpp
Normal file
12
include/internal/bottles.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef __INTERNAL_BOTTLES_HPP
|
||||
#define __INTERNAL_BOTTLES_HPP
|
||||
#pragma once
|
||||
|
||||
namespace cellar {
|
||||
namespace bottles {
|
||||
extern void print_bottles(int,char**);
|
||||
extern void print_active_bottle(int,char**);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __INTERNAL_BOTTLES_HPP
|
11
src/bottles/active.cpp
Normal file
11
src/bottles/active.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "bottles.hpp"
|
||||
#include "internal/bottles.hpp"
|
||||
#include "dll.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
DLL_PUBLIC void cellar::bottles::print_active_bottle(int argc, char** argv) {
|
||||
cout << "i just want to make sure cmake likes it first" << endl;
|
||||
}
|
@ -10,7 +10,7 @@
|
||||
#include "json.hpp"
|
||||
|
||||
#include "bottles.hpp"
|
||||
#include "commands.hpp"
|
||||
#include "internal/bottles.hpp"
|
||||
#include "dll.hpp"
|
||||
#include "fs.hpp"
|
||||
|
||||
@ -33,7 +33,7 @@ DLL_PUBLIC map<string, Bottle> cellar::bottles::get_bottles() {
|
||||
string homepath = getenv("HOME");
|
||||
vector<string> homedir = cellar::fs::listdir(homepath);
|
||||
for (string item : homedir) {
|
||||
if (item.substr(0,6) == ".wine.") {
|
||||
if (item.substr(0,5) == ".wine") {
|
||||
Bottle output;
|
||||
|
||||
string fullitem = homepath + "/" + item;
|
||||
@ -75,7 +75,7 @@ DLL_PUBLIC map<string, Bottle> cellar::bottles::get_bottles() {
|
||||
return result;
|
||||
}
|
||||
|
||||
void print_bottles(int argc, char** argv) {
|
||||
void cellar::bottles::print_bottles(int argc, char** argv) {
|
||||
map<string, Bottle> bottles = get_bottles();
|
||||
|
||||
for (auto item : bottles) {
|
||||
@ -97,8 +97,3 @@ void print_bottles(int argc, char** argv) {
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
DLL_PUBLIC map<string, CommandFunction> cellar::commands::bottles_commands() {
|
||||
map<string, CommandFunction> result;
|
||||
result.insert(pair<string,CommandFunction>("list", &print_bottles));
|
||||
return result;
|
||||
}
|
||||
|
28
src/bottles/commands.cpp.cog
Normal file
28
src/bottles/commands.cpp.cog
Normal file
@ -0,0 +1,28 @@
|
||||
// vim: filetype=cpp :
|
||||
#include <map>
|
||||
|
||||
#include "bottles.hpp"
|
||||
#include "internal/bottles.hpp"
|
||||
#include "commands.hpp"
|
||||
#include "dll.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cellar::bottles;
|
||||
using namespace cellar::commands;
|
||||
|
||||
DLL_PUBLIC map<string, CommandFunction> cellar::commands::bottles_commands() {
|
||||
map<string, CommandFunction> result;
|
||||
/*[[[cog
|
||||
import cog
|
||||
|
||||
with open("src/bottles/commands.txt") as commandfile:
|
||||
for line in commandfile:
|
||||
linesplit = line.split(" ")
|
||||
name = linesplit[0]
|
||||
func = linesplit[1]
|
||||
|
||||
cog.outl("result.insert(pair<string,CommandFunction>(\"{0}\", &{1}));".format(name, func))
|
||||
]]]*/
|
||||
//[[[end]]]
|
||||
return result;
|
||||
}
|
2
src/bottles/commands.txt
Normal file
2
src/bottles/commands.txt
Normal file
@ -0,0 +1,2 @@
|
||||
list print_bottles
|
||||
active print_active_bottle
|
Loading…
Reference in New Issue
Block a user