switched commandfunction to vector<string>
This commit is contained in:
		@@ -1,10 +1,12 @@
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
#include "bottles.hpp"
 | 
			
		||||
#include "internal/bottles.hpp"
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
void cellar::bottles::switch_active_bottle(int argc, char** argv) {
 | 
			
		||||
void cellar::bottles::switch_active_bottle(int argc, vector<string> argv) {
 | 
			
		||||
    cout << argc << endl;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <map>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
#include "bottles.hpp"
 | 
			
		||||
#include "internal/bottles.hpp"
 | 
			
		||||
@@ -9,7 +10,7 @@
 | 
			
		||||
using namespace std;
 | 
			
		||||
using namespace cellar::bottles;
 | 
			
		||||
 | 
			
		||||
void cellar::bottles::print_active_bottle(int argc, char** argv) {
 | 
			
		||||
void cellar::bottles::print_active_bottle(int argc, vector<string> argv) {
 | 
			
		||||
    map<string, Bottle> bottlemap = get_bottles();
 | 
			
		||||
    if (bottlemap.find(".wine") == bottlemap.end()) { // not found
 | 
			
		||||
        cout << "no active wine bottle" << endl;
 | 
			
		||||
 
 | 
			
		||||
@@ -75,7 +75,7 @@ DLL_PUBLIC map<string, Bottle> cellar::bottles::get_bottles() {
 | 
			
		||||
	return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void cellar::bottles::print_bottles(int argc, char** argv) {
 | 
			
		||||
void cellar::bottles::print_bottles(int argc, vector<string> argv) {
 | 
			
		||||
    map<string, Bottle> bottles = get_bottles();
 | 
			
		||||
 | 
			
		||||
    for (auto item : bottles) {
 | 
			
		||||
 
 | 
			
		||||
@@ -43,7 +43,9 @@ int main(int argc, char* argv[]) {
 | 
			
		||||
 | 
			
		||||
        string usercmd = command.getValue();
 | 
			
		||||
        if (commands::command_map.count(usercmd) > 0) {
 | 
			
		||||
            commands::command_map[usercmd](argc, argv);
 | 
			
		||||
            int subargc = 0;
 | 
			
		||||
            vector<string> subargv;
 | 
			
		||||
            commands::command_map[usercmd](subargc, subargv);
 | 
			
		||||
        } else {
 | 
			
		||||
            cerr << "invalid command: " << usercmd << endl;
 | 
			
		||||
            return 1;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,6 @@
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
#include "commands.hpp"
 | 
			
		||||
#include "cellar.hpp"
 | 
			
		||||
@@ -16,7 +18,7 @@ vector<string> cellar::commands::list_commands() {
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void help_command(int argc, char** argv) {
 | 
			
		||||
void help_command(int argc, vector<string> argv) {
 | 
			
		||||
    vector<string> commands = list_commands();
 | 
			
		||||
    cellar::print_header();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
// vim: filetype=cpp :
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
#include "commands.hpp"
 | 
			
		||||
#include "version.hpp"
 | 
			
		||||
@@ -38,7 +40,7 @@ string cellar::version::short_version() {
 | 
			
		||||
    //[[[end]]]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void print_version(int argc, char** argv) {
 | 
			
		||||
void print_version(int argc, vector<string> argv) {
 | 
			
		||||
    cout << short_version() << endl;
 | 
			
		||||
}
 | 
			
		||||
cellar::commands::CommandFunction versioncmd = cellar::commands::command_map["version"] = &print_version;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user