Utils/Console: Repeat repeated command on console
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1224
270642c3-0616-0410-b53a-bc976706d245
return *rootNode;
}
+namespace {
+ void dodump(std::ostream & output, unsigned level, senf::console::DirectoryNode & node)
+ {
+ std::string pad (2*level, ' ');
+ senf::console::DirectoryNode::child_iterator i (node.children().begin());
+ senf::console::DirectoryNode::child_iterator const i_end (node.children().end());
+ for (; i != i_end; ++i) {
+ output << pad << i->first;
+ if (i->second->isDirectory()) {
+ output << "/\n";
+ dodump(output, level+1,static_cast<senf::console::DirectoryNode&>(*i->second));
+ }
+ else if (i->second->isLink())
+ output << "@ -> " << i->second->followLink().path() << '\n';
+ else
+ output << '\n';
+ }
+ }
+}
+
+prefix_ void senf::console::dump(std::ostream & os, DirectoryNode & dir)
+{
+ dodump(os,0,dir);
+}
+
///////////////////////////////////////////////////////////////////////////
// senf::console::GenericNode
class CommandNode;
DirectoryNode & root();
+ void dump(std::ostream & os, DirectoryNode & dir=root());
/** \brief Config/console node tree base-class
p->shortdoc("short doc");
BOOST_CHECK_EQUAL( p->shorthelp(), "short doc" );
+ ss.str("");
+ senf::console::root()["dir2"].mkdir("dir4");
+ senf::console::root()["dir2"].link("link", *p);
+ senf::console::root()["dir2"]["dir4"].link("link", senf::console::root());
+ senf::console::dump(ss, senf::console::root()["dir2"]);
+ BOOST_CHECK_EQUAL( ss.str(),
+ "dir3/\n"
+ "dir4/\n"
+ " link@ -> /\n"
+ "link@ -> /dir1\n" );
+
BOOST_CHECK( senf::console::root().remove("dir1") == p );
senf::console::root().remove("dir2");
senf::console::root().remove("fn");
prefix_ std::string::size_type senf::console::Client::handleInput(std::string data,
bool incremental)
{
- if (data.empty() && ! incremental)
+ if (data.empty() && ! incremental) {
data = lastCommand_;
- else
+ stream() << "repeat: " << data << std::endl;
+ } else
lastCommand_ = data;
std::string::size_type n (data.size());