diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 468ede195..997174924 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -40,7 +40,6 @@ set (task_SRCS API.cpp API.h Variant.cpp Variant.h ViewTask.cpp ViewTask.h ViewText.cpp ViewText.h - burndown.cpp command.cpp dependency.cpp export.cpp diff --git a/src/Cmd.cpp b/src/Cmd.cpp index 720f7a9c2..d38b09730 100644 --- a/src/Cmd.cpp +++ b/src/Cmd.cpp @@ -134,9 +134,6 @@ void Cmd::load () commands.push_back ("export.csv"); commands.push_back ("export.ical"); commands.push_back ("export.yaml"); - commands.push_back ("burndown.daily"); - commands.push_back ("burndown.weekly"); - commands.push_back ("burndown.monthly"); commands.push_back ("add"); commands.push_back ("annotate"); commands.push_back ("denotate"); @@ -217,9 +214,6 @@ bool Cmd::isReadOnlyCommand () command == "export.csv" || command == "export.ical" || command == "export.yaml" || - command == "burndown.daily" || - command == "burndown.weekly" || - command == "burndown.monthly" || command == "calendar" || command == "colors" || command == "config" || diff --git a/src/Context.cpp b/src/Context.cpp index 3a7092035..f74705dce 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -249,9 +249,6 @@ int Context::dispatch (std::string &out) // TODO Chain-of-command pattern dispatch. if (cmd.command == "colors") { rc = handleColor (out); } else if (cmd.command == "config") { rc = handleConfig (out); } - else if (cmd.command == "burndown.daily") { rc = handleReportBurndownDaily (out); } - else if (cmd.command == "burndown.weekly") { rc = handleReportBurndownWeekly (out); } - else if (cmd.command == "burndown.monthly") { rc = handleReportBurndownMonthly (out); } else if (cmd.command == "summary") { rc = handleReportSummary (out); } else if (cmd.command == "calendar") { rc = handleReportCalendar (out); } else if (cmd.command == "timesheet") { rc = handleReportTimesheet (out); } diff --git a/src/commands/CMakeLists.txt b/src/commands/CMakeLists.txt index 0bd97ef35..872362656 100644 --- a/src/commands/CMakeLists.txt +++ b/src/commands/CMakeLists.txt @@ -7,6 +7,7 @@ include_directories (${CMAKE_SOURCE_DIR} set (commands_SRCS Command.cpp Command.h CmdAppend.cpp CmdAppend.h + CmdBurndown.cpp CmdBurndown.h CmdCommands.cpp CmdCommands.h CmdCount.cpp CmdCount.h CmdCustom.cpp CmdCustom.h diff --git a/src/burndown.cpp b/src/commands/CmdBurndown.cpp similarity index 95% rename from src/burndown.cpp rename to src/commands/CmdBurndown.cpp index 7670848fb..585edcf37 100644 --- a/src/burndown.cpp +++ b/src/commands/CmdBurndown.cpp @@ -26,16 +26,12 @@ //////////////////////////////////////////////////////////////////////////////// #include -#include #include -#include - #include #include #include -#include -#include #include +#include extern Context context; @@ -970,93 +966,17 @@ void Chart::calculateRates (std::vector & sequence) } //////////////////////////////////////////////////////////////////////////////// -int handleReportBurndownDaily (std::string& outs) +CmdBurndownMonthly::CmdBurndownMonthly () { - int rc = 0; - - // Scan the pending tasks, applying any filter. - std::vector tasks; - context.tdb.lock (context.config.getBoolean ("locking")); - handleRecurrence (); - context.tdb.load (tasks, context.filter); - context.tdb.commit (); - context.tdb.unlock (); - - // Create a chart, scan the tasks, then render. - Chart chart ('D'); - - // Use any filter as a title. - if (context.filter.size ()) - { - std::string combined = "("; - - for (unsigned int i = 0; i < context.filter.size (); ++i) - { - if (i) - combined += " "; - - combined += context.filter[i].name (); - - if (context.filter[i].mod ().length ()) - combined += "." + context.filter[i].mod (); - - combined += ":" + context.filter[i].value (); - } - - combined += ")"; - chart.description (combined); - } - - chart.scan (tasks); - outs = chart.render (); - return rc; + _keyword = "burndown.monthly"; + _usage = "task burndown.monthly []"; + _description = "Shows a graphical burndown chart, by month."; + _read_only = true; + _displays_id = false; } //////////////////////////////////////////////////////////////////////////////// -int handleReportBurndownWeekly (std::string& outs) -{ - int rc = 0; - - // Scan the pending tasks, applying any filter. - std::vector tasks; - context.tdb.lock (context.config.getBoolean ("locking")); - handleRecurrence (); - context.tdb.load (tasks, context.filter); - context.tdb.commit (); - context.tdb.unlock (); - - // Create a chart, scan the tasks, then render. - Chart chart ('W'); - - // Use any filter as a title. - if (context.filter.size ()) - { - std::string combined = "("; - - for (unsigned int i = 0; i < context.filter.size (); ++i) - { - if (i) - combined += " "; - - combined += context.filter[i].name (); - - if (context.filter[i].mod ().length ()) - combined += "." + context.filter[i].mod (); - - combined += ":" + context.filter[i].value (); - } - - combined += ")"; - chart.description (combined); - } - - chart.scan (tasks); - outs = chart.render (); - return rc; -} - -//////////////////////////////////////////////////////////////////////////////// -int handleReportBurndownMonthly (std::string& outs) +int CmdBurndownMonthly::execute (const std::string&, std::string& output) { int rc = 0; @@ -1094,7 +1014,113 @@ int handleReportBurndownMonthly (std::string& outs) } chart.scan (tasks); - outs = chart.render (); + output = chart.render (); + return rc; +} + +//////////////////////////////////////////////////////////////////////////////// +CmdBurndownWeekly::CmdBurndownWeekly () +{ + _keyword = "burndown.weekly"; + _usage = "task burndown.weekly []"; + _description = "Shows a graphical burndown chart, by week."; + _read_only = true; + _displays_id = false; +} + +//////////////////////////////////////////////////////////////////////////////// +int CmdBurndownWeekly::execute (const std::string&, std::string& output) +{ + int rc = 0; + + // Scan the pending tasks, applying any filter. + std::vector tasks; + context.tdb.lock (context.config.getBoolean ("locking")); + handleRecurrence (); + context.tdb.load (tasks, context.filter); + context.tdb.commit (); + context.tdb.unlock (); + + // Create a chart, scan the tasks, then render. + Chart chart ('W'); + + // Use any filter as a title. + if (context.filter.size ()) + { + std::string combined = "("; + + for (unsigned int i = 0; i < context.filter.size (); ++i) + { + if (i) + combined += " "; + + combined += context.filter[i].name (); + + if (context.filter[i].mod ().length ()) + combined += "." + context.filter[i].mod (); + + combined += ":" + context.filter[i].value (); + } + + combined += ")"; + chart.description (combined); + } + + chart.scan (tasks); + output = chart.render (); + return rc; +} + +//////////////////////////////////////////////////////////////////////////////// +CmdBurndownDaily::CmdBurndownDaily () +{ + _keyword = "burndown.daily"; + _usage = "task burndown.daily []"; + _description = "Shows a graphical burndown chart, by day."; + _read_only = true; + _displays_id = false; +} + +//////////////////////////////////////////////////////////////////////////////// +int CmdBurndownDaily::execute (const std::string&, std::string& output) +{ + int rc = 0; + + // Scan the pending tasks, applying any filter. + std::vector tasks; + context.tdb.lock (context.config.getBoolean ("locking")); + handleRecurrence (); + context.tdb.load (tasks, context.filter); + context.tdb.commit (); + context.tdb.unlock (); + + // Create a chart, scan the tasks, then render. + Chart chart ('D'); + + // Use any filter as a title. + if (context.filter.size ()) + { + std::string combined = "("; + + for (unsigned int i = 0; i < context.filter.size (); ++i) + { + if (i) + combined += " "; + + combined += context.filter[i].name (); + + if (context.filter[i].mod ().length ()) + combined += "." + context.filter[i].mod (); + + combined += ":" + context.filter[i].value (); + } + + combined += ")"; + chart.description (combined); + } + + chart.scan (tasks); + output = chart.render (); return rc; } diff --git a/src/commands/CmdBurndown.h b/src/commands/CmdBurndown.h new file mode 100644 index 000000000..f4eb56c70 --- /dev/null +++ b/src/commands/CmdBurndown.h @@ -0,0 +1,56 @@ +//////////////////////////////////////////////////////////////////////////////// +// taskwarrior - a command line task list manager. +// +// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_CMDBURNDOWN +#define INCLUDED_CMDBURNDOWN +#define L10N // Localization complete. + +#include +#include + +class CmdBurndownMonthly : public Command +{ +public: + CmdBurndownMonthly (); + int execute (const std::string&, std::string&); +}; + +class CmdBurndownWeekly : public Command +{ +public: + CmdBurndownWeekly (); + int execute (const std::string&, std::string&); +}; + +class CmdBurndownDaily : public Command +{ +public: + CmdBurndownDaily (); + int execute (const std::string&, std::string&); +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/CmdHelp.cpp b/src/commands/CmdHelp.cpp index 820c947e7..44a5f2e7b 100644 --- a/src/commands/CmdHelp.cpp +++ b/src/commands/CmdHelp.cpp @@ -151,18 +151,6 @@ int CmdHelp::execute (const std::string&, std::string& output) view.set (row, 1, "task timesheet [weeks]"); view.set (row, 2, "Shows a weekly report of tasks completed and started."); - row = view.addRow (); - view.set (row, 1, "task burndown.daily"); - view.set (row, 2, "Shows a graphical burndown chart, by day."); - - row = view.addRow (); - view.set (row, 1, "task burndown.weekly"); - view.set (row, 2, "Shows a graphical burndown chart, by week."); - - row = view.addRow (); - view.set (row, 1, "task burndown.monthly"); - view.set (row, 2, "Shows a graphical burndown chart, by month."); - row = view.addRow (); view.set (row, 1, "task calendar [due|month year|year]"); view.set (row, 2, "Shows a calendar, with due tasks marked."); diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index dc81659f3..171ddc055 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +61,9 @@ void Command::factory (std::map & all) Command* c; c = new CmdAppend (); all[c->keyword ()] = c; + c = new CmdBurndownDaily (); all[c->keyword ()] = c; + c = new CmdBurndownMonthly (); all[c->keyword ()] = c; + c = new CmdBurndownWeekly (); all[c->keyword ()] = c; c = new CmdCompletionCommands (); all[c->keyword ()] = c; c = new CmdCompletionIds (); all[c->keyword ()] = c; c = new CmdCompletionProjects (); all[c->keyword ()] = c;