mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Commands - burndown.monthly, burndown.weekly, burndown.daily
- Migrated burndown charts to CmdBurndown.
This commit is contained in:
parent
398380d390
commit
b0cbc7f757
8 changed files with 176 additions and 111 deletions
|
@ -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
|
||||
|
|
|
@ -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" ||
|
||||
|
|
|
@ -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); }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -26,16 +26,12 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <Context.h>
|
||||
#include <Date.h>
|
||||
#include <Duration.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <main.h>
|
||||
#include <CmdBurndown.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
|
@ -970,93 +966,17 @@ void Chart::calculateRates (std::vector <time_t>& sequence)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int handleReportBurndownDaily (std::string& outs)
|
||||
CmdBurndownMonthly::CmdBurndownMonthly ()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
// Scan the pending tasks, applying any filter.
|
||||
std::vector <Task> 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 [<filter>]";
|
||||
_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 <Task> 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 [<filter>]";
|
||||
_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 <Task> 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 [<filter>]";
|
||||
_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 <Task> 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;
|
||||
}
|
||||
|
56
src/commands/CmdBurndown.h
Normal file
56
src/commands/CmdBurndown.h
Normal file
|
@ -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 <string>
|
||||
#include <Command.h>
|
||||
|
||||
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
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -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.");
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <vector>
|
||||
#include <Command.h>
|
||||
#include <CmdAppend.h>
|
||||
#include <CmdBurndown.h>
|
||||
#include <CmdCommands.h>
|
||||
#include <CmdCount.h>
|
||||
#include <CmdCustom.h>
|
||||
|
@ -60,6 +61,9 @@ void Command::factory (std::map <std::string, Command*>& 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue