diff --git a/src/bottles/commands.cpp.cog b/src/bottles/commands.cpp.cog index 8d07562..b0e0204 100644 --- a/src/bottles/commands.cpp.cog +++ b/src/bottles/commands.cpp.cog @@ -4,46 +4,45 @@ #include "bottles.hpp" #include "internal/bottles.hpp" #include "commands.hpp" -#include "dll.hpp" #include "help.hpp" using namespace std; using namespace cellar::bottles; using namespace cellar::commands; -DLL_PUBLIC map cellar::commands::bottles_commands() { +map cellar::commands::bottles_commands() { map result; - /*[[[cog - import cog - import os - - with open("src/bottles/commands.txt") as commandfile: - for line in commandfile: - linesplit = line.strip().split(" ") - name = linesplit[0] - func = linesplit[1] - - cog.outl("result.insert(pair(\"{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 - else: - print("-- No description is available for the {0} command.".format(name)) - - if os.path.exists("src/bottles/help/" + name): - cog.out("cellar::help::set_details(\"{0}\", R\"(".format(name)) - with open("src/bottles/help/" + name) as detailsfile: - for detail in detailsfile: - cog.out(detail, dedent=True, trimblanklines=True) - cog.out(")\");") - else: - print("-- No details are available for the {0} command.".format(name)) - ]]]*/ - //[[[end]]] +/*[[[cog + import cog + import os + + with open("src/bottles/commands.txt") as commandfile: + for line in commandfile: + linesplit = line.strip().split(" ") + name = linesplit[0] + func = linesplit[1] + + cog.outl("result.insert(pair(\"{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 + else: + print("-- No description is available for the {0} command.".format(name)) + + if os.path.exists("src/bottles/help/" + name): + cog.out("cellar::help::set_details(\"{0}\", R\"(".format(name)) + with open("src/bottles/help/" + name) as detailsfile: + for detail in detailsfile: + cog.out(detail, trimblanklines=True) + cog.out(")\");") + else: + print("-- No details are available for the {0} command.".format(name)) + ]]]*/ +//[[[end]]] return result; } diff --git a/src/commands.cpp.cog b/src/commands.cpp.cog index d65f9bf..21fa6bf 100644 --- a/src/commands.cpp.cog +++ b/src/commands.cpp.cog @@ -23,37 +23,37 @@ vector cellar::commands::list_commands() { map cellar::commands::core_commands() { map result; - /*[[[cog - import cog - import os.path +/*[[[cog + import cog + import os.path - with open("src/commands.txt") as commandfile: - for line in commandfile: - linesplit = line.strip().split(" ") - name = linesplit[0] - func = linesplit[1] + with open("src/commands.txt") as commandfile: + for line in commandfile: + linesplit = line.strip().split(" ") + name = linesplit[0] + func = linesplit[1] - cog.outl("result.insert(pair(\"{0}\", &{1}));".format(name, func)) + cog.outl("result.insert(pair(\"{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 - else: - print("-- No description is available for the {0} command.".format(name)) + 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 + else: + print("-- No description is available for the {0} command.".format(name)) - if os.path.exists("src/help/" + name): - cog.out("cellar::help::set_details(\"{0}\", R\"(".format(name)) - with open("src/help/" + name) as detailsfile: - for detail in detailsfile: - cog.out(detail, dedent=True, trimblanklines=True) - cog.out(")\");") - else: - print("-- No details are available for the {0} command.".format(name)) - ]]]*/ - //[[[end]]] + if os.path.exists("src/help/" + name): + cog.out("cellar::help::set_details(\"{0}\", R\"(".format(name)) + with open("src/help/" + name) as detailsfile: + for detail in detailsfile: + cog.out(detail, trimblanklines=True) + cog.out(")\");") + else: + print("-- No details are available for the {0} command.".format(name)) + ]]]*/ +//[[[end]]] return result; } diff --git a/src/launch/commands.cpp.cog b/src/launch/commands.cpp.cog index 65c940c..ada2414 100644 --- a/src/launch/commands.cpp.cog +++ b/src/launch/commands.cpp.cog @@ -13,37 +13,37 @@ using namespace cellar::commands; DLL_PUBLIC map cellar::commands::launch_commands() { map result; - /*[[[cog - import cog - import os +/*[[[cog + import cog + import os - with open("src/launch/commands.txt") as commandfile: - for line in commandfile: - linesplit = line.strip().split(" ") - name = linesplit[0] - func = linesplit[1] + with open("src/launch/commands.txt") as commandfile: + for line in commandfile: + linesplit = line.strip().split(" ") + name = linesplit[0] + func = linesplit[1] - cog.outl("result.insert(pair(\"{0}\", &{1}));".format(name, func)) + cog.outl("result.insert(pair(\"{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 - else: - print("-- No description is available for the {0} command.".format(name)) + 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 + else: + print("-- No description is available for the {0} command.".format(name)) - if os.path.exists("src/launch/help/" + name): - cog.out("cellar::help::set_details(\"{0}\", R\"(".format(name)) - with open("src/launch/help/" + name) as detailsfile: - for detail in detailsfile: - cog.out(detail, dedent=True, trimblanklines=True) - cog.out(")\");") - else: - print("-- No details are available for the {0} command.".format(name)) - ]]]*/ - //[[[end]]] + if os.path.exists("src/launch/help/" + name): + cog.out("cellar::help::set_details(\"{0}\", R\"(".format(name)) + with open("src/launch/help/" + name) as detailsfile: + for detail in detailsfile: + cog.out(detail, trimblanklines=True) + cog.out(")\");") + else: + print("-- No details are available for the {0} command.".format(name)) + ]]]*/ +//[[[end]]] return result; }