#include <boost/utility.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/bind.hpp>
+#include <boost/format.hpp>
#include "../../Utils/senfassert.hh"
#include "../../Utils/Range.hh"
#include "../../Utils/String.hh"
DirectoryNode & node (*dir.back().lock());
DirectoryNode::child_iterator i (node.children().begin());
DirectoryNode::child_iterator const i_end (node.children().end());
- for (; i != i_end; ++i) {
- output << i->first;
- if (i->second->isDirectory())
- output << "/";
- else if (i->second->isLink())
- output << "@";
- output << "\n";
- }
+ boost::format fmt ("%s%s %|20t|%.59s\n");
+ for (; i != i_end; ++i)
+ output << fmt
+ % i->first
+ % ( i->second->isDirectory()
+ ? "/"
+ : i->second->isLink()
+ ? "@"
+ : "" )
+ % i->second->shorthelp();
}
prefix_ void senf::console::Executor::pushd(ParseCommandInfo::TokensRange dir)
parser.parse("ls", &setCommand);
executor(os, commands.back());
BOOST_CHECK_EQUAL( commands.back().builtin(), senf::console::ParseCommandInfo::BuiltinLS );
- BOOST_CHECK_EQUAL( os.str(), "dir1/\ndir2/\nsys/\n" );
+ BOOST_CHECK_EQUAL( os.str(),
+ "dir1/ \n"
+ "dir2/ Helptext\n"
+ "sys/ \n" );
}
{
parser.parse("ls dir1", &setCommand);
executor(os, commands.back());
BOOST_CHECK_EQUAL( commands.back().builtin(), senf::console::ParseCommandInfo::BuiltinLS );
- BOOST_CHECK_EQUAL( os.str(), "dir3/\n" );
+ BOOST_CHECK_EQUAL( os.str(), "dir3/ \n" );
}
{
parser.parse("ls dir1", &setCommand);
executor(os, commands.back());
BOOST_CHECK_EQUAL( commands.back().builtin(), senf::console::ParseCommandInfo::BuiltinLS );
- BOOST_CHECK_EQUAL( os.str(), "dir3/\n" );
+ BOOST_CHECK_EQUAL( os.str(), "dir3/ \n" );
}
{
{
if (!shortdoc_.empty())
return shortdoc_;
- return doc_.substr(0,doc_.find('\n'));
+ if (!doc_.empty())
+ return doc_.substr(0,doc_.find('\n'));
+ Overloads::const_iterator i (overloads_.begin());
+ Overloads::const_iterator const i_end (overloads_.end());
+ for (; i != i_end; ++i) {
+ std::string overloadDoc ((*i)->doc());
+ if (! overloadDoc.empty())
+ return overloadDoc.substr(0,doc_.find('\n'));
+ }
+ return "";
}
prefix_ void senf::console::OverloadedCommandNode::v_execute(boost::any & rv,
SENF_CHECK_NO_THROW(
parser.parse("test/test { ls; }",
boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
- BOOST_CHECK_EQUAL( ss.str(), "<Directory at '/test/dircb'>\ncb1\n" );
+ BOOST_CHECK_EQUAL( ss.str(), "<Directory at '/test/dircb'>\ncb1 \n" );
}
}