help descriptions now understood by the cog files, no implementation yet, don't try to build this

This commit is contained in:
Nicholas O'Connor 2017-03-24 23:05:31 -07:00
parent 405ba80d8d
commit a5a8fb284c
6 changed files with 42 additions and 1 deletions

15
include/help.hpp Normal file
View File

@ -0,0 +1,15 @@
#ifndef __HELP_HPP
#define __HELP_HPP
#pragma once
#include <string>
using namespace std;
namespace cellar {
namespace help {
extern void set_description(string,string);
}
}
#endif // __HELP_HPP

View File

@ -22,6 +22,14 @@ DLL_PUBLIC map<string, CommandFunction> cellar::commands::bottles_commands() {
func = linesplit[1] func = linesplit[1]
cog.outl("result.insert(pair<string,CommandFunction>(\"{0}\", &{1}));".format(name, func)) cog.outl("result.insert(pair<string,CommandFunction>(\"{0}\", &{1}));".format(name, func))
if (len(linesplit) > 2):
desc = " ".join(linesplit[2:]) # Rest of line assumed to be description
cog.outl("cellar::help::set_description(\"{0}\", \"{1}\");"
.format(name, desc
.replace("\"", "\\\"")
.replace("\\", "\\\\")))
# the replace methods escape " and \ characters
]]]*/ ]]]*/
//[[[end]]] //[[[end]]]
return result; return result;

View File

@ -6,6 +6,7 @@
#include "commands.hpp" #include "commands.hpp"
#include "internal/core.hpp" #include "internal/core.hpp"
#include "cellar.hpp" #include "cellar.hpp"
#include "help.hpp"
using namespace std; using namespace std;
using namespace cellar::commands; using namespace cellar::commands;
@ -32,6 +33,14 @@ map<string, CommandFunction> cellar::commands::core_commands() {
func = linesplit[1] func = linesplit[1]
cog.outl("result.insert(pair<string,CommandFunction>(\"{0}\", &{1}));".format(name, func)) cog.outl("result.insert(pair<string,CommandFunction>(\"{0}\", &{1}));".format(name, func))
if (len(linesplit) > 2):
desc = " ".join(linesplit[2:]) # Rest of line assumed to be description
cog.outl("cellar::help::set_description(\"{0}\", \"{1}\");"
.format(name, desc
.replace("\"", "\\\"")
.replace("\\", "\\\\")))
# the replace methods escape " and \ characters
]]]*/ ]]]*/
//[[[end]]] //[[[end]]]
return result; return result;

View File

@ -1,2 +1,2 @@
version print_version version print_version Prints version information.
help help_command help help_command

View File

@ -3,6 +3,7 @@
#include "cellar.hpp" #include "cellar.hpp"
#include "internal/core.hpp" #include "internal/core.hpp"
#include "help.cpp"
using namespace std; using namespace std;

View File

@ -22,6 +22,14 @@ DLL_PUBLIC map<string, CommandFunction> cellar::commands::launch_commands() {
func = linesplit[1] func = linesplit[1]
cog.outl("result.insert(pair<string,CommandFunction>(\"{0}\", &{1}));".format(name, func)) cog.outl("result.insert(pair<string,CommandFunction>(\"{0}\", &{1}));".format(name, func))
if (len(linesplit) > 2):
desc = " ".join(linesplit[2:]) # Rest of line assumed to be description
cog.outl("cellar::help::set_description(\"{0}\", \"{1}\");"
.format(name, desc
.replace("\"", "\\\"")
.replace("\\", "\\\\")))
# the replace methods escape " and \ characters
]]]*/ ]]]*/
//[[[end]]] //[[[end]]]
return result; return result;