cogged bottle command code, should be easier to add commands
This commit is contained in:
		
							
								
								
									
										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
 | 
			
		||||
		Reference in New Issue
	
	Block a user