mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 07:57:20 +02:00
Code Cleanup
- Eliminated valid.cpp by relocating functions to more sensible locations.
This commit is contained in:
parent
52052f91f9
commit
1f3092469e
6 changed files with 75 additions and 134 deletions
|
@ -437,7 +437,7 @@ void Context::parse (
|
||||||
// Tags to include begin with '+'.
|
// Tags to include begin with '+'.
|
||||||
else if (arg->length () > 1 &&
|
else if (arg->length () > 1 &&
|
||||||
(*arg)[0] == '+' &&
|
(*arg)[0] == '+' &&
|
||||||
validTag (*arg))
|
noSpaces (*arg))
|
||||||
{
|
{
|
||||||
debug ("parse tag addition '" + *arg + "'");
|
debug ("parse tag addition '" + *arg + "'");
|
||||||
if (foundSequence)
|
if (foundSequence)
|
||||||
|
@ -454,7 +454,7 @@ void Context::parse (
|
||||||
// Tags to remove begin with '-'.
|
// Tags to remove begin with '-'.
|
||||||
else if (arg->length () > 1 &&
|
else if (arg->length () > 1 &&
|
||||||
(*arg)[0] == '-' &&
|
(*arg)[0] == '-' &&
|
||||||
validTag (*arg))
|
noSpaces (*arg))
|
||||||
{
|
{
|
||||||
debug ("parse tag removal '" + *arg + "'");
|
debug ("parse tag removal '" + *arg + "'");
|
||||||
if (foundSequence)
|
if (foundSequence)
|
||||||
|
|
|
@ -3,8 +3,8 @@ task_SOURCES = Att.cpp Cmd.cpp Config.cpp Context.cpp Date.cpp Duration.cpp \
|
||||||
Filter.cpp Grid.cpp Keymap.cpp Location.cpp Nibbler.cpp \
|
Filter.cpp Grid.cpp Keymap.cpp Location.cpp Nibbler.cpp \
|
||||||
Record.cpp Sequence.cpp StringTable.cpp Subst.cpp Task.cpp \
|
Record.cpp Sequence.cpp StringTable.cpp Subst.cpp Task.cpp \
|
||||||
TDB.cpp Table.cpp Timer.cpp Permission.cpp color.cpp edit.cpp \
|
TDB.cpp Table.cpp Timer.cpp Permission.cpp color.cpp edit.cpp \
|
||||||
command.cpp import.cpp interactive.cpp valid.cpp recur.cpp \
|
command.cpp import.cpp interactive.cpp recur.cpp report.cpp \
|
||||||
report.cpp custom.cpp rules.cpp main.cpp text.cpp util.cpp \
|
custom.cpp rules.cpp main.cpp text.cpp util.cpp \
|
||||||
Att.h Cmd.h Config.h Context.h Date.h Duration.h Filter.h \
|
Att.h Cmd.h Config.h Context.h Date.h Duration.h Filter.h \
|
||||||
Grid.h Keymap.h Location.h Nibbler.h Record.h Sequence.h \
|
Grid.h Keymap.h Location.h Nibbler.h Record.h Sequence.h \
|
||||||
StringTable.h Subst.h Task.h TDB.h Table.h Timer.h \
|
StringTable.h Subst.h Task.h TDB.h Table.h Timer.h \
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
static std::vector <std::string> customReports;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// This report will eventually become the one report that many others morph into
|
// This report will eventually become the one report that many others morph into
|
||||||
|
@ -550,4 +551,65 @@ std::string runCustomReport (
|
||||||
return out.str ();
|
return out.str ();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void validReportColumns (const std::vector <std::string>& columns)
|
||||||
|
{
|
||||||
|
std::vector <std::string> bad;
|
||||||
|
|
||||||
|
std::vector <std::string>::const_iterator it;
|
||||||
|
for (it = columns.begin (); it != columns.end (); ++it)
|
||||||
|
if (*it != "id" &&
|
||||||
|
*it != "uuid" &&
|
||||||
|
*it != "project" &&
|
||||||
|
*it != "priority" &&
|
||||||
|
*it != "entry" &&
|
||||||
|
*it != "start" &&
|
||||||
|
*it != "end" &&
|
||||||
|
*it != "due" &&
|
||||||
|
*it != "age" &&
|
||||||
|
*it != "age_compact" &&
|
||||||
|
*it != "active" &&
|
||||||
|
*it != "tags" &&
|
||||||
|
*it != "recur" &&
|
||||||
|
*it != "recurrence_indicator" &&
|
||||||
|
*it != "tag_indicator" &&
|
||||||
|
*it != "description_only" &&
|
||||||
|
*it != "description" &&
|
||||||
|
*it != "wait")
|
||||||
|
bad.push_back (*it);
|
||||||
|
|
||||||
|
if (bad.size ())
|
||||||
|
{
|
||||||
|
std::string error;
|
||||||
|
join (error, ", ", bad);
|
||||||
|
throw std::string ("Unrecognized column name: ") + error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void validSortColumns (
|
||||||
|
const std::vector <std::string>& columns,
|
||||||
|
const std::vector <std::string>& sortColumns)
|
||||||
|
{
|
||||||
|
std::vector <std::string> bad;
|
||||||
|
std::vector <std::string>::const_iterator sc;
|
||||||
|
for (sc = sortColumns.begin (); sc != sortColumns.end (); ++sc)
|
||||||
|
{
|
||||||
|
std::vector <std::string>::const_iterator co;
|
||||||
|
for (co = columns.begin (); co != columns.end (); ++co)
|
||||||
|
if (sc->substr (0, sc->length () - 1) == *co)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (co == columns.end ())
|
||||||
|
bad.push_back (*sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bad.size ())
|
||||||
|
{
|
||||||
|
std::string error;
|
||||||
|
join (error, ", ", bad);
|
||||||
|
throw std::string ("Sort column is not part of the report: ") + error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -39,11 +39,6 @@
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "../auto.h"
|
#include "../auto.h"
|
||||||
|
|
||||||
// valid.cpp
|
|
||||||
void validReportColumns (const std::vector <std::string>&);
|
|
||||||
void validSortColumns (const std::vector <std::string>&, const std::vector <std::string>&);
|
|
||||||
bool validTag (const std::string&);
|
|
||||||
|
|
||||||
// task.cpp
|
// task.cpp
|
||||||
void gatherNextTasks (std::vector <Task>&);
|
void gatherNextTasks (std::vector <Task>&);
|
||||||
void onChangeCallback ();
|
void onChangeCallback ();
|
||||||
|
@ -104,6 +99,8 @@ std::string handleCustomReport (const std::string&);
|
||||||
std::string runCustomReport (const std::string&, const std::string&,
|
std::string runCustomReport (const std::string&, const std::string&,
|
||||||
const std::string&, const std::string&,
|
const std::string&, const std::string&,
|
||||||
const std::string&, std::vector <Task>&);
|
const std::string&, std::vector <Task>&);
|
||||||
|
void validReportColumns (const std::vector <std::string>&);
|
||||||
|
void validSortColumns (const std::vector <std::string>&, const std::vector <std::string>&);
|
||||||
|
|
||||||
// rules.cpp
|
// rules.cpp
|
||||||
void initializeColorRules ();
|
void initializeColorRules ();
|
||||||
|
|
|
@ -3,12 +3,12 @@ PROJECT = t.t tdb.t date.t duration.t t.benchmark.t text.t autocomplete.t \
|
||||||
cmd.t util.t
|
cmd.t util.t
|
||||||
CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti
|
CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti
|
||||||
LFLAGS = -L/usr/local/lib -lncurses
|
LFLAGS = -L/usr/local/lib -lncurses
|
||||||
OBJECTS = ../TDB.o ../Task.o ../valid.o ../text.o ../Date.o ../Table.o \
|
OBJECTS = ../TDB.o ../Task.o ../text.o ../Date.o ../Table.o ../Duration.o \
|
||||||
../Duration.o ../util.o ../Config.o ../Sequence.o ../Att.o ../Cmd.o \
|
../util.o ../Config.o ../Sequence.o ../Att.o ../Cmd.o ../Record.o \
|
||||||
../Record.o ../StringTable.o ../Subst.o ../Nibbler.o ../Location.o \
|
../StringTable.o ../Subst.o ../Nibbler.o ../Location.o ../Filter.o \
|
||||||
../Filter.o ../Context.o ../Keymap.o ../command.o ../interactive.o \
|
../Context.o ../Keymap.o ../command.o ../interactive.o ../report.o \
|
||||||
../report.o ../Grid.o ../color.o ../rules.o ../recur.o ../custom.o \
|
../Grid.o ../color.o ../rules.o ../recur.o ../custom.o ../import.o \
|
||||||
../import.o ../edit.o ../Timer.o ../Permission.o
|
../edit.o ../Timer.o ../Permission.o
|
||||||
|
|
||||||
all: $(PROJECT)
|
all: $(PROJECT)
|
||||||
|
|
||||||
|
|
118
src/valid.cpp
118
src/valid.cpp
|
@ -1,118 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// task - a command line task list manager.
|
|
||||||
//
|
|
||||||
// Copyright 2006 - 2009, Paul Beckingham.
|
|
||||||
// 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
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
#include <iostream>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#include "Context.h"
|
|
||||||
#include "Date.h"
|
|
||||||
#include "Duration.h"
|
|
||||||
#include "text.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "color.h"
|
|
||||||
|
|
||||||
extern Context context;
|
|
||||||
|
|
||||||
// TODO Relocate inside Context.
|
|
||||||
static std::vector <std::string> customReports;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool validTag (const std::string& input)
|
|
||||||
{
|
|
||||||
if ((input[0] == '-' || input[0] == '+') &&
|
|
||||||
input.length () > 1 &&
|
|
||||||
noSpaces (input))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void validReportColumns (const std::vector <std::string>& columns)
|
|
||||||
{
|
|
||||||
std::vector <std::string> bad;
|
|
||||||
|
|
||||||
std::vector <std::string>::const_iterator it;
|
|
||||||
for (it = columns.begin (); it != columns.end (); ++it)
|
|
||||||
if (*it != "id" &&
|
|
||||||
*it != "uuid" &&
|
|
||||||
*it != "project" &&
|
|
||||||
*it != "priority" &&
|
|
||||||
*it != "entry" &&
|
|
||||||
*it != "start" &&
|
|
||||||
*it != "end" &&
|
|
||||||
*it != "due" &&
|
|
||||||
*it != "age" &&
|
|
||||||
*it != "age_compact" &&
|
|
||||||
*it != "active" &&
|
|
||||||
*it != "tags" &&
|
|
||||||
*it != "recur" &&
|
|
||||||
*it != "recurrence_indicator" &&
|
|
||||||
*it != "tag_indicator" &&
|
|
||||||
*it != "description_only" &&
|
|
||||||
*it != "description" &&
|
|
||||||
*it != "wait")
|
|
||||||
bad.push_back (*it);
|
|
||||||
|
|
||||||
if (bad.size ())
|
|
||||||
{
|
|
||||||
std::string error;
|
|
||||||
join (error, ", ", bad);
|
|
||||||
throw std::string ("Unrecognized column name: ") + error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void validSortColumns (
|
|
||||||
const std::vector <std::string>& columns,
|
|
||||||
const std::vector <std::string>& sortColumns)
|
|
||||||
{
|
|
||||||
std::vector <std::string> bad;
|
|
||||||
std::vector <std::string>::const_iterator sc;
|
|
||||||
for (sc = sortColumns.begin (); sc != sortColumns.end (); ++sc)
|
|
||||||
{
|
|
||||||
std::vector <std::string>::const_iterator co;
|
|
||||||
for (co = columns.begin (); co != columns.end (); ++co)
|
|
||||||
if (sc->substr (0, sc->length () - 1) == *co)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (co == columns.end ())
|
|
||||||
bad.push_back (*sc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bad.size ())
|
|
||||||
{
|
|
||||||
std::string error;
|
|
||||||
join (error, ", ", bad);
|
|
||||||
throw std::string ("Sort column is not part of the report: ") + error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue