40 size_t comment = c.find_first_of(
'#');
41 if (comment != std::string::npos)
48 command >> std::boolalpha >> std::ws;
50 if (cmd.length() == 0)
57 if (arg.length() == 0) {
75 if (x->name() == arg) {
89 if (x->name() == cmd) {
90 return x->execute(command);
103 std::ifstream f(configFile);
109 for (std::string line; std::getline(f, line);) {
110 if (line.length() == 0)
123 std::vector<std::string> candidates;
125 std::string help(
"help");
126 if (begin.size() <= help.size()) {
127 if (begin.compare(0, begin.size(), help, 0, begin.size()) == 0) {
128 candidates.push_back(help);
134 std::string
name = x->name();
135 if (begin.size() <= name.size()) {
136 if (begin.compare(0, begin.size(),
name, 0, begin.size()) == 0) {
137 candidates.push_back(name);
143 if (candidates.size() == 0) {
145 }
else if (candidates.size() == 1) {
146 return candidates.at(0);
148 std::string common = candidates.at(0);
149 for (
int i = 0; i < candidates.size(); i++) {
151 if (i < (candidates.size() - 1))
154 for (
int c = 0; (c < common.size()) && (c < candidates.at(i).size()); c++) {
155 if (common.at(c) != candidates.at(i).at(c)) {
String handling utilities.
static std::string autoComplete(std::string begin)
static std::vector< std::shared_ptr< Command > > commands
static int command(std::string c)
static LogLevel & get(int level)
static void fillCommandList()
static void error(char *msg)
virtual std::string name()=0
std::string expandHomeDirectory(std::string s)
static int executeFile(std::string file)