- Now allows abbreviations of aliases.
- No longer truncates commands after --.
This commit is contained in:
Paul Beckingham 2009-07-05 13:26:53 -04:00
parent f2af6cc2dd
commit e20e05ab54

View file

@ -280,16 +280,28 @@ std::string Context::canonicalize (const std::string& input) const
{ {
std::string canonical = input; std::string canonical = input;
// Follow the chain. // First try to autocomplete the alias.
int i = 10; // Safety valve. std::vector <std::string> options;
std::map <std::string, std::string>::const_iterator found; std::vector <std::string> matches;
while ((found = aliases.find (canonical)) != aliases.end () && i-- > 0) foreach (name, aliases)
canonical = found->second; options.push_back (name->first);
if (i < 1) autoComplete (input, options, matches);
return input; if (matches.size () == 1)
{
canonical = matches[0];
return canonical; // Follow the chain.
int i = 10; // Safety valve.
std::map <std::string, std::string>::const_iterator found;
while ((found = aliases.find (canonical)) != aliases.end () && i-- > 0)
canonical = found->second;
if (i < 1)
return input;
}
return canonical;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -362,11 +374,13 @@ void Context::loadCorrectConfigFile ()
// Apply overrides of type: "rc.name:value" // Apply overrides of type: "rc.name:value"
std::vector <std::string> filtered; std::vector <std::string> filtered;
bool foundTerminator = false;
foreach (arg, args) foreach (arg, args)
{ {
if (*arg == "--") if (*arg == "--")
break; foundTerminator = true;
else if (arg->substr (0, 3) == "rc.") else if (!foundTerminator &&
arg->substr (0, 3) == "rc.")
{ {
std::string name; std::string name;
std::string value; std::string value;