core command reorganizing, including splitting off help for new help system

This commit is contained in:
Nicholas O'Connor 2017-03-24 22:05:22 -07:00
parent 06512f0503
commit 5024b69dcb
7 changed files with 5 additions and 30 deletions

View File

@ -62,7 +62,7 @@ add_dependencies(launch cog)
add_custom_target(cog ALL DEPENDS ${coggedfiles}) add_custom_target(cog ALL DEPENDS ${coggedfiles})
add_executable(cellar ${src}/cellar.cpp ${src}/commands.cpp ${src}/fs.cpp 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) target_link_libraries(cellar ${Boost_LIBRARIES} bottles launch)
add_dependencies(cellar cog) # effectively redundant but a couple of the bin's add_dependencies(cellar cog) # effectively redundant but a couple of the bin's
# files are cogged, so this is mostly for people # files are cogged, so this is mostly for people

View File

@ -10,7 +10,6 @@ using namespace std;
namespace cellar { namespace cellar {
extern void print_header(); extern void print_header();
extern void print_version(int,vector<string>);
extern bottles::Bottle active_bottle; extern bottles::Bottle active_bottle;

View File

@ -14,8 +14,6 @@ namespace cellar {
void add_command(string, CommandFunction); void add_command(string, CommandFunction);
vector<string> list_commands(); vector<string> list_commands();
extern map<string,CommandFunction> core_commands();
} }
} }

View File

@ -65,11 +65,6 @@ int main(int argc, char* argv[]) {
verbose = verbosearg.getValue(); 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 // BULLSHIT: trying to use str.format on this string causes bizarre compiler errors
/*[[[cog /*[[[cog
import cog import cog

View File

@ -4,6 +4,7 @@
#include <vector> #include <vector>
#include "commands.hpp" #include "commands.hpp"
#include "internal/core.hpp"
#include "cellar.hpp" #include "cellar.hpp"
using namespace std; using namespace std;
@ -19,26 +20,6 @@ vector<string> cellar::commands::list_commands() {
return result; return result;
} }
void help_command(int argc, vector<string> argv) {
vector<string> 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<string, CommandFunction> cellar::commands::core_commands() { map<string, CommandFunction> cellar::commands::core_commands() {
map<string, CommandFunction> result; map<string, CommandFunction> result;
/*[[[cog /*[[[cog

View File

@ -1,2 +1,3 @@
core
bottles bottles
launch launch

View File

@ -4,6 +4,7 @@
#include <vector> #include <vector>
#include "cellar.hpp" #include "cellar.hpp"
#include "internal/core.hpp"
#include "commands.hpp" #include "commands.hpp"
#include "output.hpp" #include "output.hpp"
#include "version.hpp" #include "version.hpp"
@ -42,6 +43,6 @@ string cellar::version::short_version() {
//[[[end]]] //[[[end]]]
} }
void cellar::print_version(int argc, vector<string> argv) { void cellar::commands::print_version(int argc, vector<string> argv) {
cellar::output::statement(short_version()); cellar::output::statement(short_version());
} }