Utils: Document new utilities
[senf.git] / Console / Executor.hh
index 5cdd1f7..882792a 100644 (file)
@@ -91,6 +91,8 @@ namespace console {
                                         /**< Output will be written to \a output. 
                                              Same as execute(). */
         DirectoryNode & cwd() const;    ///< Current working directory
+        std::string cwdPath() const;    ///< Return pathname of current directory
+        bool skipping() const;          ///< \c true, if currently skipping a directory group
 
         bool autocd() const;            ///< Get current autocd status
                                         /**< if autocd is enabled, specifying a directory name as
@@ -120,19 +122,27 @@ namespace console {
                                              are accessible via the executor. This value defaults to
                                              senf::console::root(). */
 
-        Executor & policy(SecurityPolicy policy); ///< Set security policy
+        Executor & policy(SecurityPolicy policy = SecurityPolicy()); ///< Set security policy
                                         /**< The security policy is called before traversing a node
                                              to validate that access. */
 
     protected:
 
     private:
-        GenericNode & traverseNode(ParseCommandInfo::TokensRange const & path);
-        GenericNode & traverseCommand(ParseCommandInfo::CommandPathRange const & path); 
-        DirectoryNode & traverseDirectory(ParseCommandInfo::TokensRange const & path);
+        typedef std::vector<DirectoryNode::weak_ptr> Path;
+
+        void exec(std::ostream & output, ParseCommandInfo const & command);
 
-        template <class ForwardRange>
-        GenericNode & traverse(DirectoryNode & dir, ForwardRange const & range);
+        void cd(ParseCommandInfo::TokensRange dir);
+        void ls(std::ostream & output, ParseCommandInfo::TokensRange dir);
+        void pushd(ParseCommandInfo::TokensRange dir);
+        void popd();
+        void exit();
+        void help(std::ostream & output, ParseCommandInfo::TokensRange path);
+
+        GenericNode & traverseNode(ParseCommandInfo::TokensRange const & path);
+        void traverseDirectory(ParseCommandInfo::TokensRange const & path,
+                               Path & dir);
 
         struct InvalidPathException {};
         struct InvalidDirectoryException {};
@@ -140,28 +150,21 @@ namespace console {
         
         DirectoryNode::ptr root_;
         SecurityPolicy policy_;
-        DirectoryNode::weak_ptr cwd_;
-        DirectoryNode::weak_ptr oldCwd_;
-        struct DirEntry {
-            DirEntry(DirectoryNode::weak_ptr dir_, bool skip_) : dir(dir_), skip(skip_) {}
-            DirectoryNode::weak_ptr dir;
-            bool skip;
-        };
-        typedef std::vector<DirEntry> DirStack;
+        mutable Path cwd_;
+        Path oldCwd_;
+
+        typedef std::vector<Path> DirStack;
         DirStack dirstack_;
 
         bool autocd_;
         bool autocomplete_;
-        
-        bool skipping_;
     };
 
-
 }}
 
 ///////////////////////////////hh.e////////////////////////////////////////
 #include "Executor.cci"
-#include "Executor.ct"
+//#include "Executor.ct"
 //#include "Executor.cti"
 #endif