From 8731bf9ac62d640be08c4606989d5bdc9ca20d1b Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 8 Jul 2011 01:16:05 -0400 Subject: [PATCH] Calendar - If the program is renamed 'cal' or 'calendar', or symlinked to either 'cal' or 'calendar', then the calendar report is run. --- src/Arguments.cpp | 15 +++++++++++++-- src/Context.cpp | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Arguments.cpp b/src/Arguments.cpp index aa020cc33..1736df909 100644 --- a/src/Arguments.cpp +++ b/src/Arguments.cpp @@ -168,7 +168,7 @@ void Arguments::capture (int argc, const char** argv) } //////////////////////////////////////////////////////////////////////////////// -// Append a pair with a category of "". +// Append a Triple with a blank category. void Arguments::capture (const std::string& arg) { std::vector parts; @@ -185,7 +185,7 @@ void Arguments::capture (const std::string& arg) } //////////////////////////////////////////////////////////////////////////////// -// Prepend a pair with a category of "". +// Prepend a Triple with a blank category. void Arguments::capture_first (const std::string& arg) { // Break the new argument into parts that comprise a series. @@ -289,6 +289,17 @@ void Arguments::categorize () else if (arg == this->begin ()) { arg->_third = "program"; // TODO Is this a problem for expressions that do not contain a program name? + + if (arg->_first == "cal" || + arg->_first == "calendar" || + arg->_first.find ("/calendar") == arg->_first.length () - 9 || + arg->_first.find ("/cal") == arg->_first.length () - 4) + { + arg->_first = "calendar"; + arg->_third = "command"; + found_command = true; + found_non_sequence = true; + } } // command diff --git a/src/Context.cpp b/src/Context.cpp index 2fa4bc3cd..a1dba2cc8 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -120,6 +120,7 @@ int Context::initialize (int argc, const char** argv) Column::factory (columns); // Categorize all arguments one more time. + // TODO This may not be necessary. args.categorize (); // Handle default command and assumed 'info' command.