mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-30 02:17:21 +02:00
CLI
- Override detection and extraction.
This commit is contained in:
parent
c73e864cdd
commit
226c143922
2 changed files with 34 additions and 3 deletions
32
src/CLI.cpp
32
src/CLI.cpp
|
@ -54,13 +54,41 @@ void CLI::entity (const std::string& name, const std::string& value)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Capture the original, intact command line arguments. These will not be
|
// Capture the original, intact command line arguments.
|
||||||
// modified.
|
|
||||||
void CLI::initialize (int argc, const char** argv)
|
void CLI::initialize (int argc, const char** argv)
|
||||||
{
|
{
|
||||||
_program = argv[0];
|
_program = argv[0];
|
||||||
for (int i = 1; i < argc; ++i)
|
for (int i = 1; i < argc; ++i)
|
||||||
_args.push_back (argv[i]);
|
_args.push_back (argv[i]);
|
||||||
|
|
||||||
|
extractOverrides ();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CLI::extractOverrides ()
|
||||||
|
{
|
||||||
|
std::vector <std::string> reconstructed;
|
||||||
|
|
||||||
|
std::vector <std::string>::iterator i;
|
||||||
|
for (i = _args.begin (); i != _args.end (); ++i)
|
||||||
|
{
|
||||||
|
if (i->find ("rc:") == 0)
|
||||||
|
{
|
||||||
|
_rc = i->substr (3);
|
||||||
|
}
|
||||||
|
else if (i->find ("rc.") == 0)
|
||||||
|
{
|
||||||
|
std::string::size_type sep = arg.find ('=', 3);
|
||||||
|
if (sep == std::string::npos)
|
||||||
|
sep = arg.find (':', 3);
|
||||||
|
if (sep != std::string::npos)
|
||||||
|
_overrides[i->substr (3, sep - 3)] = i->substr (sep + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
reconstructed.push_back (*i);
|
||||||
|
}
|
||||||
|
|
||||||
|
_args = reconstructed;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -40,12 +40,15 @@ public:
|
||||||
void initialize (int, const char**);
|
void initialize (int, const char**);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void extractOverrides ();
|
||||||
|
|
||||||
private:
|
public:
|
||||||
std::multimap <std::string, std::string> _entities;
|
std::multimap <std::string, std::string> _entities;
|
||||||
std::map <std::string, std::string> _aliases;
|
std::map <std::string, std::string> _aliases;
|
||||||
std::string _program;
|
std::string _program;
|
||||||
std::vector <std::string> _args;
|
std::vector <std::string> _args;
|
||||||
|
std::string _rc;
|
||||||
|
std::map <std::string, std::string> _overrides;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue