mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
CLI
- Updated ::getOverride to scan all args, display the debug feedback, and derive the home dir. - Removed Parser::getOverrides calls from Context. - Cleaned up dead code in Context::initialize.
This commit is contained in:
parent
d49222e8c7
commit
9799fcefed
3 changed files with 20 additions and 22 deletions
20
src/CLI.cpp
20
src/CLI.cpp
|
@ -355,14 +355,28 @@ void CLI::analyze (bool parse /* = true */)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string CLI::getOverride ()
|
||||
void CLI::getOverride (std::string& home, File& rc)
|
||||
{
|
||||
std::vector <A>::const_iterator a;
|
||||
for (a = _args.begin (); a != _args.end (); ++a)
|
||||
{
|
||||
if (a->hasTag ("RC"))
|
||||
return a->attribute ("file");
|
||||
{
|
||||
rc = File (a->attribute ("file"));
|
||||
home = rc;
|
||||
|
||||
return "";
|
||||
std::string::size_type last_slash = rc._data.rfind ("/");
|
||||
if (last_slash != std::string::npos)
|
||||
home = rc._data.substr (0, last_slash);
|
||||
else
|
||||
home = ".";
|
||||
|
||||
context.header (format (STRING_PARSER_ALTERNATE_RC, rc._data));
|
||||
|
||||
// Keep looping, because if there are multiple rc:file arguments, the last
|
||||
// one should dominate.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <File.h>
|
||||
|
||||
// Represents a single argument.
|
||||
class A
|
||||
|
@ -69,7 +70,7 @@ public:
|
|||
void initialize (int, const char**);
|
||||
void add (const std::string&);
|
||||
void analyze (bool parse = true);
|
||||
const std::string getOverride ();
|
||||
void getOverride (std::string&, File&);
|
||||
const std::string getFilter ();
|
||||
const std::vector <std::string> getWords ();
|
||||
const std::vector <std::string> getModifications ();
|
||||
|
|
|
@ -139,7 +139,7 @@ int Context::initialize (int argc, const char** argv)
|
|||
|
||||
// Scan command line for 'rc:<file>' only.
|
||||
cli.initialize (argc, argv); // task arg0 arg1 ...
|
||||
rc_file._data = cli.getOverride ();
|
||||
cli.getOverride (home_dir, rc_file); // <-- <file>
|
||||
|
||||
// TASKRC environment variable overrides the command line.
|
||||
char* override = getenv ("TASKRC");
|
||||
|
@ -165,28 +165,11 @@ int Context::initialize (int argc, const char** argv)
|
|||
|
||||
// Process 'rc:<file>' command line override.
|
||||
parser.findOverrides (); // rc:<file> rc.<name>:<value>
|
||||
parser.getOverrides (home_dir, rc_file); // <-- <file>
|
||||
/*
|
||||
home_dir = rc_file;
|
||||
std::string::size_type last_slash = rc._data.rfind ("/");
|
||||
if (last_slash != std::string::npos)
|
||||
home_dir = rc_file.parent ();
|
||||
else
|
||||
home_dir = ".";
|
||||
std::cout << "# home_dir=" << home_dir << "\n";
|
||||
*/
|
||||
|
||||
// The data location, Context::data_dir, is determined from the assumed
|
||||
// location (~/.task), or set by data.location in the config file, or
|
||||
// overridden by rc.data.location on the command line.
|
||||
parser.getDataLocation (data_dir); // <-- rc.data.location=<location>
|
||||
/*
|
||||
if (cli._overrides.find ("data.location") != cli._overrides.end ())
|
||||
data_dir = cli._overrides["data.location"];
|
||||
else
|
||||
data_dir = config.get ("data.location");
|
||||
std::cout << "# data_dir=" << data_dir << "\n";
|
||||
*/
|
||||
|
||||
override = getenv ("TASKDATA");
|
||||
if (override)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue