Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60a99725b8 | ||
|
|
635c6432d4 | ||
|
|
eb1304ec41 | ||
|
|
a5b57ec2ac | ||
|
|
783225cd70 | ||
|
|
804b6a8cdb | ||
|
|
a31e9a5a3c | ||
|
|
8553811889 | ||
|
|
68ae9173ae | ||
|
|
72763f2a2b | ||
|
|
89267846ca | ||
|
|
38d82f6564 | ||
|
|
ac431ac5c9 | ||
|
|
fa7ea5cad5 | ||
|
|
17069843d9 | ||
|
|
d6251142a2 | ||
|
|
a3a941fd92 | ||
|
|
b6e9b84c80 | ||
|
|
2791578410 | ||
|
|
d3628c04db | ||
|
|
10450963cb | ||
|
|
fa8c33da45 | ||
|
|
e8942d11ee | ||
|
|
078e612de0 | ||
|
|
70da455f1a | ||
|
|
e5f7e18d56 | ||
|
|
98ebe8b7cc | ||
|
|
6304ca7c1f | ||
|
|
f6ff18e31d | ||
|
|
dbf8def7db | ||
|
|
df8eb7d5ef | ||
|
|
485734e107 | ||
|
|
f4dc5c3674 | ||
|
|
95e420bb15 | ||
|
|
409c6ee9b9 | ||
|
|
fa195a3cb2 | ||
|
|
cda959a658 | ||
|
|
a5d8ef524e | ||
|
|
cb1b1510a9 | ||
|
|
3f2c68377c | ||
|
|
846d9bfd83 | ||
|
|
eac6c3fca9 | ||
|
|
d082a6baad | ||
|
|
251f8e5704 | ||
|
|
0282e2be28 | ||
|
|
8229a96252 | ||
|
|
c34aeba5a4 | ||
|
|
816f0533be |
5
AUTHORS
5
AUTHORS
@@ -20,6 +20,8 @@ The following submitted code, packages or analysis, and deserve special thanks:
|
||||
Steven de Brouwer
|
||||
Pietro Cerutti
|
||||
Alexander Neumann
|
||||
Emil Sköldberg
|
||||
Johannes Schlatow
|
||||
|
||||
Thanks to the following, who submitted detailed bug reports and excellent suggestions:
|
||||
Eugene Kramer
|
||||
@@ -44,3 +46,6 @@ Thanks to the following, who submitted detailed bug reports and excellent sugges
|
||||
Ivo Jimenez
|
||||
Joe Pulliam
|
||||
Juergen Daubert
|
||||
Rich Mintz
|
||||
Seneca Cunningham
|
||||
|
||||
|
||||
32
ChangeLog
32
ChangeLog
@@ -1,7 +1,32 @@
|
||||
|
||||
------ current release ---------------------------
|
||||
|
||||
1.9.0 (2/22/2010)
|
||||
1.9.1 (5/22/2010)
|
||||
+ Summary report bar colors can now be specified with color.summary.bar
|
||||
and color.summary.background configuration variables.
|
||||
+ The 'edit' command now conveniently fills in the current date for new
|
||||
annotations.
|
||||
+ Deleting a task no longer clobbers any recorded end date (thanks to
|
||||
Seneca Cunningham).
|
||||
+ The following holidays are now computed automatically and can be used
|
||||
in the definitions for the calendar holidays:
|
||||
Good Friday (goodfriday), Easter (easter), Easter monday
|
||||
(eastermonday), Ascension (ascension), Pentecost (pentecost)
|
||||
The date is configured with the given keyword.
|
||||
+ The configure script is more portable (thanks to Emil Sköldberg).
|
||||
+ Updated task-faq.5 man page.
|
||||
+ Fixed bug #382 in which the annotate command didn't return an error
|
||||
message when called without an ID.
|
||||
+ Fixed bug #402 which failed compilation on Arch Linux (thanks to
|
||||
Johannes Schlatow).
|
||||
+ Fixed bug #401 that ignored the search.case.sensitive configuration
|
||||
setting when filtering on project names (thanks to John Florian).
|
||||
+ Fixed bug #395 that prevented the upgrade of a pending task to a
|
||||
recurring task (thanks to T. Charles Yun).
|
||||
|
||||
------ old releases ------------------------------
|
||||
|
||||
1.9.0 (2/22/2010) dd758f8b33de110a633e2ff3ebdac73232b8ff44
|
||||
+ Added feature #283 that makes it possible to control the verbosity
|
||||
of the output of annotations.
|
||||
+ Added feature #254 (#295) which gives task a second date format to be
|
||||
@@ -63,8 +88,7 @@
|
||||
+ Added a new 'task-color' man page detailing how to set up and use color in
|
||||
task.
|
||||
+ Added feature #176, which allows for configurable case-sensitivity for
|
||||
keyword
|
||||
searches and substitutions (thanks to John Florian).
|
||||
keyword searches and substitutions (thanks to John Florian).
|
||||
+ Task can now use an alternate tag indicator by setting the tag.indicator
|
||||
configuration variable to something other than the default of +.
|
||||
+ Task can now use an alternate active indicator by setting the
|
||||
@@ -103,8 +127,6 @@
|
||||
+ Fixed bug #372 which incorrectly mapped 16-color backgrounds into the
|
||||
256-color space.
|
||||
|
||||
------ old releases ------------------------------
|
||||
|
||||
1.8.5 (12/05/2009) a6c7236ff34e5eee3ef1693b97cb1367e6e3c607
|
||||
+ Added feature to allow the user to quit when asked to confirm multiple
|
||||
changes. Now task asks "Proceed with change? (Yes/no/all/quit)".
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.61)
|
||||
AC_INIT(task, 1.9.0, support@taskwarrior.org)
|
||||
AC_INIT(task, 1.9.1, support@taskwarrior.org)
|
||||
|
||||
|
||||
# Source type.
|
||||
@@ -80,7 +80,7 @@ AC_ARG_WITH([ncurses-lib],
|
||||
[ncurses_lib=$withval],
|
||||
[ncurses_lib=''])
|
||||
|
||||
if test "x$with_ncurses" == "xyes" ; then
|
||||
if test "x$with_ncurses" = "xyes" ; then
|
||||
AC_DEFINE([HAVE_LIBNCURSES], [1], [Defined if you have libncurses])
|
||||
if test -n "$ncurses_inc"; then
|
||||
CFLAGS="$CFLAGS -I$ncurses_inc"
|
||||
@@ -111,7 +111,7 @@ fi
|
||||
# [readline_lib=$withval],
|
||||
# [readline_lib=''])
|
||||
#
|
||||
#if test "x$with_readline" == "xyes" ; then
|
||||
#if test "x$with_readline" = "xyes" ; then
|
||||
# AC_DEFINE([HAVE_LIBREADLINE], [1], [Defined if you have libreadline])
|
||||
# if test -n "$readline_inc"; then
|
||||
# CFLAGS="$CFLAGS -I$readline_inc"
|
||||
@@ -142,7 +142,7 @@ AC_ARG_WITH([lua-lib],
|
||||
[lua_lib=$withval],
|
||||
[lua_lib=''])
|
||||
|
||||
if test "x$with_lua" == "xyes" ; then
|
||||
if test "x$with_lua" = "xyes" ; then
|
||||
AC_DEFINE([HAVE_LIBLUA], [1], [Defined if you have liblua])
|
||||
if test -n "$lua_inc"; then
|
||||
CFLAGS="$CFLAGS -I$lua_inc"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH task-color 5 2010-02-03 "task 1.9.0" "User Manuals"
|
||||
.TH task-color 5 2010-05-22 "task 1.9.1" "User Manuals"
|
||||
|
||||
.SH NAME
|
||||
task-color \- A color tutorial for the task(1) command line todo manager.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH task-faq 5 2010-02-03 "task 1.9.0" "User Manuals"
|
||||
.TH task-faq 5 2010-05-22 "task 1.9.1" "User Manuals"
|
||||
|
||||
.SH NAME
|
||||
task-faq \- A FAQ for the task(1) command line todo manager.
|
||||
@@ -85,7 +85,7 @@ call the task program. Here is a Bash script that does this:
|
||||
|
||||
#! /bin/bash
|
||||
|
||||
printf "\033]0;task $*\a"
|
||||
printf "\\033]0;task $*\a"
|
||||
/usr/local/bin/task $*
|
||||
|
||||
You just need to run the script, and let the script run task. Here is a Bash
|
||||
@@ -93,7 +93,7 @@ function that does the same thing:
|
||||
|
||||
t ()
|
||||
{
|
||||
printf "\033]0;task $*\a"
|
||||
printf "\\033]0;task $*\a"
|
||||
/usr/local/bin/task $*
|
||||
}
|
||||
|
||||
@@ -139,6 +139,28 @@ therefore keeps task fast. The completed data file is the one that grows
|
||||
unbounded with use, but that one isn't accessed as much, so it doesn't matter as
|
||||
much. So in all, the ID number resequencing is about efficiency.
|
||||
|
||||
.TP
|
||||
.B Q: How do I list tasks that are either priority 'H' or 'M', but not 'L'?
|
||||
Task's filters are all combined with and implicit logical AND operator, so if
|
||||
you were to try this:
|
||||
|
||||
$ task list priority:H priority:M
|
||||
|
||||
There would be no results, because the priority could not simultaneously be 'H'
|
||||
AND 'M'. What is required is some way to use OR instead of an AND operator. The
|
||||
solution is to invert the filter in this way:
|
||||
|
||||
$ task list priority.not:L priority.any:
|
||||
|
||||
This filter states that the priority must not be 'L', AND there must be a
|
||||
priority assigned. This filter then properly lists tasks that are 'H' or 'M',
|
||||
because the two logical restrictions are not mutually exclusive as in the
|
||||
original filter.
|
||||
|
||||
Some of you may be familiar with DeMorgan's laws of formal logic that relate
|
||||
the AND and OR operators in terms of each other via negation, which can be used
|
||||
to construct task filters.
|
||||
|
||||
.SH "CREDITS & COPYRIGHTS"
|
||||
task was written by P. Beckingham <paul@beckingham.net>.
|
||||
.br
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH task-tutorial 5 2010-02-03 "task 1.9.0" "User Manuals"
|
||||
.TH task-tutorial 5 2010-05-22 "task 1.9.1" "User Manuals"
|
||||
|
||||
.SH NAME
|
||||
task-tutorial \- A tutorial for the task(1) command line todo manager.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH task 1 2010-02-03 "task 1.9.0" "User Manuals"
|
||||
.TH task 1 2010-05-22 "task 1.9.1" "User Manuals"
|
||||
|
||||
.SH NAME
|
||||
task \- A command line todo manager.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH taskrc 5 2010-02-03 "task 1.9.0" "User Manuals"
|
||||
.TH taskrc 5 2010-05-22 "task 1.9.1" "User Manuals"
|
||||
|
||||
.SH NAME
|
||||
taskrc \- Configuration file for the task(1) command
|
||||
@@ -100,6 +100,17 @@ $ task config
|
||||
and in addition, will also perform a check of all the values in the file,
|
||||
warning you of anything it finds amiss.
|
||||
|
||||
.SH NESTING CONFIGURATION FILES
|
||||
The .taskrc can include other files containing configuration settings by using the
|
||||
.B include
|
||||
statement:
|
||||
|
||||
.RS
|
||||
include <path/to/the/configuration/file/to/be/included>
|
||||
.RE
|
||||
|
||||
By using include files you can divide your main configuration file into several ones containing just the relevant configuration data like colors, etc.
|
||||
|
||||
.SH CONFIGURATION VARIABLES
|
||||
Valid variable names and their default values are:
|
||||
|
||||
@@ -403,6 +414,19 @@ Dates are to be entered according to the setting in the dateformat.holiday
|
||||
variable.
|
||||
.RE
|
||||
|
||||
.RS
|
||||
The following holidays are computed automatically: Good Friday (goodfriday), Easter (easter), Easter monday (eastermonday), Ascension (ascension), Pentecost (pentecost). The date for these holidays is the given keyword:
|
||||
.RE
|
||||
|
||||
.RS
|
||||
.RS
|
||||
.br
|
||||
holiday.eastersunday.name=Easter
|
||||
.br
|
||||
holiday.eastersunday.date=easter
|
||||
.RE
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B monthsperline=3
|
||||
Determines how many months the "task calendar" command renders across the
|
||||
@@ -506,6 +530,15 @@ Colors any of the messages printed prior to the report output.
|
||||
.B color.footnote=green
|
||||
Colors any of the messages printed last.
|
||||
|
||||
.TP
|
||||
.B color.summary.bar=on green
|
||||
Colors the summary progress bar. Should include both a foreground and a
|
||||
background color.
|
||||
|
||||
.TP
|
||||
.B color.summary.background=on black
|
||||
Colors the summary progress bar. Should include at least a background color.
|
||||
|
||||
.TP
|
||||
.B color.calendar.today=black on cyan
|
||||
Color of today in calendar.
|
||||
|
||||
@@ -20,8 +20,6 @@ holiday.veteransdays.name=Veterans Day
|
||||
holiday.veteransdays.date=20101111
|
||||
holiday.thanksgiving.name=Thanksgiving Day
|
||||
holiday.thanksgiving.date=20101125
|
||||
holiday.christmaseve.name=Christmas Eve
|
||||
holiday.christmaseve.date=20101224
|
||||
holiday.christmasday.name=Christmas Day
|
||||
holiday.christmasday.date=20101225
|
||||
holiday.newyearseve.name=New Years Eve
|
||||
|
||||
@@ -1 +1 @@
|
||||
<pkg-contents spec="1.12"><f n="local" o="root" g="staff" p="16877" pt="/Users/paul/task-1.9.0.git/package-config/osx/local" m="false" t="file"><f n="bin" o="root" g="wheel" p="16877"><f n="task" o="root" g="wheel" p="33261"><mod>mode</mod><mod>owner</mod></f><mod>owner</mod></f><f n="share" o="root" g="wheel" p="16877"><f n="doc" o="root" g="wheel" p="16877"><f n="task" o="root" g="wheel" p="16877"><f n="AUTHORS" o="root" g="wheel" p="33188"><mod>mode</mod><mod>owner</mod></f><f n="ChangeLog" o="root" g="wheel" p="33188"><mod>mode</mod><mod>owner</mod></f><f n="COPYING" o="root" g="wheel" p="33188"><mod>mode</mod><mod>owner</mod></f><f n="NEWS" o="root" g="wheel" p="33188"><mod>mode</mod><mod>owner</mod></f><f n="README" o="root" g="wheel" p="33188"><mod>mode</mod><mod>owner</mod></f><f n="scripts" o="root" g="wheel" p="16877"><f n="bash" o="root" g="wheel" p="16877"><f n="task_completion.sh" o="root" g="wheel" p="33188"><mod>mode</mod><mod>group</mod><mod>owner</mod></f><mod>mode</mod><mod>owner</mod></f><f n="vim" o="root" g="wheel" p="16877"><f n="ftdetect" o="root" g="wheel" p="16877"><f n="task.vim" o="root" g="wheel" p="33188"><mod>mode</mod></f><mod>mode</mod></f><f n="README" o="root" g="wheel" p="33188"><mod>mode</mod></f><f n="syntax" o="root" g="wheel" p="16877"><f n="taskdata.vim" o="root" g="wheel" p="33188"><mod>mode</mod></f><f n="taskedit.vim" o="root" g="wheel" p="33188"><mod>mode</mod></f><f n="taskrc.vim" o="root" g="wheel" p="33188"><mod>mode</mod></f><mod>mode</mod></f><mod>mode</mod></f><f n="zsh" o="root" g="wheel" p="16877"><f n="_task" o="root" g="wheel" p="33188"><mod>mode</mod></f><mod>mode</mod></f><mod>mode</mod><mod>owner</mod></f><mod>mode</mod><mod>owner</mod></f><mod>mode</mod><mod>owner</mod></f><f n="man" o="root" g="wheel" p="16877"><f n="man1" o="root" g="wheel" p="16877"><f n="task.1" o="root" g="wheel" p="33188"><mod>mode</mod></f><mod>mode</mod></f><f n="man5" o="root" g="wheel" p="16877"><f n="task-color.5" o="root" g="wheel" p="33188"><mod>mode</mod></f><f n="task-faq.5" o="root" g="wheel" p="33188"><mod>mode</mod></f><f n="task-tutorial.5" o="root" g="wheel" p="33188"><mod>mode</mod></f><f n="taskrc.5" o="root" g="wheel" p="33188"><mod>mode</mod></f><mod>mode</mod></f><mod>mode</mod></f><mod>mode</mod><mod>owner</mod></f><mod>owner</mod></f></pkg-contents>
|
||||
<pkg-contents spec="1.12"><f n="local" o="root" g="staff" p="16877" pt="/Users/paul/task-1.9.0.git/package-config/osx/local" m="false" t="file"><f n="bin" o="root" g="wheel" p="16877"><f n="task" o="root" g="wheel" p="33261"><mod>mode</mod><mod>owner</mod></f><mod>owner</mod></f><f n="share" o="root" g="wheel" p="16877"><f n="doc" o="root" g="wheel" p="16877"><f n="task" o="root" g="wheel" p="16877"><f n="AUTHORS" o="root" g="wheel" p="33188"><mod>mode</mod><mod>owner</mod></f><f n="ChangeLog" o="root" g="wheel" p="33188"><mod>mode</mod><mod>owner</mod></f><f n="COPYING" o="root" g="wheel" p="33188"><mod>mode</mod><mod>owner</mod></f><f n="NEWS" o="root" g="wheel" p="33188"><mod>mode</mod><mod>owner</mod></f><f n="README" o="root" g="wheel" p="33188"><mod>mode</mod><mod>owner</mod></f><f n="scripts" o="root" g="wheel" p="16877"><f n="bash" o="root" g="wheel" p="16877"><f n="task_completion.sh" o="root" g="wheel" p="33188"><mod>owner</mod><mod>mode</mod><mod>group</mod></f><mod>mode</mod><mod>owner</mod></f><f n="vim" o="root" g="wheel" p="16877"><f n="ftdetect" o="root" g="wheel" p="16877"><f n="task.vim" o="root" g="wheel" p="33188"><mod>mode</mod></f><mod>mode</mod></f><f n="README" o="root" g="wheel" p="33188"><mod>mode</mod></f><f n="syntax" o="root" g="wheel" p="16877"><f n="taskdata.vim" o="root" g="wheel" p="33188"><mod>mode</mod></f><f n="taskedit.vim" o="root" g="wheel" p="33188"><mod>mode</mod></f><f n="taskrc.vim" o="root" g="wheel" p="33188"><mod>mode</mod></f><mod>mode</mod></f><mod>mode</mod></f><f n="zsh" o="root" g="wheel" p="16877"><f n="_task" o="root" g="wheel" p="33188"><mod>mode</mod></f><mod>mode</mod></f><mod>mode</mod><mod>owner</mod></f><mod>mode</mod><mod>owner</mod></f><mod>mode</mod><mod>owner</mod></f><f n="man" o="root" g="wheel" p="16877"><f n="man1" o="root" g="wheel" p="16877"><f n="task.1" o="root" g="wheel" p="33188"><mod>mode</mod></f><mod>mode</mod></f><f n="man5" o="root" g="wheel" p="16877"><f n="task-color.5" o="root" g="wheel" p="33188"><mod>mode</mod></f><f n="task-faq.5" o="root" g="wheel" p="33188"><mod>mode</mod></f><f n="task-tutorial.5" o="root" g="wheel" p="33188"><mod>mode</mod></f><f n="taskrc.5" o="root" g="wheel" p="33188"><mod>mode</mod></f><mod>mode</mod></f><mod>mode</mod></f><mod>mode</mod><mod>owner</mod></f><mod>owner</mod></f></pkg-contents>
|
||||
@@ -1 +1 @@
|
||||
<pkgref spec="1.12" uuid="3BCF9CAB-ED33-4182-AC52-29B9F8FF9B87"><config><identifier>com.beckingham.task190Beta3.local.pkg</identifier><version>1.0</version><description/><post-install type="none"/><requireAuthorization/><installFrom>/Users/paul/task-1.9.0.git/package-config/osx/local</installFrom><installTo mod="true">/usr/local</installTo><flags><followSymbolicLinks/></flags><packageStore type="internal"/><mod>installTo</mod><mod>installTo.path</mod><mod>parent</mod></config><contents><file-list>01local-contents.xml</file-list><filter>/CVS$</filter><filter>/\.svn$</filter><filter>/\.cvsignore$</filter><filter>/\.cvspass$</filter><filter>/\.DS_Store$</filter></contents></pkgref>
|
||||
<pkgref spec="1.12" uuid="3BCF9CAB-ED33-4182-AC52-29B9F8FF9B87"><config><identifier>com.beckingham.task190.local.pkg</identifier><version>2.0</version><description></description><post-install type="none"/><requireAuthorization/><installFrom>/Users/paul/task-1.9.0.git/package-config/osx/local</installFrom><installTo mod="true" relocatable="true">/usr/local</installTo><flags><followSymbolicLinks/></flags><packageStore type="internal"></packageStore><mod>installTo.path</mod><mod>version</mod><mod>parent</mod><mod>installTo</mod><mod>relocatable</mod></config><contents><file-list>01local-contents.xml</file-list><filter>/CVS$</filter><filter>/\.svn$</filter><filter>/\.cvsignore$</filter><filter>/\.cvspass$</filter><filter>/\.DS_Store$</filter></contents></pkgref>
|
||||
@@ -1 +1 @@
|
||||
<pkmkdoc spec="1.12"><properties><title>Task 1.9.0 beta3</title><build>/Users/paul/Desktop/task-1.9.0.beta3-sl.pkg</build><organization>com.beckingham</organization><userSees ui="easy"/><min-target os="3"/><domain anywhere="true" system="true"/></properties><distribution><versions min-spec="1.000000"/><scripts></scripts></distribution><description>Task 1.9.0 beta 3 install for Snow Leopard.</description><contents><choice title="local" id="choice36" starts_selected="true" starts_enabled="true" starts_hidden="false"><pkgref id="com.beckingham.task190Beta3.local.pkg"/></choice></contents><resources bg-scale="proportional" bg-align="center"><locale lang="en"><resource mod="true" type="license">/Users/paul/task-1.9.0.git/package-config/osx/COPYING.txt</resource><resource mod="true" type="welcome">/Users/paul/task-1.9.0.git/package-config/osx/README.txt</resource></locale></resources><requirements><requirement id="tosv" operator="ge" value="'10.6.0'"><message>Task requires Mac OSX 10.6.0 (Snow Leopard) or later.</message></requirement></requirements><flags/><item type="file">01local.xml</item><mod>properties.title</mod><mod>properties.customizeOption</mod><mod>description</mod><mod>properties.anywhereDomain</mod><mod>properties.systemDomain</mod></pkmkdoc>
|
||||
<pkmkdoc spec="1.12"><properties><title>Task 1.9.0</title><build>/Users/paul/Desktop/task-1.9.0-sl.pkg</build><organization>com.beckingham</organization><userSees ui="easy"/><min-target os="3"/><domain anywhere="true" system="true"/></properties><distribution><versions min-spec="1.000000"/><scripts></scripts></distribution><description>Task 1.9.0 install for Snow Leopard.</description><contents><choice title="local" id="choice36" starts_selected="true" starts_enabled="true" starts_hidden="false"><pkgref id="com.beckingham.task190.local.pkg"/></choice></contents><resources bg-scale="proportional" bg-align="center"><locale lang="en"><resource mod="true" type="license">/Users/paul/task-1.9.0.git/package-config/osx/COPYING.txt</resource><resource mod="true" type="welcome">/Users/paul/task-1.9.0.git/package-config/osx/README.txt</resource></locale></resources><requirements><requirement id="tosv" operator="ge" value="'10.6.0'"><message>Task requires Mac OSX 10.6.0 (Snow Leopard) or later.</message></requirement></requirements><flags/><item type="file">01local.xml</item><mod>properties.title</mod><mod>properties.customizeOption</mod><mod>description</mod><mod>properties.anywhereDomain</mod><mod>properties.systemDomain</mod></pkmkdoc>
|
||||
128
src/API.cpp
128
src/API.cpp
@@ -321,49 +321,117 @@ static int api_task_get_status (lua_State* L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_due (lua_State* L)
|
||||
{
|
||||
if (the_task != NULL)
|
||||
{
|
||||
unsigned int value = (unsigned int) the_task->get_ulong ("due");
|
||||
if (value)
|
||||
{
|
||||
lua_pushinteger (L, value);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
lua_pushnil (L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_entry (lua_State* L)
|
||||
{
|
||||
if (the_task != NULL)
|
||||
{
|
||||
unsigned int value = (unsigned int) the_task->get_ulong ("entry");
|
||||
if (value)
|
||||
{
|
||||
lua_pushinteger (L, value);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
lua_pushnil (L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_start (lua_State* L)
|
||||
{
|
||||
if (the_task != NULL)
|
||||
{
|
||||
unsigned int value = (unsigned int) the_task->get_ulong ("start");
|
||||
if (value)
|
||||
{
|
||||
lua_pushinteger (L, value);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
lua_pushnil (L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_end (lua_State* L)
|
||||
{
|
||||
if (the_task != NULL)
|
||||
{
|
||||
unsigned int value = (unsigned int) the_task->get_ulong ("end");
|
||||
if (value)
|
||||
{
|
||||
lua_pushinteger (L, value);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
lua_pushnil (L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_due (id)
|
||||
{
|
||||
return task.due_date
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_entry (id)
|
||||
{
|
||||
return task.entry_date
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_start (id)
|
||||
{
|
||||
return task.start_date
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_end (id)
|
||||
{
|
||||
return task.end_date
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_recur (id)
|
||||
{
|
||||
return task.recur
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_until (id)
|
||||
static int api_task_get_until (lua_State* L)
|
||||
{
|
||||
return task.until_date
|
||||
if (the_task != NULL)
|
||||
{
|
||||
unsigned int value = (unsigned int) the_task->get_ulong ("until");
|
||||
if (value)
|
||||
{
|
||||
lua_pushinteger (L, value);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
lua_pushnil (L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_wait (id)
|
||||
static int api_task_get_wait (lua_State* L)
|
||||
{
|
||||
return task.wait_date
|
||||
if (the_task != NULL)
|
||||
{
|
||||
unsigned int value = (unsigned int) the_task->get_ulong ("wait");
|
||||
if (value)
|
||||
{
|
||||
lua_pushinteger (L, value);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
lua_pushnil (L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-- 'id' is the task id passed to the hook function. Date attributes are
|
||||
-- expected as numeric epoch offsets. Tags and annotations are expected
|
||||
@@ -496,14 +564,16 @@ void API::initialize ()
|
||||
lua_pushcfunction (L, api_task_get_tags); lua_setglobal (L, "task_get_tags");
|
||||
*/
|
||||
lua_pushcfunction (L, api_task_get_status); lua_setglobal (L, "task_get_status");
|
||||
/*
|
||||
lua_pushcfunction (L, api_task_get_due); lua_setglobal (L, "task_get_due");
|
||||
lua_pushcfunction (L, api_task_get_entry); lua_setglobal (L, "task_get_entry");
|
||||
lua_pushcfunction (L, api_task_get_start); lua_setglobal (L, "task_get_start");
|
||||
lua_pushcfunction (L, api_task_get_end); lua_setglobal (L, "task_get_end");
|
||||
/*
|
||||
lua_pushcfunction (L, api_task_get_recur); lua_setglobal (L, "task_get_recur");
|
||||
*/
|
||||
lua_pushcfunction (L, api_task_get_until); lua_setglobal (L, "task_get_until");
|
||||
lua_pushcfunction (L, api_task_get_wait); lua_setglobal (L, "task_get_wait");
|
||||
/*
|
||||
lua_pushcfunction (L, api_task_set_description); lua_setglobal (L, "task_set_description");
|
||||
lua_pushcfunction (L, api_task_set_annotations); lua_setglobal (L, "task_set_annotations");
|
||||
lua_pushcfunction (L, api_task_set_project); lua_setglobal (L, "task_set_project");
|
||||
|
||||
@@ -537,7 +537,7 @@ bool Att::match (const Att& other) const
|
||||
if (other.mValue.length () < mValue.length ())
|
||||
return false;
|
||||
|
||||
if (!compare (mValue, other.mValue.substr (0, mValue.length ())))
|
||||
if (!compare (mValue, other.mValue.substr (0, mValue.length ()), (bool) case_sensitive))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <pwd.h>
|
||||
#include "Directory.h"
|
||||
#include "Date.h"
|
||||
#include "File.h"
|
||||
#include "Config.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "../auto.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// This string is used in two ways:
|
||||
@@ -93,6 +95,8 @@ std::string Config::defaults =
|
||||
"color=on # Enable color\n"
|
||||
"#color.header=bold green # Color of header messages\n"
|
||||
"#color.footnote=bold green # Color of footnote messages\n"
|
||||
"color.summary.bar=on green # Color of summary report progress bar\n"
|
||||
"color.summary.background=on black # Color of summary report background\n"
|
||||
"color.calendar.today=black on cyan # Color of today in calendar\n"
|
||||
"color.calendar.due=black on green # Color of days with due tasks in calendar\n"
|
||||
"color.calendar.due.today=black on magenta # Color of today with due tasks in calendar\n"
|
||||
@@ -395,12 +399,19 @@ void Config::createDefaultRC (const std::string& rc, const std::string& data)
|
||||
std::string::size_type loc = defaults.find ("data.location=~/.task");
|
||||
// loc+0^ +14^ +21^
|
||||
|
||||
std::string contents = defaults.substr (0, loc + 14) +
|
||||
data +
|
||||
defaults.substr (loc + 21, std::string::npos);
|
||||
Date now;
|
||||
std::stringstream contents;
|
||||
contents << "# [Created by "
|
||||
<< PACKAGE_STRING
|
||||
<< " "
|
||||
<< now.toStringWithTime ()
|
||||
<< "]\n"
|
||||
<< defaults.substr (0, loc + 14)
|
||||
<< data
|
||||
<< defaults.substr (loc + 21);
|
||||
|
||||
// Write out the new file.
|
||||
if (! File::write (rc, contents))
|
||||
if (! File::write (rc, contents.str ()))
|
||||
throw std::string ("Could not write to '") + rc + "'";
|
||||
}
|
||||
|
||||
|
||||
224
src/Date.cpp
224
src/Date.cpp
@@ -55,9 +55,27 @@ Date::Date (const int m, const int d, const int y)
|
||||
{
|
||||
// Error if not valid.
|
||||
struct tm t = {0};
|
||||
t.tm_mday = d;
|
||||
t.tm_mon = m - 1;
|
||||
t.tm_year = y - 1900;
|
||||
t.tm_isdst = -1; // Requests that mktime determine summer time effect.
|
||||
t.tm_mday = d;
|
||||
t.tm_mon = m - 1;
|
||||
t.tm_year = y - 1900;
|
||||
|
||||
mT = mktime (&t);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Date::Date (const int m, const int d, const int y,
|
||||
const int hr, const int mi, const int se)
|
||||
{
|
||||
// Error if not valid.
|
||||
struct tm t = {0};
|
||||
t.tm_isdst = -1; // Requests that mktime determine summer time effect.
|
||||
t.tm_mday = d;
|
||||
t.tm_mon = m - 1;
|
||||
t.tm_year = y - 1900;
|
||||
t.tm_hour = hr;
|
||||
t.tm_min = mi;
|
||||
t.tm_sec = se;
|
||||
|
||||
mT = mktime (&t);
|
||||
}
|
||||
@@ -65,9 +83,12 @@ Date::Date (const int m, const int d, const int y)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
|
||||
{
|
||||
int month = 0;
|
||||
int day = 0;
|
||||
int year = 0;
|
||||
int month = 0;
|
||||
int day = 0;
|
||||
int year = 0;
|
||||
int hour = 0;
|
||||
int minute = 0;
|
||||
int second = 0;
|
||||
|
||||
// Perhaps it is an epoch date, in string form?
|
||||
if (isEpoch (mdy))
|
||||
@@ -241,6 +262,64 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
|
||||
i += Date::monthName(month).size();
|
||||
break;
|
||||
|
||||
// Single or double digit.
|
||||
case 'h':
|
||||
if (i >= mdy.length () ||
|
||||
! isdigit (mdy[i]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (h).";
|
||||
}
|
||||
|
||||
if (i + 1 < mdy.length () &&
|
||||
(mdy[i + 0] == '0' || mdy[i + 0] == '1' || mdy[i + 0] == '2') &&
|
||||
isdigit (mdy[i + 1]))
|
||||
{
|
||||
hour = atoi (mdy.substr (i, 2).c_str ());
|
||||
i += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
hour = atoi (mdy.substr (i, 1).c_str ());
|
||||
++i;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
if (i + 1 >= mdy.length () ||
|
||||
! isdigit (mdy[i + 0]) ||
|
||||
! isdigit (mdy[i + 1]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (H).";
|
||||
}
|
||||
|
||||
hour = atoi (mdy.substr (i, 2).c_str ());
|
||||
i += 2;
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
if (i + 1 >= mdy.length () ||
|
||||
! isdigit (mdy[i + 0]) ||
|
||||
! isdigit (mdy[i + 1]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (N).";
|
||||
}
|
||||
|
||||
minute = atoi (mdy.substr (i, 2).c_str ());
|
||||
i += 2;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
if (i + 1 >= mdy.length () ||
|
||||
! isdigit (mdy[i + 0]) ||
|
||||
! isdigit (mdy[i + 1]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (S).";
|
||||
}
|
||||
|
||||
second = atoi (mdy.substr (i, 2).c_str ());
|
||||
i += 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (i >= mdy.length () ||
|
||||
mdy[i] != format[f])
|
||||
@@ -258,11 +337,15 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
|
||||
if (!valid (month, day, year))
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (VALID).";
|
||||
|
||||
// Duplicate Date::Date (const int, const int, const int);
|
||||
// Convert to epoch.
|
||||
struct tm t = {0};
|
||||
t.tm_mday = day;
|
||||
t.tm_mon = month - 1;
|
||||
t.tm_year = year - 1900;
|
||||
t.tm_isdst = -1; // Requests that mktime determine summer time effect.
|
||||
t.tm_mday = day;
|
||||
t.tm_mon = month - 1;
|
||||
t.tm_year = year - 1900;
|
||||
t.tm_hour = hour;
|
||||
t.tm_min = minute;
|
||||
t.tm_sec = second;
|
||||
|
||||
mT = mktime (&t);
|
||||
}
|
||||
@@ -333,6 +416,10 @@ const std::string Date::toString (const std::string& format /*= "m/d/Y" */) cons
|
||||
case 'b': sprintf (buffer, "%.3s", Date::monthName (month ()).c_str ()); break;
|
||||
case 'B': sprintf (buffer, "%.9s", Date::monthName (month ()).c_str ()); break;
|
||||
case 'V': sprintf (buffer, "%02d", Date::weekOfYear (Date::dayOfWeek (context.config.get ("weekstart")))); break;
|
||||
case 'h': sprintf (buffer, "%d", this->hour ()); break;
|
||||
case 'H': sprintf (buffer, "%02d", this->hour ()); break;
|
||||
case 'N': sprintf (buffer, "%02d", this->minute ()); break;
|
||||
case 'S': sprintf (buffer, "%02d", this->second ()); break;
|
||||
default: sprintf (buffer, "%c", c); break;
|
||||
}
|
||||
|
||||
@@ -371,6 +458,22 @@ bool Date::valid (const std::string& input, const std::string& format)
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Date::valid (const int m, const int d, const int y, const int hr,
|
||||
const int mi, const int se)
|
||||
{
|
||||
if (hr < 0 || hr > 23)
|
||||
return false;
|
||||
|
||||
if (mi < 0 || mi > 59)
|
||||
return false;
|
||||
|
||||
if (se < 0 || se > 59)
|
||||
return false;
|
||||
|
||||
return Date::valid (m, d, y);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Date::valid (const int m, const int d, const int y)
|
||||
{
|
||||
@@ -540,6 +643,32 @@ int Date::monthOfYear (const std::string& input)
|
||||
return -1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
time_t Date::easter (int year)
|
||||
{
|
||||
int Y = year;
|
||||
int a = Y % 19;
|
||||
int b = Y / 100;
|
||||
int c = Y % 100;
|
||||
int d = b / 4;
|
||||
int e = b % 4;
|
||||
int f = (b + 8) / 25;
|
||||
int g = (b - f + 1) / 3;
|
||||
int h = (19 * a + b - d - g + 15) % 30;
|
||||
int i = c / 4;
|
||||
int k = c % 4;
|
||||
int L = (32 + 2 * e + 2 * i - h - k) % 7;
|
||||
int m = (a + 11 * h + 22 * L) / 451;
|
||||
int month = (h + L - 7 * m + 114) / 31;
|
||||
int day = ((h + L - 7 * m + 114) % 31) + 1;
|
||||
struct tm t = {0};
|
||||
t.tm_isdst = -1; // Requests that mktime determine summer time effect.
|
||||
t.tm_mday = day;
|
||||
t.tm_mon = month - 1;
|
||||
t.tm_year = year - 1900;
|
||||
return mktime (&t);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Date::month () const
|
||||
{
|
||||
@@ -618,6 +747,18 @@ bool Date::operator>= (const Date& rhs)
|
||||
return mT >= rhs.mT;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Date::sameHour (const Date& rhs)
|
||||
{
|
||||
if (this->year () == rhs.year () &&
|
||||
this->month () == rhs.month () &&
|
||||
this->day () == rhs.day () &&
|
||||
this->hour () == rhs.hour ())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Date::sameDay (const Date& rhs)
|
||||
{
|
||||
@@ -651,7 +792,7 @@ bool Date::sameYear (const Date& rhs)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Date Date::operator+ (const int delta)
|
||||
{
|
||||
return Date::Date (mT + delta);
|
||||
return Date (mT + delta);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -721,6 +862,13 @@ bool Date::isRelativeDate (const std::string& input)
|
||||
supported.push_back ("eow");
|
||||
supported.push_back ("eom");
|
||||
supported.push_back ("eoy");
|
||||
supported.push_back ("goodfriday");
|
||||
supported.push_back ("easter");
|
||||
supported.push_back ("eastermonday");
|
||||
supported.push_back ("ascension");
|
||||
supported.push_back ("pentecost");
|
||||
supported.push_back ("midsommar");
|
||||
supported.push_back ("midsommarafton");
|
||||
|
||||
std::vector <std::string> matches;
|
||||
if (autoComplete (in, supported, matches) == 1)
|
||||
@@ -785,6 +933,60 @@ bool Date::isRelativeDate (const std::string& input)
|
||||
mT = then.mT;
|
||||
return true;
|
||||
}
|
||||
else if (found == "goodfriday")
|
||||
{
|
||||
Date then (Date::easter(today.year()));
|
||||
mT = then.mT - 86400*2;
|
||||
return true;
|
||||
}
|
||||
else if (found == "easter")
|
||||
{
|
||||
Date then (Date::easter(today.year()));
|
||||
mT = then.mT;
|
||||
return true;
|
||||
}
|
||||
else if (found == "eastermonday")
|
||||
{
|
||||
Date then (Date::easter(today.year()));
|
||||
mT = then.mT + 86400;
|
||||
return true;
|
||||
}
|
||||
else if (found == "ascension")
|
||||
{
|
||||
Date then (Date::easter(today.year()));
|
||||
mT = then.mT + 86400*39;
|
||||
return true;
|
||||
}
|
||||
else if (found == "pentecost")
|
||||
{
|
||||
Date then (Date::easter(today.year()));
|
||||
mT = then.mT + 86400*49;
|
||||
return true;
|
||||
}
|
||||
else if (found == "midsommar")
|
||||
{
|
||||
for (int midsommar = 20; midsommar <= 26; midsommar++)
|
||||
{
|
||||
Date then (6, midsommar, today.year ());
|
||||
if (6 == then.dayOfWeek ())
|
||||
{
|
||||
mT = then.mT;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (found == "midsommarafton")
|
||||
{
|
||||
for (int midsommar = 19; midsommar <= 25; midsommar++)
|
||||
{
|
||||
Date then (6, midsommar, today.year ());
|
||||
if (5 == then.dayOfWeek ())
|
||||
{
|
||||
mT = then.mT;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Support "21st" to indicate the next date that is the 21st day.
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
class Date;
|
||||
|
||||
class Date
|
||||
@@ -38,6 +39,7 @@ public:
|
||||
Date ();
|
||||
Date (time_t);
|
||||
Date (const int, const int, const int);
|
||||
Date (const int, const int, const int, const int, const int, const int);
|
||||
Date (const std::string&, const std::string& format = "m/d/Y");
|
||||
Date (const Date&);
|
||||
virtual ~Date ();
|
||||
@@ -49,8 +51,10 @@ public:
|
||||
const std::string toString (const std::string& format = "m/d/Y") const;
|
||||
const std::string toStringWithTime (const std::string& format = "m/d/Y") const;
|
||||
static bool valid (const std::string&, const std::string& format = "m/d/Y");
|
||||
static bool valid (const int, const int, const int, const int, const int, const int);
|
||||
static bool valid (const int, const int, const int);
|
||||
|
||||
static time_t easter (int year);
|
||||
static bool leapYear (int);
|
||||
static int daysInMonth (int, int);
|
||||
static std::string monthName (int);
|
||||
@@ -75,6 +79,7 @@ public:
|
||||
bool operator> (const Date&);
|
||||
bool operator<= (const Date&);
|
||||
bool operator>= (const Date&);
|
||||
bool sameHour (const Date&);
|
||||
bool sameDay (const Date&);
|
||||
bool sameMonth (const Date&);
|
||||
bool sameYear (const Date&);
|
||||
|
||||
@@ -372,7 +372,8 @@ bool Hooks::validFieldEvent (const std::string& event)
|
||||
event == "format-tag_indicator" ||
|
||||
event == "format-description_only" ||
|
||||
event == "format-description" ||
|
||||
event == "format-wait")
|
||||
event == "format-wait" ||
|
||||
event == "format-prompt")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -157,6 +157,16 @@ int Record::get_int (const std::string& name) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
unsigned long Record::get_ulong (const std::string& name) const
|
||||
{
|
||||
Record::const_iterator i = this->find (name);
|
||||
if (i != this->end ())
|
||||
return strtoul (i->second.value ().c_str (), NULL, 10);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Record::set (const std::string& name, const std::string& value)
|
||||
{
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
std::vector <Att> all ();
|
||||
const std::string get (const std::string&) const;
|
||||
int get_int (const std::string&) const;
|
||||
unsigned long get_ulong (const std::string&) const;
|
||||
void set (const std::string&, const std::string&);
|
||||
void set (const std::string&, int);
|
||||
void remove (const std::string&);
|
||||
|
||||
128
src/command.cpp
128
src/command.cpp
@@ -664,41 +664,6 @@ int handleConfig (std::string &outs)
|
||||
std::vector <std::string> all;
|
||||
context.config.all (all);
|
||||
|
||||
// Create a table for output.
|
||||
Table table;
|
||||
table.setTableWidth (width);
|
||||
table.setDateFormat (context.config.get ("dateformat"));
|
||||
table.addColumn ("Config variable");
|
||||
table.addColumn ("Value");
|
||||
|
||||
if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor"))
|
||||
{
|
||||
table.setColumnUnderline (0);
|
||||
table.setColumnUnderline (1);
|
||||
}
|
||||
else
|
||||
table.setTableDashedUnderline ();
|
||||
|
||||
table.setColumnWidth (0, Table::minimum);
|
||||
table.setColumnWidth (1, Table::flexible);
|
||||
table.setColumnJustification (0, Table::left);
|
||||
table.setColumnJustification (1, Table::left);
|
||||
table.sortOn (0, Table::ascendingCharacter);
|
||||
|
||||
foreach (i, all)
|
||||
{
|
||||
std::string value = context.config.get (*i);
|
||||
int row = table.addRow ();
|
||||
table.addCell (row, 0, *i);
|
||||
table.addCell (row, 1, value);
|
||||
}
|
||||
|
||||
Color bold ("bold");
|
||||
|
||||
out << std::endl
|
||||
<< table.render ()
|
||||
<< std::endl;
|
||||
|
||||
// Complain about configuration variables that are not recognized.
|
||||
// These are the regular configuration variables.
|
||||
// Note that there is a leading and trailing space, to make searching easier.
|
||||
@@ -753,14 +718,59 @@ int handleConfig (std::string &outs)
|
||||
}
|
||||
}
|
||||
|
||||
// Create a table for output.
|
||||
Table table;
|
||||
table.setTableWidth (width);
|
||||
table.setDateFormat (context.config.get ("dateformat"));
|
||||
table.addColumn ("Config variable");
|
||||
table.addColumn ("Value");
|
||||
|
||||
if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor"))
|
||||
{
|
||||
table.setColumnUnderline (0);
|
||||
table.setColumnUnderline (1);
|
||||
}
|
||||
else
|
||||
table.setTableDashedUnderline ();
|
||||
|
||||
table.setColumnWidth (0, Table::minimum);
|
||||
table.setColumnWidth (1, Table::flexible);
|
||||
table.setColumnJustification (0, Table::left);
|
||||
table.setColumnJustification (1, Table::left);
|
||||
table.sortOn (0, Table::ascendingCharacter);
|
||||
|
||||
Color error ("bold white on red");
|
||||
foreach (i, all)
|
||||
{
|
||||
std::string value = context.config.get (*i);
|
||||
int row = table.addRow ();
|
||||
table.addCell (row, 0, *i);
|
||||
table.addCell (row, 1, value);
|
||||
|
||||
if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor"))
|
||||
if (std::find (unrecognized.begin (), unrecognized.end (), *i) != unrecognized.end ())
|
||||
table.setRowColor (row, error);
|
||||
}
|
||||
|
||||
Color bold ("bold");
|
||||
|
||||
out << std::endl
|
||||
<< table.render ()
|
||||
<< std::endl;
|
||||
|
||||
// Display the unrecognized variables.
|
||||
if (unrecognized.size ())
|
||||
{
|
||||
out << "Your .taskrc file contains these unrecognized variables:"
|
||||
<< std::endl;
|
||||
<< std::endl;
|
||||
|
||||
foreach (i, unrecognized)
|
||||
out << " " << *i << std::endl;
|
||||
|
||||
if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor"))
|
||||
out << std::endl
|
||||
<< " These are highlighted in " << error.colorize ("color") << " above.";
|
||||
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
@@ -933,7 +943,12 @@ int handleDelete (std::string &outs)
|
||||
sibling->get ("uuid") == parent)
|
||||
{
|
||||
sibling->setStatus (Task::deleted);
|
||||
sibling->set ("end", endTime);
|
||||
|
||||
// Don't want a 'delete' to clobber the end date that may have
|
||||
// been written by a 'done' command.
|
||||
if (! sibling->has ("end"))
|
||||
sibling->set ("end", endTime);
|
||||
|
||||
context.tdb.update (*sibling);
|
||||
|
||||
if (context.config.getBoolean ("echo.command"))
|
||||
@@ -952,7 +967,11 @@ int handleDelete (std::string &outs)
|
||||
task->setStatus (Task::deleted);
|
||||
updateRecurrenceMask (all, *task);
|
||||
|
||||
task->set ("end", endTime);
|
||||
// Don't want a 'delete' to clobber the end date that may have
|
||||
// been written by a 'done' command.
|
||||
if (! task->has ("end"))
|
||||
task->set ("end", endTime);
|
||||
|
||||
context.tdb.update (*task);
|
||||
|
||||
out << "Deleting recurring task "
|
||||
@@ -966,7 +985,12 @@ int handleDelete (std::string &outs)
|
||||
else
|
||||
{
|
||||
task->setStatus (Task::deleted);
|
||||
task->set ("end", endTime);
|
||||
|
||||
// Don't want a 'delete' to clobber the end date that may have
|
||||
// been written by a 'done' command.
|
||||
if (! task->has ("end"))
|
||||
task->set ("end", endTime);
|
||||
|
||||
context.tdb.update (*task);
|
||||
|
||||
if (context.config.getBoolean ("echo.command"))
|
||||
@@ -1335,6 +1359,21 @@ int handleModify (std::string &outs)
|
||||
// A non-zero value forces a file write.
|
||||
int changes = 0;
|
||||
|
||||
// If a task is being made recurring, there are other cascading
|
||||
// changes.
|
||||
if (!task->has ("recur") &&
|
||||
context.task.has ("recur"))
|
||||
{
|
||||
other->setStatus (Task::recurring);
|
||||
other->set ("mask", "");
|
||||
++changes;
|
||||
|
||||
std::cout << "Task "
|
||||
<< other->id
|
||||
<< " is now a recurring task."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
// Apply other deltas.
|
||||
if (deltaDescription (*other))
|
||||
{
|
||||
@@ -1636,7 +1675,13 @@ void handleShell ()
|
||||
|
||||
do
|
||||
{
|
||||
std::cout << context.config.get ("shell.prompt") << " ";
|
||||
std::string prompt = context.config.get ("shell.prompt");
|
||||
if (context.hooks.trigger ("pre-shell-prompt"))
|
||||
{
|
||||
context.hooks.trigger ("format-prompt", "prompt", prompt);
|
||||
std::cout << prompt << " ";
|
||||
}
|
||||
context.hooks.trigger ("post-shell-prompt");
|
||||
|
||||
command = "";
|
||||
std::getline (std::cin, command);
|
||||
@@ -1877,6 +1922,9 @@ int handleAnnotate (std::string &outs)
|
||||
if (!context.task.has ("description"))
|
||||
throw std::string ("Cannot apply a blank annotation.");
|
||||
|
||||
if (context.sequence.size () == 0)
|
||||
throw std::string ("ID needed to apply an annotation.");
|
||||
|
||||
std::stringstream out;
|
||||
|
||||
std::vector <Task> tasks;
|
||||
|
||||
@@ -287,6 +287,7 @@ int runCustomReport (
|
||||
{
|
||||
Date dt (::atoi (entered.c_str ()));
|
||||
entered = dt.toString (context.config.get ("dateformat"));
|
||||
context.hooks.trigger ("format-entry", "entry", entered);
|
||||
table.addCell (row, columnCount, entered);
|
||||
}
|
||||
}
|
||||
@@ -306,6 +307,7 @@ int runCustomReport (
|
||||
{
|
||||
Date dt (::atoi (entered.c_str ()));
|
||||
entered = dt.toStringWithTime (context.config.get ("dateformat"));
|
||||
context.hooks.trigger ("format-entry_time", "entry_time", entered);
|
||||
table.addCell (row, columnCount, entered);
|
||||
}
|
||||
}
|
||||
@@ -325,6 +327,7 @@ int runCustomReport (
|
||||
{
|
||||
Date dt (::atoi (started.c_str ()));
|
||||
started = dt.toString (context.config.get ("dateformat"));
|
||||
context.hooks.trigger ("format-start", "start", started);
|
||||
table.addCell (row, columnCount, started);
|
||||
}
|
||||
}
|
||||
@@ -344,6 +347,7 @@ int runCustomReport (
|
||||
{
|
||||
Date dt (::atoi (started.c_str ()));
|
||||
started = dt.toStringWithTime (context.config.get ("dateformat"));
|
||||
context.hooks.trigger ("format-start_time", "start_time", started);
|
||||
table.addCell (row, columnCount, started);
|
||||
}
|
||||
}
|
||||
@@ -355,15 +359,16 @@ int runCustomReport (
|
||||
table.setColumnWidth (columnCount, Table::minimum);
|
||||
table.setColumnJustification (columnCount, Table::right);
|
||||
|
||||
std::string started;
|
||||
std::string ended;
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
{
|
||||
started = tasks[row].get ("end");
|
||||
if (started.length ())
|
||||
ended = tasks[row].get ("end");
|
||||
if (ended.length ())
|
||||
{
|
||||
Date dt (::atoi (started.c_str ()));
|
||||
started = dt.toString (context.config.get ("dateformat"));
|
||||
table.addCell (row, columnCount, started);
|
||||
Date dt (::atoi (ended.c_str ()));
|
||||
ended = dt.toString (context.config.get ("dateformat"));
|
||||
context.hooks.trigger ("format-end", "end", ended);
|
||||
table.addCell (row, columnCount, ended);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -376,15 +381,16 @@ int runCustomReport (
|
||||
|
||||
std::string format = context.config.get ("dateformat");
|
||||
|
||||
std::string started;
|
||||
std::string ended;
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
{
|
||||
started = tasks[row].get ("end");
|
||||
if (started.length ())
|
||||
ended = tasks[row].get ("end");
|
||||
if (ended.length ())
|
||||
{
|
||||
Date dt (::atoi (started.c_str ()));
|
||||
started = dt.toStringWithTime (format);
|
||||
table.addCell (row, columnCount, started);
|
||||
Date dt (::atoi (ended.c_str ()));
|
||||
ended = dt.toStringWithTime (format);
|
||||
context.hooks.trigger ("format-end_time", "end_time", ended);
|
||||
table.addCell (row, columnCount, ended);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,7 +410,11 @@ int runCustomReport (
|
||||
int row = 0;
|
||||
std::string due;
|
||||
foreach (task, tasks)
|
||||
table.addCell (row++, columnCount, getDueDate (*task, format));
|
||||
{
|
||||
std::string value = getDueDate (*task, format);
|
||||
context.hooks.trigger ("format-due", "due", value);
|
||||
table.addCell (row++, columnCount, value);
|
||||
}
|
||||
|
||||
dueColumn = columnCount;
|
||||
}
|
||||
@@ -427,7 +437,7 @@ int runCustomReport (
|
||||
time_t cntdwn = (time_t) (now - dt);
|
||||
countdown = formatSeconds ( cntdwn < 0 ? cntdwn * -1 : cntdwn );
|
||||
if ( cntdwn < 0 )
|
||||
countdown = std::string("- ") + countdown;
|
||||
countdown = std::string("-") + countdown;
|
||||
context.hooks.trigger ("format-countdown", "countdown", countdown);
|
||||
table.addCell (row, columnCount, countdown);
|
||||
}
|
||||
@@ -452,7 +462,7 @@ int runCustomReport (
|
||||
time_t cntdwn = (time_t) (now - dt);
|
||||
countdown = formatSecondsCompact ( cntdwn < 0 ? cntdwn * -1 : cntdwn );
|
||||
if ( cntdwn < 0 )
|
||||
countdown = std::string("- ") + countdown;
|
||||
countdown = std::string("-") + countdown;
|
||||
context.hooks.trigger ("format-countdown_compact", "countdown_compact", countdown);
|
||||
table.addCell (row, columnCount, countdown);
|
||||
}
|
||||
@@ -574,7 +584,10 @@ int runCustomReport (
|
||||
{
|
||||
std::string recur = tasks[row].get ("recur");
|
||||
if (recur != "")
|
||||
{
|
||||
context.hooks.trigger ("format-recur", "recur", recur);
|
||||
table.addCell (row, columnCount, recur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -615,6 +628,7 @@ int runCustomReport (
|
||||
{
|
||||
Date dt (::atoi (wait.c_str ()));
|
||||
wait = dt.toString (context.config.get ("dateformat"));
|
||||
context.hooks.trigger ("format-wait", "wait", wait);
|
||||
table.addCell (row++, columnCount, wait);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,9 +168,11 @@ static std::string formatTask (Task task)
|
||||
<< " " << anno->value () << std::endl;
|
||||
}
|
||||
|
||||
before << " Annotation: " << std::endl
|
||||
<< " Annotation: " << std::endl
|
||||
Date now;
|
||||
before << " Annotation: " << now.toString (context.config.get ("dateformat")) << " " << std::endl
|
||||
<< " Annotation: " << now.toString (context.config.get ("dateformat")) << " " << std::endl
|
||||
<< "# End" << std::endl;
|
||||
|
||||
return before.str ();
|
||||
}
|
||||
|
||||
|
||||
@@ -399,7 +399,9 @@ int handleInfo (std::string &outs)
|
||||
{
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "Recurrence");
|
||||
table.addCell (row, 1, task->get ("recur"));
|
||||
value = task->get ("recur");
|
||||
context.hooks.trigger ("format-recur", "recur", value);
|
||||
table.addCell (row, 1, value);
|
||||
}
|
||||
|
||||
// until
|
||||
@@ -445,13 +447,13 @@ int handleInfo (std::string &outs)
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "Due");
|
||||
|
||||
Date dt (atoi (task->get ("due").c_str ()));
|
||||
std::string format = context.config.get ("reportdateformat");
|
||||
if (format == "")
|
||||
format = context.config.get ("dateformat");
|
||||
|
||||
std::string due = getDueDate (*task, format);
|
||||
table.addCell (row, 1, due);
|
||||
value = getDueDate (*task, format);
|
||||
context.hooks.trigger ("format-due", "due", value);
|
||||
table.addCell (row, 1, value);
|
||||
}
|
||||
|
||||
// wait
|
||||
@@ -460,7 +462,9 @@ int handleInfo (std::string &outs)
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "Waiting until");
|
||||
Date dt (atoi (task->get ("wait").c_str ()));
|
||||
table.addCell (row, 1, dt.toString (context.config.get ("dateformat")));
|
||||
value = dt.toString (context.config.get ("dateformat"));
|
||||
context.hooks.trigger ("format-wait", "wait", value);
|
||||
table.addCell (row, 1, value);
|
||||
}
|
||||
|
||||
// start
|
||||
@@ -469,7 +473,10 @@ int handleInfo (std::string &outs)
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "Start");
|
||||
Date dt (atoi (task->get ("start").c_str ()));
|
||||
table.addCell (row, 1, dt.toString (context.config.get ("dateformat")));
|
||||
|
||||
value = dt.toString (context.config.get ("dateformat"));
|
||||
context.hooks.trigger ("format-due", "due", value);
|
||||
table.addCell (row, 1, value);
|
||||
}
|
||||
|
||||
// end
|
||||
@@ -478,7 +485,9 @@ int handleInfo (std::string &outs)
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "End");
|
||||
Date dt (atoi (task->get ("end").c_str ()));
|
||||
table.addCell (row, 1, dt.toString (context.config.get ("dateformat")));
|
||||
value = dt.toString (context.config.get ("dateformat"));
|
||||
context.hooks.trigger ("format-end", "end", value);
|
||||
table.addCell (row, 1, value);
|
||||
}
|
||||
|
||||
// tags ...
|
||||
@@ -515,6 +524,7 @@ int handleInfo (std::string &outs)
|
||||
age = formatSeconds ((time_t) (now - dt));
|
||||
}
|
||||
|
||||
context.hooks.trigger ("format-entry", "entry", entry);
|
||||
table.addCell (row, 1, entry + " (" + age + ")");
|
||||
|
||||
// fg
|
||||
@@ -645,6 +655,9 @@ int handleReportSummary (std::string &outs)
|
||||
table.sortOn (0, Table::ascendingCharacter);
|
||||
table.setDateFormat (context.config.get ("dateformat"));
|
||||
|
||||
Color bar_color (context.config.get ("color.summary.bar"));
|
||||
Color bg_color (context.config.get ("color.summary.background"));
|
||||
|
||||
int barWidth = 30;
|
||||
foreach (i, allProjects)
|
||||
{
|
||||
@@ -665,17 +678,19 @@ int handleReportSummary (std::string &outs)
|
||||
int completedBar = (c * barWidth) / (c + p);
|
||||
|
||||
std::string bar;
|
||||
std::string subbar;
|
||||
if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor"))
|
||||
{
|
||||
bar = "\033[42m";
|
||||
for (int b = 0; b < completedBar; ++b)
|
||||
bar += " ";
|
||||
subbar += " ";
|
||||
|
||||
bar += bar_color.colorize (subbar);
|
||||
subbar = "";
|
||||
|
||||
bar += "\033[40m";
|
||||
for (int b = 0; b < barWidth - completedBar; ++b)
|
||||
bar += " ";
|
||||
subbar += " ";
|
||||
|
||||
bar += "\033[0m";
|
||||
bar += bg_color.colorize (subbar);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
1
src/tests/.gitignore
vendored
1
src/tests/.gitignore
vendored
@@ -20,4 +20,5 @@ list.t
|
||||
path.t
|
||||
file.t
|
||||
directory.t
|
||||
grid.t
|
||||
*.log
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
PROJECT = t.t tdb.t date.t duration.t t.benchmark.t text.t autocomplete.t \
|
||||
config.t seq.t att.t stringtable.t record.t nibbler.t subst.t filt.t \
|
||||
cmd.t util.t color.t list.t path.t file.t directory.t
|
||||
cmd.t util.t color.t list.t path.t file.t directory.t grid.t
|
||||
CFLAGS = -I. -I.. -I../.. -Wall -pedantic -ggdb3 -fno-rtti
|
||||
LFLAGS = -L/usr/local/lib -lncurses
|
||||
LFLAGS = -L/usr/local/lib -lncurses -llua
|
||||
OBJECTS = ../t-TDB.o ../t-Task.o ../t-text.o ../t-Date.o ../t-Table.o \
|
||||
../t-Duration.o ../t-util.o ../t-Config.o ../t-Sequence.o ../t-Att.o \
|
||||
../t-Cmd.o ../t-Record.o ../t-StringTable.o ../t-Subst.o \
|
||||
@@ -92,3 +92,6 @@ file.t: file.t.o $(OBJECTS) test.o
|
||||
directory.t: directory.t.o $(OBJECTS) test.o
|
||||
g++ directory.t.o $(OBJECTS) test.o $(LFLAGS) -o directory.t
|
||||
|
||||
grid.t: grid.t.o $(OBJECTS) test.o
|
||||
g++ grid.t.o $(OBJECTS) test.o $(LFLAGS) -o grid.t
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 5;
|
||||
use Test::More tests => 6;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'bug_annotate.rc')
|
||||
@@ -43,6 +43,10 @@ qx{../task rc:bug_annotate.rc add foo};
|
||||
my $output = qx{../task rc:bug_annotate.rc 1 annotate};
|
||||
like ($output, qr/Cannot apply a blank annotation./, 'failed on blank annotation');
|
||||
|
||||
# Attempt an annotation without ID
|
||||
$output = qx{../task rc:bug_annotate.rc annotate bar};
|
||||
like ($output, qr/ID needed to apply an annotation./, 'failed on annotation without ID');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
@@ -57,16 +57,16 @@ if (open my $fh, '>', 'annual.rc')
|
||||
|
||||
qx{../task rc:annual.rc add foo due:1/1/2000 recur:annual until:1/1/2009};
|
||||
my $output = qx{../task rc:annual.rc list};
|
||||
like ($output, qr/2\s+1\/1\/2000\s+-\s+foo/, 'synthetic 1 no creep');
|
||||
like ($output, qr/3\s+1\/1\/2001\s+-\s+foo/, 'synthetic 2 no creep');
|
||||
like ($output, qr/4\s+1\/1\/2002\s+-\s+foo/, 'synthetic 3 no creep');
|
||||
like ($output, qr/5\s+1\/1\/2003\s+-\s+foo/, 'synthetic 4 no creep');
|
||||
like ($output, qr/6\s+1\/1\/2004\s+-\s+foo/, 'synthetic 5 no creep');
|
||||
like ($output, qr/7\s+1\/1\/2005\s+-\s+foo/, 'synthetic 6 no creep');
|
||||
like ($output, qr/8\s+1\/1\/2006\s+-\s+foo/, 'synthetic 7 no creep');
|
||||
like ($output, qr/9\s+1\/1\/2007\s+-\s+foo/, 'synthetic 8 no creep');
|
||||
like ($output, qr/10\s+1\/1\/2008\s+-\s+foo/, 'synthetic 9 no creep');
|
||||
like ($output, qr/11\s+1\/1\/2009\s+-\s+foo/, 'synthetic 10 no creep');
|
||||
like ($output, qr/2\s+1\/1\/2000\s+(?:-|\d+\ssecs?)\s+foo/, 'synthetic 1 no creep');
|
||||
like ($output, qr/3\s+1\/1\/2001\s+(?:-|\d+\ssecs?)\s+foo/, 'synthetic 2 no creep');
|
||||
like ($output, qr/4\s+1\/1\/2002\s+(?:-|\d+\ssecs?)\s+foo/, 'synthetic 3 no creep');
|
||||
like ($output, qr/5\s+1\/1\/2003\s+(?:-|\d+\ssecs?)\s+foo/, 'synthetic 4 no creep');
|
||||
like ($output, qr/6\s+1\/1\/2004\s+(?:-|\d+\ssecs?)\s+foo/, 'synthetic 5 no creep');
|
||||
like ($output, qr/7\s+1\/1\/2005\s+(?:-|\d+\ssecs?)\s+foo/, 'synthetic 6 no creep');
|
||||
like ($output, qr/8\s+1\/1\/2006\s+(?:-|\d+\ssecs?)\s+foo/, 'synthetic 7 no creep');
|
||||
like ($output, qr/9\s+1\/1\/2007\s+(?:-|\d+\ssecs?)\s+foo/, 'synthetic 8 no creep');
|
||||
like ($output, qr/10\s+1\/1\/2008\s+(?:-|\d+\ssecs?)\s+foo/, 'synthetic 9 no creep');
|
||||
like ($output, qr/11\s+1\/1\/2009\s+(?:-|\d+\ssecs?)\s+foo/, 'synthetic 10 no creep');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
|
||||
@@ -67,7 +67,7 @@ else
|
||||
{
|
||||
like ($output, qr/\[30;46m$day/, 'Current day is highlighted');
|
||||
}
|
||||
like ($output, qr/$month\w+?\s+?$year/, 'Current month and year are displayed');
|
||||
like ($output, qr/$month\S*?\s+?$year/, 'Current month and year are displayed');
|
||||
$output = qx{../task rc:cal.rc add zero};
|
||||
unlike ($output, qr/\[41m\d+/, 'No overdue tasks are present');
|
||||
unlike ($output, qr/\[43m\d+/, 'No due tasks are present');
|
||||
@@ -76,17 +76,17 @@ like ($output, qr/Su Mo Tu/, 'Week starts on Sunday');
|
||||
$output = qx{../task rc:cal.rc rc.weekstart:Monday cal};
|
||||
like ($output, qr/Fr Sa Su/, 'Week starts on Monday');
|
||||
$output = qx{../task rc:cal.rc cal y};
|
||||
like ($output, qr/$month\w+?\s+?$year/, 'Current month and year are displayed');
|
||||
like ($output, qr/$month\S*?\s+?$year/, 'Current month and year are displayed');
|
||||
if ( $month eq "Jan")
|
||||
{
|
||||
$nextyear = $nextyear - 1;
|
||||
}
|
||||
like ($output, qr/$prevmonth\w+?\s+?$nextyear/, 'Month and year one year ahead are displayed');
|
||||
like ($output, qr/$prevmonth\S*?\s+?$nextyear/, 'Month and year one year ahead are displayed');
|
||||
if ( $month eq "Jan")
|
||||
{
|
||||
$nextyear = $nextyear + 1;
|
||||
}
|
||||
unlike ($output, qr/$month\w+?\s+?$nextyear/, 'Current month and year ahead are not displayed');
|
||||
unlike ($output, qr/$month\S*?\s+?$nextyear/, 'Current month and year ahead are not displayed');
|
||||
|
||||
# task cal due and task cal due y
|
||||
qx{../task rc:cal.rc add due:20190515 one};
|
||||
@@ -210,7 +210,7 @@ my $duedate = $year.$mon.$day;
|
||||
|
||||
qx{../task rc:details.rc add due:$duedate rc.monthsperline:1 nine};
|
||||
$output = qx{../task rc:details.rc cal};
|
||||
like ($output, qr/$month\w+?\s+?$year/, 'Current month and year are displayed');
|
||||
like ($output, qr/$month\S*?\s+?$year/, 'Current month and year are displayed');
|
||||
like ($output, qr/$duedate/, 'Due date on current day is displayed');
|
||||
like ($output, qr/1 task/, '1 due task is displayed');
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ Context context;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (111);
|
||||
UnitTest t (143);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -78,6 +78,12 @@ int main (int argc, char** argv)
|
||||
t.ok (Date::valid ("2/29/2008"), "valid: 2/29/2008");
|
||||
t.notok (Date::valid ("2/29/2007"), "invalid: 2/29/2007");
|
||||
|
||||
// Time validity.
|
||||
t.ok (Date::valid (2, 28, 2010, 0, 0, 0), "valid 2/28/2010 0:00:00");
|
||||
t.ok (Date::valid (2, 28, 2010, 23, 59, 59), "valid 2/28/2010 23:59:59");
|
||||
t.notok (Date::valid (2, 28, 2010, 24, 59, 59), "valid 2/28/2010 24:59:59");
|
||||
t.notok (Date::valid (2, 28, 2010, -1, 0, 0), "valid 2/28/2010 -1:00:00");
|
||||
|
||||
// Leap year.
|
||||
t.ok (Date::leapYear (2008), "2008 is a leap year");
|
||||
t.notok (Date::leapYear (2007), "2007 is not a leap year");
|
||||
@@ -195,6 +201,48 @@ int main (int argc, char** argv)
|
||||
t.is (fromString10.day (), 1, "ctor (std::string) -> d");
|
||||
t.is (fromString10.year (), 2008, "ctor (std::string) -> y");
|
||||
|
||||
Date fromString11 ("6/7/2010 1:23:45", "m/d/Y h:N:S");
|
||||
t.is (fromString11.month (), 6, "ctor (std::string) -> m");
|
||||
t.is (fromString11.day (), 7, "ctor (std::string) -> d");
|
||||
t.is (fromString11.year (), 2010, "ctor (std::string) -> Y");
|
||||
t.is (fromString11.hour (), 1, "ctor (std::string) -> h");
|
||||
t.is (fromString11.minute (), 23, "ctor (std::string) -> N");
|
||||
t.is (fromString11.second (), 45, "ctor (std::string) -> S");
|
||||
|
||||
Date fromString12 ("6/7/2010 01:23:45", "m/d/Y H:N:S");
|
||||
t.is (fromString12.month (), 6, "ctor (std::string) -> m");
|
||||
t.is (fromString12.day (), 7, "ctor (std::string) -> d");
|
||||
t.is (fromString12.year (), 2010, "ctor (std::string) -> Y");
|
||||
t.is (fromString12.hour (), 1, "ctor (std::string) -> h");
|
||||
t.is (fromString12.minute (), 23, "ctor (std::string) -> N");
|
||||
t.is (fromString12.second (), 45, "ctor (std::string) -> S");
|
||||
|
||||
Date fromString13 ("6/7/2010 12:34:56", "m/d/Y H:N:S");
|
||||
t.is (fromString13.month (), 6, "ctor (std::string) -> m");
|
||||
t.is (fromString13.day (), 7, "ctor (std::string) -> d");
|
||||
t.is (fromString13.year (), 2010, "ctor (std::string) -> Y");
|
||||
t.is (fromString13.hour (), 12, "ctor (std::string) -> h");
|
||||
t.is (fromString13.minute (), 34, "ctor (std::string) -> N");
|
||||
t.is (fromString13.second (), 56, "ctor (std::string) -> S");
|
||||
|
||||
// Easter
|
||||
Date e1 (Date::easter(1980));
|
||||
t.is (e1.toString (), "4/6/1980", "Easter 4/6/1980");
|
||||
Date e2 (Date::easter(1995));
|
||||
t.is (e2.toString (), "4/16/1995", "Easter 4/16/1995");
|
||||
Date e3 (Date::easter(2000));
|
||||
t.is (e3.toString (), "4/23/2000", "Easter 4/23/2000");
|
||||
Date e4 (Date::easter(2009));
|
||||
t.is (e4.toString (), "4/12/2009", "Easter 4/12/2009");
|
||||
Date e5 (Date::easter(2010));
|
||||
t.is (e5.toString (), "4/4/2010", "Easter 4/4/2010");
|
||||
Date e6 (Date::easter(2011));
|
||||
t.is (e6.toString (), "4/24/2011", "Easter 4/24/2011");
|
||||
Date e7 (Date::easter(2012));
|
||||
t.is (e7.toString (), "4/8/2012", "Easter 4/8/2012");
|
||||
Date e8 (Date::easter(2020));
|
||||
t.is (e8.toString (), "4/12/2020", "Easter 4/12/2020");
|
||||
|
||||
// Relative dates.
|
||||
Date r1 ("today");
|
||||
t.ok (r1.sameDay (now), "today = now");
|
||||
@@ -255,6 +303,14 @@ int main (int argc, char** argv)
|
||||
|
||||
Date r13 ("eoy");
|
||||
t.ok (r13.sameYear (now), "eoy in same year as now");
|
||||
|
||||
// Date::sameHour
|
||||
Date r14 ("6/7/2010 01:00:00", "m/d/Y H:N:S");
|
||||
Date r15 ("6/7/2010 01:59:59", "m/d/Y H:N:S");
|
||||
t.ok (r14.sameHour (r15), "two dates within the same hour");
|
||||
|
||||
Date r16 ("6/7/2010 00:59:59", "m/d/Y H:N:S");
|
||||
t.notok (r14.sameHour (r16), "two dates not within the same hour");
|
||||
}
|
||||
|
||||
catch (std::string& e)
|
||||
|
||||
69
src/tests/grid.t.cpp
Normal file
69
src/tests/grid.t.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation; either version 2 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program; if not, write to the
|
||||
//
|
||||
// Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor,
|
||||
// Boston, MA
|
||||
// 02110-1301
|
||||
// USA
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <Context.h>
|
||||
#include <Grid.h>
|
||||
#include <test.h>
|
||||
|
||||
Context context;
|
||||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest ut (30);
|
||||
|
||||
Grid g;
|
||||
ut.is ((int) g.width (), 0, "Zero width for uninitialized grid");
|
||||
ut.is ((int) g.height (), 0, "Zero height for uninitialized grid");
|
||||
|
||||
g.add (2, 2, false);
|
||||
ut.is ((int) g.width (), 3, "Width of 3 columns");
|
||||
ut.is ((int) g.height (), 3, "Height of 3 rows");
|
||||
|
||||
Grid g2;
|
||||
g2.add (0, 1, "value");
|
||||
g2.add (1, 0, "value");
|
||||
ut.is ((int) g2.width (), 2, "Width of 2 columns");
|
||||
ut.is ((int) g2.height (), 2, "Height of 2 rows");
|
||||
ut.is (g2.byRow (0, 0), NULL, "Gap at 0,0");
|
||||
ut.ok (g2.byRow (0, 1), "Cell at 0,0");
|
||||
ut.ok (g2.byRow (1, 0), "Cell at 0,0");
|
||||
ut.is (g2.byRow (1, 1), NULL, "Gap at 1,1");
|
||||
|
||||
Grid g3;
|
||||
for (int i = 0; i < 14; ++i)
|
||||
g3.add (i / 4, i % 4, "value");
|
||||
|
||||
for (int i = 0; i < 20; ++i)
|
||||
if (i < 14)
|
||||
ut.ok (g3.byRow (i / 4, i % 4), "g3 good cell");
|
||||
else
|
||||
ut.is (g3.byRow (i / 4, i % 4), NULL, "g3 missing cell");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
80
src/tests/hook.api.task_get_due.t
Executable file
80
src/tests/hook.api.task_get_due.t
Executable file
@@ -0,0 +1,80 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.pre-display=" . $ENV{'PWD'} . "/hook:test\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function test ()\n",
|
||||
" print ('<<' .. task_get_due () .. '>>')\n",
|
||||
" return 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
# Test the hook.
|
||||
qx{../task rc:hook.rc add foo due:eom};
|
||||
$output = qx{../task rc:hook.rc info 1};
|
||||
like ($output, qr/^<<\d+>>$/ms, 'Hook called task_get_due');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('Hook called task_get_due - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
81
src/tests/hook.api.task_get_end.t
Executable file
81
src/tests/hook.api.task_get_end.t
Executable file
@@ -0,0 +1,81 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.pre-display=" . $ENV{'PWD'} . "/hook:test\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function test ()\n",
|
||||
" print ('<<' .. task_get_end () .. '>>')\n",
|
||||
" return 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
# Test the hook.
|
||||
qx{../task rc:hook.rc add foo};
|
||||
qx{../task rc:hook.rc do 1};
|
||||
$output = qx{../task rc:hook.rc info 1};
|
||||
like ($output, qr/^<<\d+>>$/ms, 'Hook called task_get_end');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('Hook called task_get_end - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
80
src/tests/hook.api.task_get_entry.t
Executable file
80
src/tests/hook.api.task_get_entry.t
Executable file
@@ -0,0 +1,80 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.pre-display=" . $ENV{'PWD'} . "/hook:test\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function test ()\n",
|
||||
" print ('<<' .. task_get_entry () .. '>>')\n",
|
||||
" return 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
# Test the hook.
|
||||
qx{../task rc:hook.rc add foo};
|
||||
$output = qx{../task rc:hook.rc info 1};
|
||||
like ($output, qr/^<<\d+>>$/ms, 'Hook called task_get_entry');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('Hook called task_get_entry - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
81
src/tests/hook.api.task_get_start.t
Executable file
81
src/tests/hook.api.task_get_start.t
Executable file
@@ -0,0 +1,81 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.pre-display=" . $ENV{'PWD'} . "/hook:test\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function test ()\n",
|
||||
" print ('<<' .. task_get_start () .. '>>')\n",
|
||||
" return 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
# Test the hook.
|
||||
qx{../task rc:hook.rc add foo};
|
||||
qx{../task rc:hook.rc start 1};
|
||||
$output = qx{../task rc:hook.rc info 1};
|
||||
like ($output, qr/^<<\d+>>$/ms, 'Hook called task_get_start');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('Hook called task_get_start - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
80
src/tests/hook.api.task_get_until.t
Executable file
80
src/tests/hook.api.task_get_until.t
Executable file
@@ -0,0 +1,80 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.pre-display=" . $ENV{'PWD'} . "/hook:test\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function test ()\n",
|
||||
" print ('<<' .. task_get_until () .. '>>')\n",
|
||||
" return 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
# Test the hook.
|
||||
qx{../task rc:hook.rc add foo due:tomorrow recur:weekly until:eoy};
|
||||
$output = qx{../task rc:hook.rc info 1};
|
||||
like ($output, qr/^<<\d+>>$/ms, 'Hook called task_get_until');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('Hook called task_get_until - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
80
src/tests/hook.api.task_get_wait.t
Executable file
80
src/tests/hook.api.task_get_wait.t
Executable file
@@ -0,0 +1,80 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.pre-display=" . $ENV{'PWD'} . "/hook:test\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function test ()\n",
|
||||
" print ('<<' .. task_get_wait () .. '>>')\n",
|
||||
" return 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
# Test the hook.
|
||||
qx{../task rc:hook.rc add foo wait:tomorrow};
|
||||
$output = qx{../task rc:hook.rc info 1};
|
||||
like ($output, qr/^<<\d+>>$/ms, 'Hook called task_get_wait');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('Hook called task_get_wait - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
81
src/tests/hook.format-countdown.t
Executable file
81
src/tests/hook.format-countdown.t
Executable file
@@ -0,0 +1,81 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.format-countdown=" . $ENV{'PWD'} . "/hook:countdown\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
# Create the hook functions.
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function countdown (name, value)\n",
|
||||
" value = '<' .. value .. '>'\n",
|
||||
" return value, 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
qx{../task rc:hook.rc add foo due:eom};
|
||||
$output = qx{../task rc:hook.rc long};
|
||||
|
||||
like ($output, qr/<-?\d+\s\D+>/, 'format-countdown hook countdown -> <countdown>');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('format-countdown hook countdown -> <countdown> - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
83
src/tests/hook.format-countdown_compact.t
Executable file
83
src/tests/hook.format-countdown_compact.t
Executable file
@@ -0,0 +1,83 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"report.long.columns=id,project,priority,entry,start_time,due,",
|
||||
"recur,countdown_compact,age,tags,description\n",
|
||||
"hooks=on\n",
|
||||
"hook.format-countdown_compact=" . $ENV{'PWD'} . "/hook:countdown_compact\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
# Create the hook functions.
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function countdown_compact (name, value)\n",
|
||||
" value = '<' .. value .. '>'\n",
|
||||
" return value, 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
qx{../task rc:hook.rc add foo due:eom};
|
||||
$output = qx{../task rc:hook.rc long};
|
||||
|
||||
like ($output, qr/<-?\d+\D+>/, 'format-countdown_compact hook countdown_compact -> <countdown_compact>');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('format-countdown_compact hook countdown_compact -> <countdown_compact> - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
81
src/tests/hook.format-due.t
Executable file
81
src/tests/hook.format-due.t
Executable file
@@ -0,0 +1,81 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.format-due=" . $ENV{'PWD'} . "/hook:due\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
# Create the hook functions.
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function due (name, value)\n",
|
||||
" value = '<' .. value .. '>'\n",
|
||||
" return value, 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
qx{../task rc:hook.rc add foo due:tomorrow};
|
||||
$output = qx{../task rc:hook.rc list};
|
||||
|
||||
like ($output, qr/<\d+\/\d+\/\d+>/, 'format-due hook due -> <due>');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('format-due hook due -> <due> - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
82
src/tests/hook.format-end.t
Executable file
82
src/tests/hook.format-end.t
Executable file
@@ -0,0 +1,82 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.format-end=" . $ENV{'PWD'} . "/hook:xend\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
# Create the hook functions.
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function xend (name, value)\n",
|
||||
" value = '<' .. value .. '>'\n",
|
||||
" return value, 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
qx{../task rc:hook.rc add foo};
|
||||
qx{../task rc:hook.rc do 1};
|
||||
$output = qx{../task rc:hook.rc completed};
|
||||
|
||||
like ($output, qr/<\d+\/\d+\/\d+>/, 'format-end hook end -> <end>');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('format-end hook end -> <end> - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
84
src/tests/hook.format-end_time.t
Executable file
84
src/tests/hook.format-end_time.t
Executable file
@@ -0,0 +1,84 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"report.completed.columns=end_time,project,priority,age,description\n",
|
||||
"report.completed.sort=end_time+,priority-,project+\n",
|
||||
"hooks=on\n",
|
||||
"hook.format-end_time=" . $ENV{'PWD'} . "/hook:end_time\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
# Create the hook functions.
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function end_time (name, value)\n",
|
||||
" value = '<' .. value .. '>'\n",
|
||||
" return value, 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
qx{../task rc:hook.rc add foo};
|
||||
qx{../task rc:hook.rc do 1};
|
||||
$output = qx{../task rc:hook.rc completed};
|
||||
|
||||
like ($output, qr/<\d+\/\d+\/\d+\s\d+:\d+:\d+>/, 'format-end_time hook end_time -> <end_time>');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('format-end_time hook end_time -> <end_time> - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
81
src/tests/hook.format-entry.t
Executable file
81
src/tests/hook.format-entry.t
Executable file
@@ -0,0 +1,81 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.format-entry=" . $ENV{'PWD'} . "/hook:entry\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
# Create the hook functions.
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function entry (name, value)\n",
|
||||
" value = '<' .. value .. '>'\n",
|
||||
" return value, 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
qx{../task rc:hook.rc add foo};
|
||||
$output = qx{../task rc:hook.rc long};
|
||||
|
||||
like ($output, qr/<\d+\/\d+\/\d+>/, 'format-entry hook entry -> <entry>');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('format-entry hook entry -> <entry> - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
82
src/tests/hook.format-entry_time.t
Executable file
82
src/tests/hook.format-entry_time.t
Executable file
@@ -0,0 +1,82 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"report.long.columns=id,project,priority,entry_time,start,due,recur,countdown,age,tags,description\n",
|
||||
"hooks=on\n",
|
||||
"hook.format-entry_time=" . $ENV{'PWD'} . "/hook:entry_time\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
# Create the hook functions.
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function entry_time (name, value)\n",
|
||||
" value = '<' .. value .. '>'\n",
|
||||
" return value, 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
qx{../task rc:hook.rc add foo};
|
||||
$output = qx{../task rc:hook.rc long};
|
||||
|
||||
like ($output, qr/<\d+\/\d+\/\d+\s\d+:\d+:\d+>/, 'format-entry_time hook entry_time -> <entry_time>');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('format-entry_time hook entry_time -> <entry_time> - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
81
src/tests/hook.format-prompt.t
Executable file
81
src/tests/hook.format-prompt.t
Executable file
@@ -0,0 +1,81 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"shell.prompt=foo\n",
|
||||
"default.command=_version\n",
|
||||
"hooks=on\n",
|
||||
"hook.format-prompt=" . $ENV{'PWD'} . "/hook:prompt\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
# Create the hook functions.
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function prompt (name, value)\n",
|
||||
" value = '<' .. value .. '>'\n",
|
||||
" return value, 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
my $output = qx{echo "\\nquit\\n" | ../task rc:hook.rc shell};
|
||||
like ($output, qr/<foo>/, 'format-prompt hook prompt -> <prompt>');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('format-prompt hook prompt -> <prompt> - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
81
src/tests/hook.format-recur.t
Executable file
81
src/tests/hook.format-recur.t
Executable file
@@ -0,0 +1,81 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.format-recur=" . $ENV{'PWD'} . "/hook:recur\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
# Create the hook functions.
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function recur (name, value)\n",
|
||||
" value = '<' .. value .. '>'\n",
|
||||
" return value, 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
qx{../task rc:hook.rc add foo due:tomorrow recur:weekly};
|
||||
$output = qx{../task rc:hook.rc long};
|
||||
|
||||
like ($output, qr/<weekly>/, 'format-recur hook recur -> <recur>');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('format-recur hook recur -> <recur> - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
82
src/tests/hook.format-start.t
Executable file
82
src/tests/hook.format-start.t
Executable file
@@ -0,0 +1,82 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.format-start=" . $ENV{'PWD'} . "/hook:start\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
# Create the hook functions.
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function start (name, value)\n",
|
||||
" value = '<' .. value .. '>'\n",
|
||||
" return value, 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
qx{../task rc:hook.rc add foo};
|
||||
qx{../task rc:hook.rc start 1};
|
||||
$output = qx{../task rc:hook.rc long};
|
||||
|
||||
like ($output, qr/<\d+\/\d+\/\d+>/, 'format-start hook start -> <start>');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('format-start hook start -> <start> - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
83
src/tests/hook.format-start_time.t
Executable file
83
src/tests/hook.format-start_time.t
Executable file
@@ -0,0 +1,83 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"report.long.columns=id,project,priority,entry,start_time,due,recur,countdown,age,tags,description\n",
|
||||
"hooks=on\n",
|
||||
"hook.format-start_time=" . $ENV{'PWD'} . "/hook:start_time\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
# Create the hook functions.
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function start_time (name, value)\n",
|
||||
" value = '<' .. value .. '>'\n",
|
||||
" return value, 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
qx{../task rc:hook.rc add foo};
|
||||
qx{../task rc:hook.rc start 1};
|
||||
$output = qx{../task rc:hook.rc long};
|
||||
|
||||
like ($output, qr/<\d+\/\d+\/\d+\s\d+:\d+:\d+>/, 'format-start_time hook start_time -> <start_time>');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('format-start_time hook start_time -> <start_time> - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
81
src/tests/hook.format-wait.t
Executable file
81
src/tests/hook.format-wait.t
Executable file
@@ -0,0 +1,81 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'hook.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"hooks=on\n",
|
||||
"hook.format-wait=" . $ENV{'PWD'} . "/hook:wait\n";
|
||||
close $fh;
|
||||
ok (-r 'hook.rc', 'Created hook.rc');
|
||||
}
|
||||
|
||||
# Create the hook functions.
|
||||
if (open my $fh, '>', 'hook')
|
||||
{
|
||||
print $fh "function wait (name, value)\n",
|
||||
" value = '<' .. value .. '>'\n",
|
||||
" return value, 0, nil\n",
|
||||
"end\n";
|
||||
close $fh;
|
||||
ok (-r 'hook', 'Created hook');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:hook.rc version};
|
||||
if ($output =~ /PUC-Rio/)
|
||||
{
|
||||
qx{../task rc:hook.rc add foo wait:tomorrow};
|
||||
$output = qx{../task rc:hook.rc waiting};
|
||||
|
||||
like ($output, qr/<\d+\/\d+\/\d+>/, 'format-wait hook wait -> <wait>');
|
||||
}
|
||||
else
|
||||
{
|
||||
pass ('format-wait hook wait -> <wait> - skip: no Lua support');
|
||||
}
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'hook';
|
||||
ok (!-r 'hook', 'Removed hook');
|
||||
|
||||
unlink 'hook.rc';
|
||||
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
@@ -35,7 +35,7 @@ Context context;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (19);
|
||||
UnitTest t (21);
|
||||
|
||||
// (blank)
|
||||
bool good = true;
|
||||
@@ -94,8 +94,14 @@ int main (int argc, char** argv)
|
||||
t.is (record.composeF4 (), "[name:\"value\" one:\"1\"]\n", "Record::set");
|
||||
t.is (record.get_int ("one"), 1, "Record::get_int");
|
||||
|
||||
// Record::get_ulong
|
||||
record.set ("two", "4294967295");
|
||||
t.is (record.composeF4 (), "[name:\"value\" one:\"1\" two:\"4294967295\"]\n", "Record::set");
|
||||
t.is ((size_t)record.get_ulong ("two"), (size_t)4294967295, "Record::get_ulong");
|
||||
|
||||
// Record::remove
|
||||
record.remove ("one");
|
||||
record.remove ("two");
|
||||
t.is (record.composeF4 (), "[name:\"value\"]\n", "Record::remove");
|
||||
|
||||
// Record::all
|
||||
|
||||
@@ -26,9 +26,7 @@ esac
|
||||
|
||||
RUNTIME=$(($ENDEPOCH - $STARTEPOCH))
|
||||
|
||||
echo -n 'Pass: '
|
||||
grep ^ok all.log | wc -l
|
||||
echo -n 'Fail: '
|
||||
grep ^not all.log | wc -l
|
||||
echo -n 'Runtime: '
|
||||
echo $RUNTIME
|
||||
printf "Pass: %5d\n" $(grep ^ok all.log | wc -l)
|
||||
printf "Fail: %5d\n" $(grep ^not all.log | wc -l)
|
||||
printf "Skipped: %5d\n" $(grep ^skip all.log | wc -l)
|
||||
printf "Runtime: %5d\n" $RUNTIME
|
||||
|
||||
20
with_lua
20
with_lua
@@ -1,14 +1,24 @@
|
||||
# This is currently what is required to build with Lua.
|
||||
|
||||
# OSX:
|
||||
autoreconf -f
|
||||
./configure --with-lua
|
||||
OS=`uname`
|
||||
|
||||
case $OS in
|
||||
Darwin)
|
||||
./configure --with-lua
|
||||
;;
|
||||
esac
|
||||
|
||||
# Cygwin 1.5:
|
||||
#autoreconf -f
|
||||
# Command:
|
||||
#./configure
|
||||
|
||||
# Cygwin 1.7:
|
||||
#autoreconf -f
|
||||
# Command:
|
||||
#./configure --with-ncurses --with-ncurses-inc=/usr/include/ncurses
|
||||
|
||||
# Ubuntu 9.10:
|
||||
# sudo apt-get install lualib5.1-0-dev
|
||||
# The library name is also liblua5.1.a, with no symlink to liblua.a.
|
||||
# Command:
|
||||
# ./configure --with-lua --with-lua-inc=/usr/include/lua5.1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user