Commit missing files
[senf.git] / Scheduler / Console / Executor.cc
index 80d632f..d6218d8 100644 (file)
@@ -33,6 +33,7 @@
 #include "../../Utils/senfassert.hh"
 #include "../../Utils/Range.hh"
 #include "../../Utils/String.hh"
+#include "../../Utils/range.hh"
 
 //#include "Executor.mpp"
 #define prefix_
@@ -232,7 +233,7 @@ prefix_ void senf::console::Executor::help(std::ostream & output,
                                            ParseCommandInfo::TokensRange path)
 {
     GenericNode const & node (traverseNode(path));
-    output << prettyName(typeid(node)) << " at " << node.path() << "\n\n";
+    // output << prettyName(typeid(node)) << " at " << node.path() << "\n\n";
     node.help(output);
     output << std::flush;
 }
@@ -248,8 +249,17 @@ senf::console::Executor::traverseNode(ParseCommandInfo::TokensRange const & path
                               path.begin(),
                               boost::prior(path.end())),
                           dir);
+        // For auto-cd support we need to check against '.' and '..' here too
+        Token const & tok (*boost::prior(path.end()));
+        if (tok == WordToken("..")) {
+            if (dir.size() > 1)
+                dir.pop_back();
+            return *dir.back().lock();
+        }
         DirectoryNode & base (*dir.back().lock());
-        std::string const & name (complete(base, boost::prior(path.end())->value()));
+        if (tok == WordToken("."))
+            return base;
+        std::string const & name (complete(base, tok.value()));
         if (policy_)
             policy_( base, name );
         return dir.back().lock()->get(name);
@@ -301,7 +311,7 @@ prefix_ std::string senf::console::Executor::complete(DirectoryNode & dir,
 {
     if (! dir.hasChild(name)) {
         DirectoryNode::ChildrenRange completions (dir.completions(name));
-        if (completions.size() == 1)
+        if (has_one_elt(completions))
             return completions.begin()->first;
     }
     return name;