]> git.armaanb.net Git - gen-shell.git/blobdiff - src/main.cpp
combined files
[gen-shell.git] / src / main.cpp
index 1e8f1d2496742a2a8b2bc9919d4a8d40e0e58b7c..3d0e2c65d6d3c9e5fed8eadc22a129743b3f9328 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <cmake.h>
 #include <iostream>
+#include <vector>
+#include <string>
 #include <../Sarge/src/sarge.h>
 #include <stdlib.h>
 
 using namespace std;
 std::string promptCompose();
 
+static std::vector <std::string> contexts;
+std::string composeContexts (bool pretty = false);
+
+int promptClear ()
+{
+  contexts.clear ();
+  return 0;
+}
+
+int promptRemove ()
+{
+  if (contexts.size ())
+    contexts.pop_back ();
+
+  return 0;
+}
+
+int promptAdd (const std::string& context)
+{
+  contexts.push_back (context);
+  return 0;
+}
+
+std::string promptCompose ()
+{
+  return "% ";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
 const std::string getResponse(const std::string & prompt) {
   std::string response {
     ""
   };
 
-  // Display prompt, get input.
+  // Display prompt, get input
   #ifdef HAVE_READLINE
   char * line_read = readline(prompt.c_str());
   if (!line_read) {
     std::cout << "\n";
     response = "<EOF>";
   } else {
-    // Save history.
+    // Save history
     if ( * line_read)
       add_history(line_read);
 
@@ -99,15 +131,15 @@ int main(int argc, char** argv)
 
   // Main program
   while (true) {
-    // Compose the prompt.
+    // Compose the prompt
     auto prompt = promptCompose();
 
-    // Display prompt, get input.
+    // Display prompt, get input
     auto command = getResponse(prompt);
 
     if (command != "")
     {
-      // Dispatch command.
+      // Dispatch command
       if (command == "<EOF>")
       {
         return 0;