X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Console%2FExecutor.cc;h=fdbb85035e129e72f557e95bce62ec0e3ae31efd;hb=fa5eaa97c8593e3587c87f25adb14f7f91f31f37;hp=da8aa49e32370985836df31567f047a526cf9dd8;hpb=706fe01937df3649e40aed24b75c3d28fc4fa007;p=senf.git diff --git a/Console/Executor.cc b/Console/Executor.cc index da8aa49..fdbb850 100644 --- a/Console/Executor.cc +++ b/Console/Executor.cc @@ -60,8 +60,11 @@ prefix_ void senf::console::Executor::execute(std::ostream & output, GenericNode & node ( traverseCommand(command.commandPath()) ); DirectoryNode * dir ( dynamic_cast(&node) ); if ( dir ) { - oldCwd_ = cwd_; - cwd_ = dir->thisptr(); + if (autocd_ && command.tokens().empty()) { + oldCwd_ = cwd_; + cwd_ = dir->thisptr(); + } else + throw InvalidCommandException(); } else { dynamic_cast(node)(output, command); } @@ -80,14 +83,14 @@ prefix_ void senf::console::Executor::execute(std::ostream & output, } else { oldCwd_ = cwd_; - cwd_ = traverseDirectory(command.arguments().begin()[0]).thisptr(); + cwd_ = traverseDirectory(*command.arguments().begin()).thisptr(); } } break; case ParseCommandInfo::BuiltinLS : { DirectoryNode const & dir ( command.arguments() - ? traverseDirectory(command.arguments().begin()[0]) + ? traverseDirectory(*command.arguments().begin()) : cwd() ); for (DirectoryNode::child_iterator i (dir.children().begin()); i != dir.children().end(); ++i) { @@ -102,7 +105,7 @@ prefix_ void senf::console::Executor::execute(std::ostream & output, case ParseCommandInfo::BuiltinPUSHD : dirstack_.push_back(cwd_); if ( command.arguments() ) - cwd_ = traverseDirectory(command.arguments().begin()[0]).thisptr(); + cwd_ = traverseDirectory(*command.arguments().begin()).thisptr(); break; case ParseCommandInfo::BuiltinPOPD : @@ -117,7 +120,7 @@ prefix_ void senf::console::Executor::execute(std::ostream & output, case ParseCommandInfo::BuiltinHELP : GenericNode const & node (command.arguments() - ? traverseNode(command.arguments().begin()[0]) + ? traverseNode(*command.arguments().begin()) : cwd()); output << prettyName(typeid(node)) << " at " << node.path() << "\n\n"; node.help(output); @@ -138,13 +141,14 @@ prefix_ void senf::console::Executor::execute(std::ostream & output, } prefix_ senf::console::GenericNode & -senf::console::Executor::traverseNode(ParseCommandInfo::argument_value_type const & path) +senf::console::Executor::traverseNode(ParseCommandInfo::TokensRange const & path) { try { return cwd().traverse( boost::make_iterator_range( boost::make_transform_iterator(path.begin(), TraverseTokens()), - boost::make_transform_iterator(path.end(), TraverseTokens()))); + boost::make_transform_iterator(path.end(), TraverseTokens())), + autocomplete_); } catch (std::bad_cast &) { throw InvalidPathException(); @@ -158,7 +162,7 @@ prefix_ senf::console::GenericNode & senf::console::Executor::traverseCommand(ParseCommandInfo::CommandPathRange const & path) { try { - return cwd().traverse(path); + return cwd().traverse(path, autocomplete_); } catch (std::bad_cast &) { throw InvalidPathException(); @@ -169,7 +173,7 @@ senf::console::Executor::traverseCommand(ParseCommandInfo::CommandPathRange cons } prefix_ senf::console::DirectoryNode & -senf::console::Executor::traverseDirectory(ParseCommandInfo::argument_value_type const & path) +senf::console::Executor::traverseDirectory(ParseCommandInfo::TokensRange const & path) { try { return dynamic_cast( traverseNode(path) );