From 5024b69dcbe9b76658705789b01bce6e75b9179a Mon Sep 17 00:00:00 2001 From: Nicholas O'Connor Date: Fri, 24 Mar 2017 22:05:22 -0700 Subject: [PATCH] core command reorganizing, including splitting off help for new help system --- CMakeLists.txt | 2 +- include/cellar.hpp | 1 - include/commands.hpp | 2 -- src/cellar.cpp.cog | 5 ----- src/commands.cpp.cog | 21 +-------------------- src/modules.txt | 1 + src/version.cpp.cog | 3 ++- 7 files changed, 5 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b24470..b0bf54a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ add_dependencies(launch cog) 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) + ${src}/version.cpp ${src}/output.cpp ${src}/help/help.cpp) target_link_libraries(cellar ${Boost_LIBRARIES} bottles launch) add_dependencies(cellar cog) # effectively redundant but a couple of the bin's # files are cogged, so this is mostly for people diff --git a/include/cellar.hpp b/include/cellar.hpp index 11c1cb3..7c80176 100644 --- a/include/cellar.hpp +++ b/include/cellar.hpp @@ -10,7 +10,6 @@ using namespace std; namespace cellar { extern void print_header(); - extern void print_version(int,vector); extern bottles::Bottle active_bottle; diff --git a/include/commands.hpp b/include/commands.hpp index 7fa169e..482b8be 100644 --- a/include/commands.hpp +++ b/include/commands.hpp @@ -14,8 +14,6 @@ namespace cellar { void add_command(string, CommandFunction); vector list_commands(); - - extern map core_commands(); } } diff --git a/src/cellar.cpp.cog b/src/cellar.cpp.cog index 82b2406..41ecac1 100644 --- a/src/cellar.cpp.cog +++ b/src/cellar.cpp.cog @@ -65,11 +65,6 @@ int main(int argc, char* argv[]) { verbose = verbosearg.getValue(); - // hardcoded because it's special - for (auto item : commands::core_commands()) { - commands::command_map[item.first] = item.second; - } - // as above, but cogged from src/modules.txt // BULLSHIT: trying to use str.format on this string causes bizarre compiler errors /*[[[cog import cog diff --git a/src/commands.cpp.cog b/src/commands.cpp.cog index ef68830..7b3ac3d 100644 --- a/src/commands.cpp.cog +++ b/src/commands.cpp.cog @@ -4,6 +4,7 @@ #include #include "commands.hpp" +#include "internal/core.hpp" #include "cellar.hpp" using namespace std; @@ -19,26 +20,6 @@ vector cellar::commands::list_commands() { return result; } -void help_command(int argc, vector argv) { - vector commands = list_commands(); - cellar::print_header(); - - cout << "You have these commands:\n" << endl; - - int num_columns = 4; - int cur_column = 1; - for (string command : commands) { - cout << "\t" << command; - if (cur_column == num_columns) { - cout << endl; - cur_column = 1; - } else { - cur_column++; - } - } - cout << endl; -} - map cellar::commands::core_commands() { map result; /*[[[cog diff --git a/src/modules.txt b/src/modules.txt index e9de022..8aee732 100644 --- a/src/modules.txt +++ b/src/modules.txt @@ -1,2 +1,3 @@ +core bottles launch diff --git a/src/version.cpp.cog b/src/version.cpp.cog index 1750e02..c478ca1 100644 --- a/src/version.cpp.cog +++ b/src/version.cpp.cog @@ -4,6 +4,7 @@ #include #include "cellar.hpp" +#include "internal/core.hpp" #include "commands.hpp" #include "output.hpp" #include "version.hpp" @@ -42,6 +43,6 @@ string cellar::version::short_version() { //[[[end]]] } -void cellar::print_version(int argc, vector argv) { +void cellar::commands::print_version(int argc, vector argv) { cellar::output::statement(short_version()); }