diff --git a/include/commands.hpp b/include/commands.hpp index 2bc7e3c..482b8be 100644 --- a/include/commands.hpp +++ b/include/commands.hpp @@ -9,7 +9,7 @@ using namespace std; namespace cellar { namespace commands { - typedef void (*CommandFunction)(int, char*[]); + typedef void (*CommandFunction)(int, vector); extern map command_map; void add_command(string, CommandFunction); diff --git a/include/internal/bottles.hpp.cog b/include/internal/bottles.hpp.cog index 23b0518..e1961ee 100644 --- a/include/internal/bottles.hpp.cog +++ b/include/internal/bottles.hpp.cog @@ -11,7 +11,7 @@ namespace cellar { with open("src/bottles/commands.txt") as commandsfile: for line in commandsfile: item = line.strip().split(" ") - cog.outl("extern void {0} (int, char**);".format(item[1])) + cog.outl("extern void {0} (int, vector);".format(item[1])) ]]]*/ //[[[end]]] } diff --git a/src/bottles/activate.cpp b/src/bottles/activate.cpp index 07099ee..7062d0b 100644 --- a/src/bottles/activate.cpp +++ b/src/bottles/activate.cpp @@ -1,10 +1,12 @@ #include +#include +#include #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 argv) { cout << argc << endl; } diff --git a/src/bottles/active.cpp b/src/bottles/active.cpp index cbd40e0..ec76458 100644 --- a/src/bottles/active.cpp +++ b/src/bottles/active.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #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 argv) { map bottlemap = get_bottles(); if (bottlemap.find(".wine") == bottlemap.end()) { // not found cout << "no active wine bottle" << endl; diff --git a/src/bottles/bottles.cpp b/src/bottles/bottles.cpp index ee2626b..eee6e2a 100644 --- a/src/bottles/bottles.cpp +++ b/src/bottles/bottles.cpp @@ -75,7 +75,7 @@ DLL_PUBLIC map cellar::bottles::get_bottles() { return result; } -void cellar::bottles::print_bottles(int argc, char** argv) { +void cellar::bottles::print_bottles(int argc, vector argv) { map bottles = get_bottles(); for (auto item : bottles) { diff --git a/src/cellar.cpp b/src/cellar.cpp index 93a9e51..e00c684 100644 --- a/src/cellar.cpp +++ b/src/cellar.cpp @@ -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 subargv; + commands::command_map[usercmd](subargc, subargv); } else { cerr << "invalid command: " << usercmd << endl; return 1; diff --git a/src/commands.cpp b/src/commands.cpp index 89da87d..1f2865d 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include "commands.hpp" #include "cellar.hpp" @@ -16,7 +18,7 @@ vector cellar::commands::list_commands() { return result; } -void help_command(int argc, char** argv) { +void help_command(int argc, vector argv) { vector commands = list_commands(); cellar::print_header(); diff --git a/src/version.cpp.cog b/src/version.cpp.cog index d122e15..6a80c68 100644 --- a/src/version.cpp.cog +++ b/src/version.cpp.cog @@ -1,5 +1,7 @@ // vim: filetype=cpp : #include +#include +#include #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 argv) { cout << short_version() << endl; } cellar::commands::CommandFunction versioncmd = cellar::commands::command_map["version"] = &print_version;