From 53609b283793e6e655a66fe274b0287842c2ce62 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 6 Sep 2009 16:27:28 -0400 Subject: [PATCH] Bug Fix - #288 - Fixed bug which failed to propagate rc overrides from the command line to the default command (thanks to Zach Frazier). --- AUTHORS | 2 +- ChangeLog | 4 +++- src/Context.cpp | 9 ++++++--- src/Context.h | 1 + src/tests/basic.t | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/AUTHORS b/AUTHORS index 64a7e5cb7..c764f5bd5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -38,4 +38,4 @@ Thanks to the following, who submitted detailed bug reports and excellent sugges Mike Adonay Thomas@BIC Ian Mortimer - + Zach Frazier diff --git a/ChangeLog b/ChangeLog index 6944da69e..537059544 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,7 +10,9 @@ + Fixed bug #289 which imported task from todo.sh without valid uuids (thanks to Ben Jackson). + Fixed bug #291 which generated a false warning about an unrecognized - variable when enabling default.projects in .taskrc (thanks to Thomas@BIC) + variable when enabling default.projects in .taskrc (thanks to Thomas@BIC). + + Fixed bug #288 which failed to propagate rc file overrides on the command + line to the default command (thanks to Zach Frazier). ------ old releases ------------------------------ diff --git a/src/Context.cpp b/src/Context.cpp index a3553db32..81ee76b8c 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -49,6 +49,7 @@ Context::Context () , tdb () , stringtable () , program ("") +, overrides ("") , cmd () , inShadow (false) { @@ -438,6 +439,7 @@ void Context::loadCorrectConfigFile () n.getUntilEOS (value)) { config.set (name, value); + overrides += " " + *arg; footnote (std::string ("Configuration override ") + // TODO i18n arg->substr (3, std::string::npos)); } @@ -654,12 +656,13 @@ void Context::parse ( // then invoke the default command. if (parseCmd.command == "" && parseArgs.size () == 0) { - std::string defaultCommand = config.get ("default.command"); + // Apply overrides, if any. + std::string defaultCommand = config.get ("default.command") + overrides; if (defaultCommand != "") { // Stuff the command line. - parseArgs.clear (); - split (parseArgs, defaultCommand, ' '); + args.clear (); + split (args, defaultCommand, ' '); header ("[task " + defaultCommand + "]"); // Reinitialize the context and recurse. diff --git a/src/Context.h b/src/Context.h index c49b6731c..e903bb8a7 100644 --- a/src/Context.h +++ b/src/Context.h @@ -83,6 +83,7 @@ public: StringTable stringtable; std::string program; std::vector args; + std::string overrides; Cmd cmd; std::map aliases; std::vector tagAdditions; diff --git a/src/tests/basic.t b/src/tests/basic.t index 25294b0ff..eb735cfb6 100755 --- a/src/tests/basic.t +++ b/src/tests/basic.t @@ -40,7 +40,7 @@ if (open my $fh, '>', 'basic.rc') # Test the usage command. my $output = qx{../task rc:basic.rc}; -like ($output, qr/You must specify a command, or a task ID to modify/, 'missing command and ID'); +like ($output, qr/You must specify a command, or a task ID to modify/m, 'missing command and ID'); # Test the version command. $output = qx{../task rc:basic.rc version};