mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Merge branch '2.3.0' into 2.4.0
Conflicts: AUTHORS CMakeLists.txt NEWS src/A3.cpp src/CMakeLists.txt src/Config.cpp src/Duration.cpp src/Duration.h src/Nibbler.cpp src/Nibbler.h src/RX.cpp src/RX.h src/columns/ColDate.cpp src/columns/ColScheduled.cpp src/commands/Command.cpp src/legacy.cpp src/utf8.cpp src/utf8.h test/CMakeLists.txt test/bug.mergedeps.t.postponed test/duration.t.cpp test/merge.duplicates.t test/merge.simple_duplication.t test/merge.t test/nibbler.t.cpp test/roundtrip.t test/rx.t.cpp test/utf8.t.cpp
This commit is contained in:
commit
98f740e9d1
550 changed files with 6129 additions and 2976 deletions
|
@ -27,6 +27,7 @@ set (commands_SRCS Command.cpp Command.h
|
|||
CmdEdit.cpp CmdEdit.h
|
||||
CmdExec.cpp CmdExec.h
|
||||
CmdExport.cpp CmdExport.h
|
||||
CmdGet.cpp CmdGet.h
|
||||
CmdHelp.cpp CmdHelp.h
|
||||
CmdHistory.cpp CmdHistory.h
|
||||
CmdIDs.cpp CmdIDs.h
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <Context.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <main.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <util.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <stdlib.h>
|
||||
|
@ -351,22 +352,19 @@ int CmdCalendar::execute (std::string& output)
|
|||
// Table with holiday information
|
||||
if (context.config.get ("calendar.holidays") == "full")
|
||||
{
|
||||
std::vector <std::string> holidays;
|
||||
context.config.all (holidays);
|
||||
|
||||
ViewText holTable;
|
||||
holTable.width (context.getWidth ());
|
||||
holTable.add (Column::factory ("string", STRING_CMD_CAL_LABEL_DATE));
|
||||
holTable.add (Column::factory ("string", STRING_CMD_CAL_LABEL_HOL));
|
||||
|
||||
std::vector <std::string>::iterator it;
|
||||
Config::const_iterator it;
|
||||
std::map <time_t, std::vector<std::string> > hm; // we need to store multiple holidays per day
|
||||
for (it = holidays.begin (); it != holidays.end (); ++it)
|
||||
if (it->substr (0, 8) == "holiday.")
|
||||
if (it->substr (it->size () - 4) == "name")
|
||||
for (it = context.config.begin (); it != context.config.end (); ++it)
|
||||
if (it->first.substr (0, 8) == "holiday.")
|
||||
if (it->first.substr (it->first.size () - 4) == "name")
|
||||
{
|
||||
std::string holName = context.config.get ("holiday." + it->substr (8, it->size () - 13) + ".name");
|
||||
std::string holDate = context.config.get ("holiday." + it->substr (8, it->size () - 13) + ".date");
|
||||
std::string holName = context.config.get ("holiday." + it->first.substr (8, it->first.size () - 13) + ".name");
|
||||
std::string holDate = context.config.get ("holiday." + it->first.substr (8, it->first.size () - 13) + ".date");
|
||||
Date hDate (holDate.c_str (), context.config.get ("dateformat.holiday"));
|
||||
|
||||
if (date_after < hDate && hDate < date_before)
|
||||
|
@ -526,14 +524,12 @@ std::string CmdCalendar::renderMonths (
|
|||
// colorize holidays
|
||||
if (context.config.get ("calendar.holidays") != "none")
|
||||
{
|
||||
std::vector <std::string> holidays;
|
||||
context.config.all (holidays);
|
||||
std::vector <std::string>::iterator hol;
|
||||
for (hol = holidays.begin (); hol != holidays.end (); ++hol)
|
||||
if (hol->substr (0, 8) == "holiday.")
|
||||
if (hol->substr (hol->size () - 4) == "date")
|
||||
Config::const_iterator hol;
|
||||
for (hol = context.config.begin (); hol != context.config.end (); ++hol)
|
||||
if (hol->first.substr (0, 8) == "holiday.")
|
||||
if (hol->first.substr (hol->first.size () - 4) == "date")
|
||||
{
|
||||
std::string value = context.config.get (*hol);
|
||||
std::string value = hol->second;
|
||||
Date holDate (value.c_str (), context.config.get ("dateformat.holiday"));
|
||||
if (holDate.day () == d &&
|
||||
holDate.month () == months[mpl] &&
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <ViewText.h>
|
||||
#include <Context.h>
|
||||
|
@ -69,27 +70,24 @@ int CmdColor::execute (std::string& output)
|
|||
{
|
||||
out << "\n" << STRING_CMD_COLOR_HERE << "\n";
|
||||
|
||||
std::vector <std::string> all;
|
||||
context.config.all (all);
|
||||
|
||||
ViewText view;
|
||||
view.width (context.getWidth ());
|
||||
view.add (Column::factory ("string", STRING_CMD_COLOR_COLOR));
|
||||
view.add (Column::factory ("string", STRING_CMD_COLOR_DEFINITION));
|
||||
|
||||
std::vector <std::string>::iterator item;
|
||||
for (item = all.begin (); item != all.end (); ++item)
|
||||
Config::const_iterator item;
|
||||
for (item = context.config.begin (); item != context.config.end (); ++item)
|
||||
{
|
||||
// Skip items with 'color' in their name, that are not referring to
|
||||
// actual colors.
|
||||
if (*item != "_forcecolor" &&
|
||||
*item != "color" &&
|
||||
item->find ("color") == 0)
|
||||
if (item->first != "_forcecolor" &&
|
||||
item->first != "color" &&
|
||||
item->first.find ("color") == 0)
|
||||
{
|
||||
Color color (context.config.get (*item));
|
||||
Color color (context.config.get (item->first));
|
||||
int row = view.addRow ();
|
||||
view.set (row, 0, *item, color);
|
||||
view.set (row, 1, context.config.get (*item), color);
|
||||
view.set (row, 0, item->first, color);
|
||||
view.set (row, 1, item->second, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <algorithm>
|
||||
#include <Context.h>
|
||||
#include <ViewText.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,9 +25,11 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <Context.h>
|
||||
#include <JSON.h>
|
||||
#include <i18n.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
|
@ -102,9 +104,9 @@ int CmdConfig::execute (std::string& output)
|
|||
if (confirm (format (STRING_CMD_CONFIG_CONFIRM, name, context.config.get (name), value)))
|
||||
{
|
||||
if (comment != std::string::npos)
|
||||
*line = name + "=" + value + " " + line->substr (comment);
|
||||
*line = name + "=" + json::encode (value) + " " + line->substr (comment);
|
||||
else
|
||||
*line = name + "=" + value;
|
||||
*line = name + "=" + json::encode (value);
|
||||
|
||||
change = true;
|
||||
}
|
||||
|
@ -115,7 +117,7 @@ int CmdConfig::execute (std::string& output)
|
|||
if (!found &&
|
||||
confirm (format (STRING_CMD_CONFIG_CONFIRM2, name, value)))
|
||||
{
|
||||
contents.push_back (name + "=" + value);
|
||||
contents.push_back (name + "=" + json::encode (value));
|
||||
change = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <Context.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <util.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <text.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
@ -34,8 +35,9 @@
|
|||
#include <i18n.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <cmake.h>
|
||||
#ifdef HAVE_COMMIT
|
||||
#include <commit.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBGNUTLS
|
||||
#include <gnutls/gnutls.h>
|
||||
|
@ -136,7 +138,9 @@ int CmdDiagnostics::execute (std::string& output)
|
|||
|
||||
// Build date.
|
||||
<< " " << STRING_CMD_DIAG_BUILT << ": " << __DATE__ << " " << __TIME__ << "\n"
|
||||
#ifdef HAVE_COMMIT
|
||||
<< " " << STRING_CMD_DIAG_COMMIT << ": " << COMMIT << "\n"
|
||||
#endif
|
||||
<< " CMake: " << CMAKE_VERSION << "\n"
|
||||
<< " " << STRING_CMD_DIAG_CAPS << ":"
|
||||
#ifdef HAVE_LIBPTHREAD
|
||||
|
@ -145,24 +149,6 @@ int CmdDiagnostics::execute (std::string& output)
|
|||
<< " -pthreads"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SRANDOM
|
||||
<< " +srandom"
|
||||
#else
|
||||
<< " -srandom"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RANDOM
|
||||
<< " +random"
|
||||
#else
|
||||
<< " -random"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UUID
|
||||
<< " +uuid"
|
||||
#else
|
||||
<< " -uuid"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBGNUTLS
|
||||
<< " +tls"
|
||||
#else
|
||||
|
@ -171,12 +157,10 @@ int CmdDiagnostics::execute (std::string& output)
|
|||
<< "\n";
|
||||
|
||||
out << " libuuid: "
|
||||
#if defined (HAVE_UUID) and defined (HAVE_UUID_UNPARSE_LOWER)
|
||||
#ifdef HAVE_UUID_UNPARSE_LOWER
|
||||
<< "libuuid + uuid_unparse_lower"
|
||||
#elif defined (HAVE_UUID) and !defined (HAVE_UUID_UNPARSE_LOWER)
|
||||
<< "libuuid, no uuid_unparse_lower"
|
||||
#else
|
||||
<< "n/a"
|
||||
<< "libuuid, no uuid_unparse_lower"
|
||||
#endif
|
||||
<< "\n";
|
||||
|
||||
|
@ -213,16 +197,18 @@ int CmdDiagnostics::execute (std::string& output)
|
|||
<< location.mode ()
|
||||
<< "\n";
|
||||
|
||||
out << " Server: "
|
||||
<< context.config.get ("taskd.server")
|
||||
<< "\n";
|
||||
|
||||
out << " Locking: "
|
||||
<< (context.config.getBoolean ("locking")
|
||||
? STRING_CMD_DIAG_ENABLED
|
||||
: STRING_CMD_DIAG_DISABLED)
|
||||
<< "\n";
|
||||
|
||||
out << " GC: "
|
||||
<< (context.config.getBoolean ("gc")
|
||||
? STRING_CMD_DIAG_ENABLED
|
||||
: STRING_CMD_DIAG_DISABLED)
|
||||
<< "\n";
|
||||
|
||||
// Determine rc.editor/$EDITOR/$VISUAL.
|
||||
char* peditor;
|
||||
if (context.config.get ("editor") != "")
|
||||
|
@ -232,9 +218,50 @@ int CmdDiagnostics::execute (std::string& output)
|
|||
else if ((peditor = getenv ("EDITOR")) != NULL)
|
||||
out << " $EDITOR: " << peditor << "\n";
|
||||
|
||||
out << "\n";
|
||||
out << " Server: "
|
||||
<< context.config.get ("taskd.server")
|
||||
<< "\n";
|
||||
|
||||
if (context.config.get ("taskd.ca") != "")
|
||||
out << " CA: "
|
||||
<< context.config.get ("taskd.ca")
|
||||
<< (File (context.config.get ("taskd.ca")).readable ()
|
||||
? " (readable)" : " (not readable)")
|
||||
<< "\n";
|
||||
|
||||
if (context.config.get ("taskd.trust") != "")
|
||||
out << " Trust: override\n";
|
||||
|
||||
out << " Cert: "
|
||||
<< context.config.get ("taskd.certificate")
|
||||
<< (File (context.config.get ("taskd.certificate")).readable ()
|
||||
? " (readable)" : " (not readable)")
|
||||
<< "\n";
|
||||
|
||||
out << " Key: "
|
||||
<< context.config.get ("taskd.key")
|
||||
<< (File (context.config.get ("taskd.key")).readable ()
|
||||
? " (readable)" : " (not readable)")
|
||||
<< "\n";
|
||||
|
||||
out << " Ciphers: "
|
||||
<< context.config.get ("taskd.ciphers")
|
||||
<< "\n";
|
||||
|
||||
// Get credentials, but mask out the key.
|
||||
std::string credentials = context.config.get ("taskd.credentials");
|
||||
std::string::size_type last_slash = credentials.rfind ('/');
|
||||
if (last_slash != std::string::npos)
|
||||
credentials = credentials.substr (0, last_slash)
|
||||
+ "/"
|
||||
+ std::string (credentials.length () - last_slash - 1, '*');
|
||||
|
||||
out << " Creds: "
|
||||
<< credentials
|
||||
<< "\n\n";
|
||||
|
||||
// External commands.
|
||||
// Deprecated in 2.3.0 with push, pull, merge.
|
||||
out << bold.colorize (STRING_CMD_DIAG_EXTERNAL)
|
||||
<< "\n";
|
||||
{
|
||||
|
@ -296,24 +323,6 @@ int CmdDiagnostics::execute (std::string& output)
|
|||
out << bold.colorize (STRING_CMD_DIAG_TESTS)
|
||||
<< "\n";
|
||||
{
|
||||
out << " UUID gen: ";
|
||||
std::vector <std::string> uuids;
|
||||
std::string id;
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
id = uuid ();
|
||||
if (std::find (uuids.begin (), uuids.end (), id) != uuids.end ())
|
||||
{
|
||||
out << format (STRING_CMD_DIAG_UUID_BAD, i) << "\n";
|
||||
break;
|
||||
}
|
||||
else
|
||||
uuids.push_back (id);
|
||||
}
|
||||
|
||||
if (uuids.size () >= 1000)
|
||||
out << STRING_CMD_DIAG_UUID_GOOD << "\n";
|
||||
|
||||
// Determine terminal details.
|
||||
const char* term = getenv ("TERM");
|
||||
out << " $TERM: "
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <util.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <text.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
|
@ -658,20 +659,10 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
|||
std::vector <std::string>::iterator dep;
|
||||
for (dep = dependencies.begin (); dep != dependencies.end (); ++dep)
|
||||
{
|
||||
std::vector <int> ids;
|
||||
|
||||
// Crude UUID check
|
||||
if (dep->length () == 36)
|
||||
{
|
||||
int id = context.tdb2.pending.id (*dep);
|
||||
ids.push_back (id);
|
||||
}
|
||||
if (dep->length () >= 7)
|
||||
task.addDependency (*dep);
|
||||
else
|
||||
A3::extract_id (*dep, ids);
|
||||
|
||||
std::vector <int>::iterator id;
|
||||
for (id = ids.begin (); id != ids.end(); id++)
|
||||
task.addDependency (*id);
|
||||
task.addDependency ((int) strtol (dep->c_str (), NULL, 10));
|
||||
}
|
||||
|
||||
// UDAs
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <stdlib.h>
|
||||
#include <Context.h>
|
||||
#include <i18n.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <Context.h>
|
||||
#include <main.h>
|
||||
#include <i18n.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
69
src/commands/CmdGet.cpp
Normal file
69
src/commands/CmdGet.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <Context.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
#include <CmdGet.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdGet::CmdGet ()
|
||||
{
|
||||
_keyword = "_get";
|
||||
_usage = "task _get <DOM> [<DOM> ...]";
|
||||
_description = STRING_CMD_GET_USAGE;
|
||||
_read_only = true;
|
||||
_displays_id = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdGet::execute (std::string& output)
|
||||
{
|
||||
// Obtain the arguments from the description. That way, things like '--'
|
||||
// have already been handled.
|
||||
std::vector <std::string> words = context.a3.extract_words ();
|
||||
if (words.size () == 0)
|
||||
throw std::string (STRING_CMD_GET_NO_DOM);
|
||||
|
||||
std::vector <std::string> results;
|
||||
std::vector <std::string>::iterator word;
|
||||
for (word = words.begin (); word != words.end (); ++word)
|
||||
{
|
||||
Task t;
|
||||
results.push_back (context.dom.get (*word, t));
|
||||
}
|
||||
|
||||
join (output, " ", results);
|
||||
output += "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
42
src/commands/CmdGet.h
Normal file
42
src/commands/CmdGet.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDED_CMDGET
|
||||
#define INCLUDED_CMDGET
|
||||
|
||||
#include <string>
|
||||
#include <Command.h>
|
||||
|
||||
class CmdGet : public Command
|
||||
{
|
||||
public:
|
||||
CmdGet ();
|
||||
int execute (std::string&);
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <algorithm>
|
||||
#include <CmdHelp.h>
|
||||
#include <ViewText.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <Context.h>
|
||||
#include <ViewText.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <Context.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <Context.h>
|
||||
|
@ -98,121 +99,15 @@ int CmdImport::execute (std::string& output)
|
|||
continue;
|
||||
|
||||
// Parse the whole thing.
|
||||
json::value* root = json::parse (object);
|
||||
if (root->type () == json::j_object)
|
||||
{
|
||||
json::object* root_obj = (json::object*)root;
|
||||
Task task;
|
||||
Task task (object);
|
||||
|
||||
// For each object element...
|
||||
json_object_iter i;
|
||||
for (i = root_obj->_data.begin ();
|
||||
i != root_obj->_data.end ();
|
||||
++i)
|
||||
{
|
||||
// If the attribute is a recognized column.
|
||||
Column* col = context.columns[i->first];
|
||||
if (col)
|
||||
{
|
||||
// Any specified id is ignored.
|
||||
if (i->first == "id")
|
||||
;
|
||||
|
||||
// Urgency, if present, is ignored.
|
||||
else if (i->first == "urgency")
|
||||
;
|
||||
|
||||
// Dates are converted from ISO to epoch.
|
||||
else if (col->type () == "date")
|
||||
{
|
||||
Date d (unquoteText (i->second->dump ()));
|
||||
task.set (i->first, d.toEpochString ());
|
||||
}
|
||||
|
||||
// Tags are an array of JSON strings.
|
||||
else if (i->first == "tags")
|
||||
{
|
||||
json::array* tags = (json::array*)i->second;
|
||||
json_array_iter t;
|
||||
for (t = tags->_data.begin ();
|
||||
t != tags->_data.end ();
|
||||
++t)
|
||||
{
|
||||
json::string* tag = (json::string*)*t;
|
||||
task.addTag (tag->_data);
|
||||
}
|
||||
}
|
||||
|
||||
// Other types are simply added.
|
||||
else
|
||||
task.set (i->first, unquoteText (i->second->dump ()));
|
||||
}
|
||||
|
||||
// Several attributes do not have columns.
|
||||
// mask
|
||||
// imask
|
||||
// parent
|
||||
// UDA orphans
|
||||
else
|
||||
{
|
||||
// Annotations are an array of JSON objects with 'entry' and
|
||||
// 'description' values and must be converted.
|
||||
if (i->first == "annotations")
|
||||
{
|
||||
std::map <std::string, std::string> annos;
|
||||
|
||||
json::array* atts = (json::array*)i->second;
|
||||
json_array_iter annotations;
|
||||
for (annotations = atts->_data.begin ();
|
||||
annotations != atts->_data.end ();
|
||||
++annotations)
|
||||
{
|
||||
json::object* annotation = (json::object*)*annotations;
|
||||
json::string* when = (json::string*)annotation->_data["entry"];
|
||||
json::string* what = (json::string*)annotation->_data["description"];
|
||||
|
||||
if (! when)
|
||||
throw format (STRING_CMD_IMPORT_NO_ENTRY, *line);
|
||||
|
||||
if (! what)
|
||||
throw format (STRING_CMD_IMPORT_NO_DESC, *line);
|
||||
|
||||
std::string name = "annotation_" + Date (when->_data).toEpochString ();
|
||||
|
||||
annos.insert (std::make_pair (name, what->_data));
|
||||
}
|
||||
|
||||
task.setAnnotations (annos);
|
||||
}
|
||||
|
||||
// Attributes without columns are simply added.
|
||||
else if (i->first == "parent" ||
|
||||
i->first == "mask" ||
|
||||
i->first == "imask")
|
||||
{
|
||||
task.set (i->first, unquoteText (i->second->dump ()));
|
||||
}
|
||||
|
||||
// UDA Orphan - must be preserved.
|
||||
else
|
||||
{
|
||||
task.set (i->first, unquoteText (i->second->dump ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.tdb2.add (task);
|
||||
++count;
|
||||
std::cout << " "
|
||||
<< task.get ("uuid")
|
||||
<< " "
|
||||
<< task.get ("description")
|
||||
<< "\n";
|
||||
}
|
||||
else
|
||||
throw format (STRING_CMD_IMPORT_NOT_JSON, *line);
|
||||
|
||||
delete root;
|
||||
context.tdb2.add (task);
|
||||
++count;
|
||||
std::cout << " "
|
||||
<< task.get ("uuid")
|
||||
<< " "
|
||||
<< task.get ("description")
|
||||
<< "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include <Context.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <CmdInstall.h>
|
||||
#include <Context.h>
|
||||
#include <i18n.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <Context.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <CmdLogo.h>
|
||||
#include <Context.h>
|
||||
#include <text.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <Context.h>
|
||||
|
@ -51,6 +52,8 @@ CmdMerge::CmdMerge ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdMerge::execute (std::string& output)
|
||||
{
|
||||
context.footnote ("The 'merge' command is deprecated, and will be removed in a subsequent release.");
|
||||
|
||||
// invoke gc and commit before merging in order to update data files
|
||||
context.tdb2.gc ();
|
||||
context.tdb2.commit ();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <main.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <util.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <Context.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <Context.h>
|
||||
|
@ -49,6 +50,8 @@ CmdPull::CmdPull ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdPull::execute (std::string& output)
|
||||
{
|
||||
context.footnote ("The 'pull' command is deprecated, and will be removed in a subsequent release.");
|
||||
|
||||
std::vector <std::string> words = context.a3.extract_words ();
|
||||
std::string file;
|
||||
if (words.size ())
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <Context.h>
|
||||
|
@ -51,6 +52,8 @@ CmdPush::CmdPush ()
|
|||
// Because this is potentially on another machine, no checking can be performed.
|
||||
int CmdPush::execute (std::string& output)
|
||||
{
|
||||
context.footnote ("The 'push' command is deprecated, and will be removed in a subsequent release.");
|
||||
|
||||
std::vector <std::string> words = context.a3.extract_words ();
|
||||
std::string file;
|
||||
if (words.size ())
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <Context.h>
|
||||
|
@ -51,15 +52,12 @@ int CmdReports::execute (std::string& output)
|
|||
std::vector <std::string> reports;
|
||||
|
||||
// Add custom reports.
|
||||
std::vector <std::string> vars;
|
||||
context.config.all (vars);
|
||||
|
||||
std::vector <std::string>::iterator i;
|
||||
for (i = vars.begin (); i != vars.end (); ++i)
|
||||
Config::const_iterator i;
|
||||
for (i = context.config.begin (); i != context.config.end (); ++i)
|
||||
{
|
||||
if (i->substr (0, 7) == "report.")
|
||||
if (i->first.substr (0, 7) == "report.")
|
||||
{
|
||||
std::string report = i->substr (7);
|
||||
std::string report = i->first.substr (7);
|
||||
std::string::size_type columns = report.find (".columns");
|
||||
if (columns != std::string::npos)
|
||||
reports.push_back (report.substr (0, columns));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
@ -133,6 +134,7 @@ int CmdShow::execute (std::string& output)
|
|||
" dateformat.info"
|
||||
" dateformat.report"
|
||||
" debug"
|
||||
" debug.tls"
|
||||
" default.command"
|
||||
" default.due"
|
||||
" default.priority"
|
||||
|
@ -164,14 +166,14 @@ int CmdShow::execute (std::string& output)
|
|||
" list.all.tags"
|
||||
" locale"
|
||||
" locking"
|
||||
" merge.autopush"
|
||||
" merge.default.uri"
|
||||
" merge.autopush" // Deprecated 2.3.0
|
||||
" merge.default.uri" // Deprecated 2.3.0
|
||||
" monthsperline"
|
||||
" nag"
|
||||
" patterns"
|
||||
" print.empty.columns"
|
||||
" pull.default.uri"
|
||||
" push.default.uri"
|
||||
" pull.default.uri" // Deprecated 2.3.0
|
||||
" push.default.uri" // Deprecated 2.3.0
|
||||
" recurrence.indicator"
|
||||
" recurrence.limit"
|
||||
" regex"
|
||||
|
@ -185,7 +187,12 @@ int CmdShow::execute (std::string& output)
|
|||
" shell.prompt"
|
||||
" tag.indicator"
|
||||
" taskd.server"
|
||||
" taskd.ca"
|
||||
" taskd.certificate"
|
||||
" taskd.ciphers"
|
||||
" taskd.credentials"
|
||||
" taskd.key"
|
||||
" taskd.trust"
|
||||
" undo.style"
|
||||
" urgency.active.coefficient"
|
||||
" urgency.scheduled.coefficient"
|
||||
|
@ -210,37 +217,35 @@ int CmdShow::execute (std::string& output)
|
|||
// is redirected to a file, or stdout is not a tty.
|
||||
recognized += "_forcecolor ";
|
||||
|
||||
std::vector <std::string> all;
|
||||
context.config.all (all);
|
||||
|
||||
std::vector <std::string> unrecognized;
|
||||
std::vector <std::string>::iterator i;
|
||||
for (i = all.begin (); i != all.end (); ++i)
|
||||
Config::const_iterator i;
|
||||
for (i = context.config.begin (); i != context.config.end (); ++i)
|
||||
{
|
||||
// Disallow partial matches by tacking a leading and trailing space on each
|
||||
// variable name.
|
||||
std::string pattern = " " + *i + " ";
|
||||
std::string pattern = " " + i->first + " ";
|
||||
if (recognized.find (pattern) == std::string::npos)
|
||||
{
|
||||
// These are special configuration variables, because their name is
|
||||
// dynamic.
|
||||
if (i->substr (0, 14) != "color.keyword." &&
|
||||
i->substr (0, 14) != "color.project." &&
|
||||
i->substr (0, 10) != "color.tag." &&
|
||||
i->substr (0, 10) != "color.uda." &&
|
||||
i->substr (0, 8) != "holiday." &&
|
||||
i->substr (0, 7) != "report." &&
|
||||
i->substr (0, 6) != "alias." &&
|
||||
i->substr (0, 5) != "hook." &&
|
||||
i->substr (0, 5) != "push." &&
|
||||
i->substr (0, 5) != "pull." &&
|
||||
i->substr (0, 6) != "merge." &&
|
||||
i->substr (0, 4) != "uda." &&
|
||||
i->substr (0, 21) != "urgency.user.project." &&
|
||||
i->substr (0, 17) != "urgency.user.tag." &&
|
||||
i->substr (0, 12) != "urgency.uda.")
|
||||
if (i->first.substr (0, 14) != "color.keyword." &&
|
||||
i->first.substr (0, 14) != "color.project." &&
|
||||
i->first.substr (0, 10) != "color.tag." &&
|
||||
i->first.substr (0, 10) != "color.uda." &&
|
||||
i->first.substr (0, 8) != "holiday." &&
|
||||
i->first.substr (0, 7) != "report." &&
|
||||
i->first.substr (0, 6) != "alias." &&
|
||||
i->first.substr (0, 5) != "hook." &&
|
||||
i->first.substr (0, 5) != "push." && // Deprecated 2.3.0
|
||||
i->first.substr (0, 5) != "pull." && // Deprecated 2.3.0
|
||||
i->first.substr (0, 6) != "merge." && // Deprecated 2.3.0
|
||||
i->first.substr (0, 4) != "uda." &&
|
||||
i->first.substr (0, 4) != "default." &&
|
||||
i->first.substr (0, 21) != "urgency.user.project." &&
|
||||
i->first.substr (0, 17) != "urgency.user.tag." &&
|
||||
i->first.substr (0, 12) != "urgency.uda.")
|
||||
{
|
||||
unrecognized.push_back (*i);
|
||||
unrecognized.push_back (i->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -250,9 +255,9 @@ int CmdShow::execute (std::string& output)
|
|||
Config default_config;
|
||||
default_config.setDefaults ();
|
||||
|
||||
for (i = all.begin (); i != all.end (); ++i)
|
||||
if (context.config.get (*i) != default_config.get (*i))
|
||||
default_values.push_back (*i);
|
||||
for (i = context.config.begin (); i != context.config.end (); ++i)
|
||||
if (i->second != default_config.get (i->first))
|
||||
default_values.push_back (i->first);
|
||||
|
||||
// Create output view.
|
||||
ViewText view;
|
||||
|
@ -276,37 +281,27 @@ int CmdShow::execute (std::string& output)
|
|||
section = "";
|
||||
|
||||
std::string::size_type loc;
|
||||
for (i = all.begin (); i != all.end (); ++i)
|
||||
for (i = context.config.begin (); i != context.config.end (); ++i)
|
||||
{
|
||||
loc = i->find (section, 0);
|
||||
loc = i->first.find (section, 0);
|
||||
if (loc != std::string::npos)
|
||||
{
|
||||
// Look for unrecognized.
|
||||
Color color;
|
||||
if (std::find (unrecognized.begin (), unrecognized.end (), *i) != unrecognized.end ())
|
||||
if (std::find (unrecognized.begin (), unrecognized.end (), i->first) != unrecognized.end ())
|
||||
{
|
||||
issue_error = true;
|
||||
color = error;
|
||||
}
|
||||
else if (std::find (default_values.begin (), default_values.end (), *i) != default_values.end ())
|
||||
else if (std::find (default_values.begin (), default_values.end (), i->first) != default_values.end ())
|
||||
{
|
||||
issue_warning = true;
|
||||
color = warning;
|
||||
}
|
||||
|
||||
std::string value = context.config.get (*i);
|
||||
// hide sensible information
|
||||
if ( (i->substr (0, 5) == "push." ||
|
||||
i->substr (0, 5) == "pull." ||
|
||||
i->substr (0, 6) == "merge.") && (i->find (".uri") != std::string::npos) ) {
|
||||
|
||||
Uri uri (value);
|
||||
uri.parse ();
|
||||
value = uri.ToString ();
|
||||
}
|
||||
|
||||
std::string value = i->second;
|
||||
int row = view.addRow ();
|
||||
view.set (row, 0, *i, color);
|
||||
view.set (row, 0, i->first, color);
|
||||
view.set (row, 1, value, color);
|
||||
}
|
||||
}
|
||||
|
@ -331,6 +326,7 @@ int CmdShow::execute (std::string& output)
|
|||
{
|
||||
out << STRING_CMD_SHOW_UNREC << "\n";
|
||||
|
||||
std::vector <std::string>::iterator i;
|
||||
for (i = unrecognized.begin (); i != unrecognized.end (); ++i)
|
||||
out << " " << *i << "\n";
|
||||
|
||||
|
@ -376,7 +372,7 @@ int CmdShow::execute (std::string& output)
|
|||
// Verify installation. This is mentioned in the documentation as the way
|
||||
// to ensure everything is properly installed.
|
||||
|
||||
if (all.size () == 0)
|
||||
if (context.config.size () == 0)
|
||||
{
|
||||
out << STRING_CMD_SHOW_EMPTY << "\n";
|
||||
rc = 1;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <main.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <stdlib.h>
|
||||
|
@ -75,7 +76,7 @@ int CmdStats::execute (std::string& output)
|
|||
std::vector <std::string> backlogTxns = context.tdb2.backlog.get_lines ();
|
||||
int backlogCount = 0;
|
||||
for (tx = backlogTxns.begin (); tx != backlogTxns.end (); ++tx)
|
||||
if ((*tx)[0] == '[')
|
||||
if ((*tx)[0] == '{')
|
||||
++backlogCount;
|
||||
|
||||
// Get all the tasks.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <main.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,13 +25,15 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <iostream>
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <inttypes.h>
|
||||
#include <signal.h>
|
||||
#include <Context.h>
|
||||
#include <Socket.h>
|
||||
#include <TLSClient.h>
|
||||
#include <Color.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
#include <CmdSync.h>
|
||||
|
||||
|
@ -41,7 +43,7 @@ extern Context context;
|
|||
CmdSync::CmdSync ()
|
||||
{
|
||||
_keyword = "synchronize";
|
||||
_usage = "task synchronize";
|
||||
_usage = "task synchronize [initialize]";
|
||||
_description = STRING_CMD_SYNC_USAGE;
|
||||
_read_only = false;
|
||||
_displays_id = false;
|
||||
|
@ -51,17 +53,38 @@ CmdSync::CmdSync ()
|
|||
int CmdSync::execute (std::string& output)
|
||||
{
|
||||
int status = 0;
|
||||
Timer timer_sync;
|
||||
timer_sync.start ();
|
||||
|
||||
#ifdef HAVE_LIBGNUTLS
|
||||
std::stringstream out;
|
||||
|
||||
// Loog for the 'init' keyword to indicate one-time pending.data upload.
|
||||
bool first_time_init = false;
|
||||
std::vector <std::string> words = context.a3.extract_words ();
|
||||
std::vector <std::string>::iterator word;
|
||||
for (word = words.begin (); word != words.end (); ++word)
|
||||
{
|
||||
if (closeEnough ("initialize", *word, 4))
|
||||
{
|
||||
if (!context.config.getBoolean ("confirmation") ||
|
||||
confirm (STRING_CMD_SYNC_INIT))
|
||||
first_time_init = true;
|
||||
else
|
||||
throw std::string (STRING_CMD_SYNC_NO_INIT);
|
||||
}
|
||||
}
|
||||
|
||||
// If no server is set up, quit.
|
||||
std::string connection = context.config.get ("taskd.server");
|
||||
if (connection == "" ||
|
||||
connection.rfind (':') == std::string::npos)
|
||||
throw std::string (STRING_CMD_SYNC_NO_SERVER);
|
||||
|
||||
// If push/pull/merge is configured, quit.
|
||||
if (context.config.get ("merge.autopush") != "" ||
|
||||
context.config.get ("merge.default.uri") != "" ||
|
||||
context.config.get ("push.default.uri") != "" ||
|
||||
context.config.get ("pull.default.uri") != "")
|
||||
throw std::string (STRING_CMD_SYNC_NOMERGE);
|
||||
|
||||
// Obtain credentials.
|
||||
std::string credentials_string = context.config.get ("taskd.credentials");
|
||||
if (credentials_string == "")
|
||||
|
@ -72,21 +95,53 @@ int CmdSync::execute (std::string& output)
|
|||
if (credentials.size () != 3)
|
||||
throw std::string (STRING_CMD_SYNC_BAD_CRED);
|
||||
|
||||
// Read backlog.data.
|
||||
std::string payload = "";
|
||||
File backlog (context.config.get ("data.location") + "/backlog.data");
|
||||
if (backlog.exists ())
|
||||
backlog.read (payload);
|
||||
bool trust = context.config.getBoolean ("taskd.trust");
|
||||
|
||||
// Count the number of tasks being uploaded.
|
||||
// CA must exist, if provided.
|
||||
File ca (context.config.get ("taskd.ca"));
|
||||
if (ca._data != "" && ! ca.exists ())
|
||||
throw std::string (STRING_CMD_SYNC_BAD_CA);
|
||||
|
||||
if (trust && ca._data != "")
|
||||
throw std::string (STRING_CMD_SYNC_TRUST_CA);
|
||||
|
||||
File certificate (context.config.get ("taskd.certificate"));
|
||||
if (! certificate.exists ())
|
||||
throw std::string (STRING_CMD_SYNC_BAD_CERT);
|
||||
|
||||
File key (context.config.get ("taskd.key"));
|
||||
if (! key.exists ())
|
||||
throw std::string (STRING_CMD_SYNC_BAD_KEY);
|
||||
|
||||
// If this is a first-time initialization, send pending.data, not
|
||||
// backlog.data.
|
||||
std::string payload = "";
|
||||
int upload_count = 0;
|
||||
if (first_time_init)
|
||||
{
|
||||
std::vector <std::string> lines;
|
||||
split (lines, payload, "\n");
|
||||
// Delete backlog.data. Because if we're uploading everything, the list of
|
||||
// deltas is meaningless.
|
||||
context.tdb2.backlog._file.truncate ();
|
||||
|
||||
std::vector <Task> pending = context.tdb2.pending.get_tasks ();
|
||||
std::vector <Task>::iterator i;
|
||||
for (i = pending.begin (); i != pending.end (); ++i)
|
||||
{
|
||||
payload += i->composeJSON () + "\n";
|
||||
++upload_count;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector <std::string> lines = context.tdb2.backlog.get_lines ();
|
||||
std::vector <std::string>::iterator i;
|
||||
for (i = lines.begin (); i != lines.end (); ++i)
|
||||
if ((*i)[0] == '[')
|
||||
{
|
||||
if ((*i)[0] == '{')
|
||||
++upload_count;
|
||||
|
||||
payload += *i + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Send 'sync' + payload.
|
||||
|
@ -97,15 +152,22 @@ int CmdSync::execute (std::string& output)
|
|||
request.set ("user", credentials[1]);
|
||||
request.set ("key", credentials[2]);
|
||||
|
||||
// TODO Add the other necessary header fields.
|
||||
|
||||
request.setPayload (payload);
|
||||
|
||||
out << format (STRING_CMD_SYNC_PROGRESS, connection)
|
||||
<< "\n";
|
||||
|
||||
// Ignore harmful signals.
|
||||
signal (SIGHUP, SIG_IGN);
|
||||
signal (SIGINT, SIG_IGN);
|
||||
signal (SIGKILL, SIG_IGN);
|
||||
signal (SIGPIPE, SIG_IGN);
|
||||
signal (SIGTERM, SIG_IGN);
|
||||
signal (SIGUSR1, SIG_IGN);
|
||||
signal (SIGUSR2, SIG_IGN);
|
||||
|
||||
Msg response;
|
||||
if (send (connection, request, response))
|
||||
if (send (connection, ca._data, certificate._data, key._data, trust, request, response))
|
||||
{
|
||||
std::string code = response.get ("code");
|
||||
if (code == "200")
|
||||
|
@ -118,15 +180,17 @@ int CmdSync::execute (std::string& output)
|
|||
std::vector <std::string> lines;
|
||||
split (lines, payload, '\n');
|
||||
|
||||
// TODO This is not necessary if only a synch key was received.
|
||||
// Load all tasks.
|
||||
context.tdb2.all_tasks ();
|
||||
// Load all tasks, but only if necessary. There is always a sync key in
|
||||
// the payload, so if there are two or more lines, then we have merging
|
||||
// to perform, otherwise it's just a backlog.data update.
|
||||
if (lines.size () > 1)
|
||||
context.tdb2.all_tasks ();
|
||||
|
||||
std::string synch_key = "";
|
||||
std::string sync_key = "";
|
||||
std::vector <std::string>::iterator line;
|
||||
for (line = lines.begin (); line != lines.end (); ++line)
|
||||
{
|
||||
if ((*line)[0] == '[')
|
||||
if ((*line)[0] == '{')
|
||||
{
|
||||
++download_count;
|
||||
|
||||
|
@ -158,28 +222,29 @@ int CmdSync::execute (std::string& output)
|
|||
}
|
||||
else if (*line != "")
|
||||
{
|
||||
synch_key = *line;
|
||||
context.debug ("Synch key " + synch_key);
|
||||
sync_key = *line;
|
||||
context.debug ("Sync key " + sync_key);
|
||||
}
|
||||
|
||||
// Otherwise line is blank, so ignore it.
|
||||
}
|
||||
|
||||
// Only update everything if there is a new synch_key. No synch_key means
|
||||
// Only update everything if there is a new sync_key. No sync_key means
|
||||
// something horrible happened on the other end of the wire.
|
||||
if (synch_key != "")
|
||||
if (sync_key != "")
|
||||
{
|
||||
// Truncate backlog.data, save new synch_key.
|
||||
// Truncate backlog.data, save new sync_key.
|
||||
context.tdb2.backlog._file.truncate ();
|
||||
context.tdb2.backlog.clear_tasks ();
|
||||
context.tdb2.backlog.clear_lines ();
|
||||
context.tdb2.backlog.add_line (synch_key + "\n");
|
||||
context.tdb2.backlog.add_line (sync_key + "\n");
|
||||
|
||||
// Commit all changes.
|
||||
context.tdb2.commit ();
|
||||
|
||||
// Present a clear status message.
|
||||
if (upload_count == 0 && download_count == 0)
|
||||
// Note: should not happen - expect code 201 instead.
|
||||
context.footnote (STRING_CMD_SYNC_SUCCESS0);
|
||||
else if (upload_count == 0 && download_count > 0)
|
||||
context.footnote (format (STRING_CMD_SYNC_SUCCESS2, download_count));
|
||||
|
@ -193,6 +258,13 @@ int CmdSync::execute (std::string& output)
|
|||
{
|
||||
context.footnote (STRING_CMD_SYNC_SUCCESS_NOP);
|
||||
}
|
||||
else if (code == "301")
|
||||
{
|
||||
std::string new_server = response.get ("info");
|
||||
context.config.set ("taskd.server", new_server);
|
||||
context.error (STRING_CMD_SYNC_RELOCATE0);
|
||||
context.error (" " + format (STRING_CMD_SYNC_RELOCATE1, new_server));
|
||||
}
|
||||
else if (code == "430")
|
||||
{
|
||||
context.error (STRING_CMD_SYNC_FAIL_ACCOUNT);
|
||||
|
@ -206,7 +278,7 @@ int CmdSync::execute (std::string& output)
|
|||
status = 2;
|
||||
}
|
||||
|
||||
// Display all errors returned. This is required by the server protocol.
|
||||
// Display all errors returned. This is recommended by the server protocol.
|
||||
std::string to_be_displayed = response.get ("messages");
|
||||
if (to_be_displayed != "")
|
||||
{
|
||||
|
@ -233,26 +305,33 @@ int CmdSync::execute (std::string& output)
|
|||
out << "\n";
|
||||
output = out.str ();
|
||||
|
||||
/*
|
||||
timer_sync.stop ();
|
||||
std::stringstream s;
|
||||
s << "Sync "
|
||||
<< Date ().toISO ()
|
||||
<< " sync:"
|
||||
<< timer_sync.total ()
|
||||
<< "\n";
|
||||
debug (s.str ());
|
||||
*/
|
||||
// Restore signal handling.
|
||||
signal (SIGHUP, SIG_DFL);
|
||||
signal (SIGINT, SIG_DFL);
|
||||
signal (SIGKILL, SIG_DFL);
|
||||
signal (SIGPIPE, SIG_DFL);
|
||||
signal (SIGTERM, SIG_DFL);
|
||||
signal (SIGUSR1, SIG_DFL);
|
||||
signal (SIGUSR2, SIG_DFL);
|
||||
|
||||
#else
|
||||
// Without GnuTLS found at compile time, there is no working sync command.
|
||||
throw std::string (STRING_CMD_SYNC_NO_TLS);
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CmdSync::send (
|
||||
const std::string& to,
|
||||
const std::string& ca,
|
||||
const std::string& certificate,
|
||||
const std::string& key,
|
||||
bool trust,
|
||||
const Msg& request,
|
||||
Msg& response)
|
||||
{
|
||||
#ifdef HAVE_LIBGNUTLS
|
||||
std::string::size_type colon = to.rfind (':');
|
||||
if (colon == std::string::npos)
|
||||
throw format (STRING_CMD_SYNC_BAD_SERVER, to);
|
||||
|
@ -262,13 +341,18 @@ bool CmdSync::send (
|
|||
|
||||
try
|
||||
{
|
||||
Socket s;
|
||||
s.connect (server, port);
|
||||
s.write (request.serialize () + "\n");
|
||||
TLSClient client;
|
||||
client.debug (context.config.getInteger ("debug.tls"));
|
||||
|
||||
client.trust (trust);
|
||||
client.ciphers (context.config.get ("taskd.ciphers"));
|
||||
client.init (ca, certificate, key);
|
||||
client.connect (server, port);
|
||||
client.send (request.serialize () + "\n");
|
||||
|
||||
std::string incoming;
|
||||
s.read (incoming);
|
||||
s.close ();
|
||||
client.recv (incoming);
|
||||
client.bye ();
|
||||
|
||||
response.parse (incoming);
|
||||
return true;
|
||||
|
@ -276,10 +360,11 @@ bool CmdSync::send (
|
|||
|
||||
catch (std::string& error)
|
||||
{
|
||||
context.debug (error);
|
||||
context.error (error);
|
||||
}
|
||||
|
||||
// Indicate message failed.
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -39,7 +39,7 @@ public:
|
|||
int execute (std::string&);
|
||||
|
||||
private:
|
||||
bool send (const std::string&, const Msg&, Msg&);
|
||||
bool send (const std::string&, const std::string&, const std::string&, const std::string&, bool, const Msg&, Msg&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include <Context.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <Context.h>
|
||||
|
@ -53,19 +54,16 @@ int CmdUDAs::execute (std::string& output)
|
|||
int rc = 0;
|
||||
std::stringstream out;
|
||||
|
||||
std::vector <std::string> names;
|
||||
context.config.all (names);
|
||||
|
||||
std::vector <std::string> udas;
|
||||
std::vector <std::string>::iterator name;
|
||||
for (name = names.begin (); name != names.end (); ++name)
|
||||
Config::const_iterator name;
|
||||
for (name = context.config.begin (); name != context.config.end (); ++name)
|
||||
{
|
||||
if (name->substr (0, 4) == "uda." &&
|
||||
name->find (".type") != std::string::npos)
|
||||
if (name->first.substr (0, 4) == "uda." &&
|
||||
name->first.find (".type") != std::string::npos)
|
||||
{
|
||||
std::string::size_type period = name->find ('.', 4);
|
||||
std::string::size_type period = name->first.find ('.', 4);
|
||||
if (period != std::string::npos)
|
||||
udas.push_back (name->substr (4, period - 4));
|
||||
udas.push_back (name->first.substr (4, period - 4));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,13 +75,15 @@ int CmdUDAs::execute (std::string& output)
|
|||
{
|
||||
std::sort (udas.begin (), udas.end ());
|
||||
|
||||
// Render a list of UDA name, type and label.
|
||||
// Render a list of UDA name, type, label, allowed values,
|
||||
// possible default value, and finally the usage count.
|
||||
ViewText view;
|
||||
view.width (context.getWidth ());
|
||||
view.add (Column::factory ("string", STRING_COLUMN_LABEL_UDA));
|
||||
view.add (Column::factory ("string", STRING_COLUMN_LABEL_TYPE));
|
||||
view.add (Column::factory ("string", STRING_COLUMN_LABEL_LABEL));
|
||||
view.add (Column::factory ("string", STRING_COLUMN_LABEL_VALUES));
|
||||
view.add (Column::factory ("string", STRING_COLUMN_LABEL_DEFAULT));
|
||||
view.add (Column::factory ("string", STRING_COLUMN_LABEL_UDACOUNT));
|
||||
|
||||
std::vector <std::string>::iterator uda;
|
||||
|
@ -92,6 +92,7 @@ int CmdUDAs::execute (std::string& output)
|
|||
std::string type = context.config.get ("uda." + *uda + ".type");
|
||||
std::string label = context.config.get ("uda." + *uda + ".label");
|
||||
std::string values = context.config.get ("uda." + *uda + ".values");
|
||||
std::string defval = context.config.get ("uda." + *uda + ".default");
|
||||
if (label == "")
|
||||
label = *uda;
|
||||
|
||||
|
@ -107,7 +108,8 @@ int CmdUDAs::execute (std::string& output)
|
|||
view.set (row, 1, type);
|
||||
view.set (row, 2, label);
|
||||
view.set (row, 3, values);
|
||||
view.set (row, 4, count);
|
||||
view.set (row, 4, defval);
|
||||
view.set (row, 5, count);
|
||||
}
|
||||
|
||||
out << optionalBlankLine ()
|
||||
|
@ -178,19 +180,16 @@ CmdCompletionUDAs::CmdCompletionUDAs ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdCompletionUDAs::execute (std::string& output)
|
||||
{
|
||||
std::vector <std::string> names;
|
||||
context.config.all (names);
|
||||
|
||||
std::vector <std::string> udas;
|
||||
std::vector <std::string>::iterator name;
|
||||
for (name = names.begin (); name != names.end (); ++name)
|
||||
Config::const_iterator name;
|
||||
for (name = context.config.begin (); name != context.config.end (); ++name)
|
||||
{
|
||||
if (name->substr (0, 4) == "uda." &&
|
||||
name->find (".type") != std::string::npos)
|
||||
if (name->first.substr (0, 4) == "uda." &&
|
||||
name->first.find (".type") != std::string::npos)
|
||||
{
|
||||
std::string::size_type period = name->find ('.', 4);
|
||||
std::string::size_type period = name->first.find ('.', 4);
|
||||
if (period != std::string::npos)
|
||||
udas.push_back (name->substr (4, period - 4));
|
||||
udas.push_back (name->first.substr (4, period - 4));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <Context.h>
|
||||
#include <i18n.h>
|
||||
#include <CmdUndo.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include <Context.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,12 +25,14 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include <Context.h>
|
||||
#include <ViewText.h>
|
||||
#include <cmake.h>
|
||||
#ifdef HAVE_COMMIT
|
||||
#include <commit.h>
|
||||
#endif
|
||||
#include <CmdVersion.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
|
@ -35,7 +36,6 @@
|
|||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
#include <Command.h>
|
||||
#include <cmake.h>
|
||||
#include <main.h>
|
||||
|
||||
#include <CmdAdd.h>
|
||||
|
@ -61,6 +61,7 @@
|
|||
#include <CmdExec.h>
|
||||
#endif
|
||||
#include <CmdExport.h>
|
||||
#include <CmdGet.h>
|
||||
#include <CmdHelp.h>
|
||||
#include <CmdHistory.h>
|
||||
#include <CmdIDs.h>
|
||||
|
@ -133,6 +134,7 @@ void Command::factory (std::map <std::string, Command*>& all)
|
|||
c = new CmdExec (); all[c->keyword ()] = c;
|
||||
#endif
|
||||
c = new CmdExport (); all[c->keyword ()] = c;
|
||||
c = new CmdGet (); all[c->keyword ()] = c;
|
||||
c = new CmdGHistoryMonthly (); all[c->keyword ()] = c;
|
||||
c = new CmdGHistoryAnnual (); all[c->keyword ()] = c;
|
||||
c = new CmdHelp (); all[c->keyword ()] = c;
|
||||
|
@ -170,16 +172,13 @@ void Command::factory (std::map <std::string, Command*>& all)
|
|||
c = new CmdZshCompletionUuids (); all[c->keyword ()] = c;
|
||||
|
||||
// Instantiate a command object for each custom report.
|
||||
std::vector <std::string> variables;
|
||||
context.config.all (variables);
|
||||
|
||||
std::vector <std::string> reports;
|
||||
std::vector <std::string>::iterator i;
|
||||
for (i = variables.begin (); i != variables.end (); ++i)
|
||||
Config::const_iterator i;
|
||||
for (i = context.config.begin (); i != context.config.end (); ++i)
|
||||
{
|
||||
if (i->substr (0, 7) == "report.")
|
||||
if (i->first.substr (0, 7) == "report.")
|
||||
{
|
||||
std::string report = i->substr (7);
|
||||
std::string report = i->first.substr (7);
|
||||
std::string::size_type columns = report.find (".columns");
|
||||
if (columns != std::string::npos)
|
||||
reports.push_back (report.substr (0, columns));
|
||||
|
@ -465,200 +464,8 @@ void Command::modify_task (
|
|||
const A3& arguments,
|
||||
std::string& description)
|
||||
{
|
||||
// Coalesce arguments together into sets to be processed as a batch.
|
||||
unsigned int pos = 0;
|
||||
Arg arg;
|
||||
while (next_mod_group (arguments, arg, pos))
|
||||
{
|
||||
// Attributes are essentially name:value pairs, and correspond directly
|
||||
// to stored attributes.
|
||||
if (arg._category == Arg::cat_attr)
|
||||
{
|
||||
std::string name;
|
||||
std::string value;
|
||||
A3::extract_attr (arg._raw, name, value);
|
||||
if (A3::is_attribute (name, name)) // Canonicalize
|
||||
{
|
||||
//std::cout << "# Command::modify_task name='" << name << "' value='" << value << "'\n";
|
||||
|
||||
// Get the column info.
|
||||
Column* column = context.columns[name];
|
||||
|
||||
if (value == "")
|
||||
{
|
||||
task.remove (name);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Dependencies are used as IDs.
|
||||
if (name == "depends")
|
||||
{
|
||||
// Parse IDs
|
||||
std::vector <std::string> deps;
|
||||
split (deps, value, ',');
|
||||
|
||||
// Apply or remove dendencies in turn.
|
||||
std::vector <std::string>::iterator i;
|
||||
for (i = deps.begin (); i != deps.end (); i++)
|
||||
{
|
||||
bool removal = false;
|
||||
std::string& dep = *i;
|
||||
|
||||
if (dep[0] == '-')
|
||||
{
|
||||
removal = true;
|
||||
dep = i->substr(1, std::string::npos);
|
||||
}
|
||||
|
||||
std::vector <int> ids;
|
||||
// Crude UUID check
|
||||
if (dep.length () == 36)
|
||||
{
|
||||
int id = context.tdb2.pending.id (dep);
|
||||
ids.push_back (id);
|
||||
}
|
||||
else
|
||||
A3::extract_id (dep, ids);
|
||||
|
||||
std::vector <int>::iterator id;
|
||||
for (id = ids.begin (); id != ids.end(); id++)
|
||||
if (removal)
|
||||
task.removeDependency (*id);
|
||||
else
|
||||
task.addDependency (*id);
|
||||
}
|
||||
}
|
||||
|
||||
// Priorities are converted to upper case.
|
||||
else if (name == "priority")
|
||||
{
|
||||
task.set (name, upperCase (value));
|
||||
}
|
||||
|
||||
// Dates are special, maybe.
|
||||
else if (column->type () == "date")
|
||||
{
|
||||
// All values must be eval'd first.
|
||||
A3 value_tokens;
|
||||
value_tokens.capture (value);
|
||||
value_tokens = value_tokens.postfix (value_tokens.tokenize (value_tokens));
|
||||
|
||||
E9 e (value_tokens);
|
||||
std::string result = e.evalExpression (task);
|
||||
context.debug (std::string ("Eval '") + value + "' --> '" + result + "'");
|
||||
|
||||
// If the date value is less than 5 years, it is a duration, not a
|
||||
// date, therefore add 'now'.
|
||||
long l = (long) strtod (result.c_str (), NULL);
|
||||
if (labs (l) < 5 * 365 * 86400)
|
||||
{
|
||||
OldDuration dur (value);
|
||||
Date now;
|
||||
now += l;
|
||||
task.set (name, now.toEpochString ());
|
||||
}
|
||||
else
|
||||
{
|
||||
Date d (result, context.config.get ("dateformat"));
|
||||
task.set (name, d.toEpochString ());
|
||||
}
|
||||
}
|
||||
|
||||
// OldDurations too.
|
||||
else if (name == "recur" ||
|
||||
column->type () == "duration")
|
||||
{
|
||||
// All values must be eval'd first, in this case, just to catch errors.
|
||||
A3 value_tokens;
|
||||
value_tokens.capture (value);
|
||||
value_tokens = value_tokens.postfix (value_tokens.tokenize (value_tokens));
|
||||
|
||||
E9 e (value_tokens);
|
||||
std::string result = e.evalExpression (task);
|
||||
context.debug (std::string ("Eval '") + value + "' --> '" + result + "'");
|
||||
|
||||
OldDuration d (value);
|
||||
|
||||
// Deliberately storing the 'raw' value, which is necessary for
|
||||
// durations like 'weekday'..
|
||||
task.set (name, name == "recur" ? value : result);
|
||||
}
|
||||
|
||||
// Need handling for numeric types, used by UDAs.
|
||||
else if (column->type () == "numeric")
|
||||
{
|
||||
A3 value_tokens;
|
||||
value_tokens.capture (value);
|
||||
value_tokens = value_tokens.postfix (value_tokens.tokenize (value_tokens));
|
||||
|
||||
E9 e (value_tokens);
|
||||
std::string result = e.evalExpression (task);
|
||||
context.debug (std::string ("Eval '") + value + "' --> '" + result + "'");
|
||||
|
||||
Nibbler n (result);
|
||||
double d;
|
||||
if (n.getNumber (d) &&
|
||||
n.depleted ())
|
||||
task.set (name, result);
|
||||
else
|
||||
throw format (STRING_UDA_NUMERIC, result);
|
||||
}
|
||||
|
||||
// By default, just add/remove it.
|
||||
else
|
||||
{
|
||||
if (column->validate (value))
|
||||
task.set (name, value);
|
||||
else
|
||||
throw format (STRING_INVALID_MOD, name, value);
|
||||
}
|
||||
|
||||
// Warn about deprecated/obsolete attribute usage.
|
||||
legacyAttributeCheck (name);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw format (STRING_CMD_ADD_BAD_ATTRIBUTE, name);
|
||||
}
|
||||
|
||||
// Tags need special handling because they are essentially a vector stored
|
||||
// in a single string, therefore Task::{add,remove}Tag must be called as
|
||||
// appropriate.
|
||||
else if (arg._category == Arg::cat_tag)
|
||||
{
|
||||
char type;
|
||||
std::string value;
|
||||
A3::extract_tag (arg._raw, type, value);
|
||||
|
||||
if (type == '+')
|
||||
{
|
||||
task.addTag (value);
|
||||
feedback_special_tags (task, value);
|
||||
}
|
||||
else
|
||||
task.removeTag (value);
|
||||
}
|
||||
|
||||
// Substitutions.
|
||||
else if (arg._category == Arg::cat_subst)
|
||||
{
|
||||
std::string from;
|
||||
std::string to;
|
||||
bool global;
|
||||
A3::extract_subst (arg._raw, from, to, global);
|
||||
task.substitute (from, to, global);
|
||||
}
|
||||
|
||||
// Anything else is essentially downgraded to 'word' and considered part of
|
||||
// the description.
|
||||
else
|
||||
{
|
||||
if (description.length ())
|
||||
description += " ";
|
||||
|
||||
description += arg._raw;
|
||||
}
|
||||
}
|
||||
// Utilize Task::modify
|
||||
task.modify (arguments, description);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -742,27 +549,3 @@ bool Command::permission (
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Special processing for modifications.
|
||||
bool Command::next_mod_group (const A3& input, Arg& arg, unsigned int& pos)
|
||||
{
|
||||
if (pos < input.size ())
|
||||
{
|
||||
arg = input[pos++];
|
||||
|
||||
if (arg._raw == "depends")
|
||||
{
|
||||
while (pos < input.size () &&
|
||||
(input[pos]._category == Arg::cat_op ||
|
||||
input[pos]._type == Arg::type_number))
|
||||
{
|
||||
arg._raw += input[pos++]._raw;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -66,8 +66,6 @@ protected:
|
|||
void safety ();
|
||||
bool permission (const Task&, const std::string&, unsigned int);
|
||||
|
||||
bool next_mod_group (const A3&, Arg&, unsigned int&);
|
||||
|
||||
protected:
|
||||
std::string _keyword;
|
||||
std::string _usage;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue