Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
462f27fce7 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -15,5 +15,5 @@ www.xls
|
||||
src/tests/all.log
|
||||
src/tests/*.data
|
||||
*~
|
||||
movie*
|
||||
.*.swp
|
||||
package-config/osx/binary/task
|
||||
|
||||
18
AUTHORS
18
AUTHORS
@@ -3,7 +3,6 @@ The development of task was made possible by the significant contributions of th
|
||||
Federico Hernandez (Package Maintainer & Contributing Author)
|
||||
David J Patrick (Designer)
|
||||
John Florian (Contributing Author)
|
||||
Cory Donnelly (Contributing Author)
|
||||
|
||||
The following submitted code, packages or analysis, and deserve special thanks:
|
||||
Damian Glenny
|
||||
@@ -18,13 +17,6 @@ The following submitted code, packages or analysis, and deserve special thanks:
|
||||
P.C. Shyamshankar
|
||||
Johan Friis
|
||||
Steven de Brouwer
|
||||
Pietro Cerutti
|
||||
Alexander Neumann
|
||||
Emil Sköldberg
|
||||
Johannes Schlatow
|
||||
Michal Josífko
|
||||
Ed Neville
|
||||
Kevin Owens
|
||||
|
||||
Thanks to the following, who submitted detailed bug reports and excellent suggestions:
|
||||
Eugene Kramer
|
||||
@@ -33,6 +25,7 @@ Thanks to the following, who submitted detailed bug reports and excellent sugges
|
||||
Thomas Engel
|
||||
Nishiishii
|
||||
galvanizd
|
||||
Stas Antons
|
||||
Vincent Fleuranceau
|
||||
ArchiMark
|
||||
Carlos Yoder
|
||||
@@ -41,15 +34,6 @@ Thanks to the following, who submitted detailed bug reports and excellent sugges
|
||||
Eric Farris
|
||||
Bruce Dillahunty
|
||||
Askme Too
|
||||
Mike Adonay
|
||||
Thomas@BIC
|
||||
Ian Mortimer
|
||||
Zach Frazier
|
||||
Ivo Jimenez
|
||||
Joe Pulliam
|
||||
Juergen Daubert
|
||||
Rich Mintz
|
||||
Seneca Cunningham
|
||||
Dirk Deimeke
|
||||
Michelle Crane
|
||||
|
||||
|
||||
285
ChangeLog
285
ChangeLog
@@ -1,283 +1,7 @@
|
||||
|
||||
------ current release ---------------------------
|
||||
|
||||
1.9.2 (7/10/2010)
|
||||
+ Added feature #320, so the command "task 123" is interpreted as an implicit
|
||||
"task info 123" command (thanks to John Florian).
|
||||
+ Added feature #326, allowing tasks to be added in the completed state, by
|
||||
using the 'log' command in place of 'add' (thanks to Cory Donnelly).
|
||||
+ Added features #36 and #37, providing annual versions of the 'history' and
|
||||
'ghistory' command as 'history.annual' and 'ghistory.annual'.
|
||||
+ Added feature #363 supporting iCalendar/vcalendar (RFC-2445, RFC-5545,
|
||||
RFC-5546) export via the 'export.ical' command.
|
||||
+ Added feature #390, an extra dateformat for annotations (thanks to Cory
|
||||
Donnelly).
|
||||
+ Added feature #407, a new 'task show' command to display the current
|
||||
configuration settings or just the ones matching a search string.
|
||||
'task config' is now only used to set new configuration values.
|
||||
+ Added feature #298, supporting a configurable number of future recurring
|
||||
tasks that are generated.
|
||||
+ Added feature #412, which allows the 'projects' and 'tags' commands to be
|
||||
list all used projects/tags, not just the ones used in current pending tasks.
|
||||
Controlled by the 'list.all.projects' and 'list.all.tags' configuration
|
||||
variables (thanks to Dirk Deimeke).
|
||||
+ Added feature #415, which supports displaying just a single page of tasks,
|
||||
by specifying either 'limit:page' to a command, or 'report.xxx.limit:page'
|
||||
in a report specification (thanks to T. Charles Yun).
|
||||
+ Improvements to the man pages (thanks to T. Charles Yun).
|
||||
+ Modified the 'next' report to only display one page, by default.
|
||||
+ Added feature #408, making it possible to delete annotations with the new
|
||||
denotate command and the provided description (thanks to Dirk Deimeke).
|
||||
+ Added support for more varied durations when specifying recurring tasks,
|
||||
such as '3 mths' or '24 hrs'.
|
||||
+ The ghistory graph bars can now be colored with 'color.history.add',
|
||||
'color.history.done' and 'color.history.delete' configuration variables.
|
||||
+ Added feature #156, so that task supports both a 'side' and 'diff' style
|
||||
of undo.
|
||||
+ Distribution now includes 7 theme files, for 16- and 256-color terminals.
|
||||
+ Task now defaults to using the equivalent to the dark-16.theme.
|
||||
+ Fixed bug #406 so that task now includes command aliases in the _commands
|
||||
helper command used by shell completion scripts.
|
||||
+ Fixed bug #211 - it was unclear which commands modify a task description.
|
||||
+ Fixed bug #411, clarifying that the 'projects' command only lists projects
|
||||
for which there are pending tasks (thanks to Dirk Deimeke).
|
||||
+ Fixed bug #414, that caused filtering on the presence or absence of tags
|
||||
containing Unicode characters to fail (thanks to Michal Josífko).
|
||||
+ Fixed bug #416, which caused sorting on a date to fail if the year was not
|
||||
included in the dateformat (thanks to Michelle Crane).
|
||||
+ Fixed bug #417, which caused sorting on countdown and age fields to be
|
||||
wrong (thanks to Michell Crane).
|
||||
+ Fixed bug #418, which caused the attribute modifier 'due.before' to fail
|
||||
if the year was not included in the dateformat (thanks to Michelle Crane).
|
||||
+ Fixed bug #132, which failed to set a sort order so that active tasks sort
|
||||
higher than inactive tasks, all things being equal.
|
||||
+ Fixed bug #405, which incorrectly compared dates on tasks created by
|
||||
versions earlier than 1.9.1 to those created by 1.9.1 or later (thanks to
|
||||
Ivo Jimenez).
|
||||
+ Fixed bug #420, missing 'ID' from help text (thanks to Ed Neville).
|
||||
+ Fixed bug that prevented 'task list priority.above:L' from working.
|
||||
+ Fixed bug that miscalculated terminal width for the ghistory.annual
|
||||
report.
|
||||
+ Fixed wording (support issue #383) when modifying a recurring task (thanks
|
||||
to T. Charles Yun).
|
||||
|
||||
------ old releases ------------------------------
|
||||
|
||||
1.9.1 (5/22/2010) 60a99725b858be134ad538cb7c1a32c98de70e67
|
||||
+ 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).
|
||||
|
||||
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
|
||||
used in the reports with more conversion sequences like weekday name
|
||||
or weeknumber. The date format is set with variable "dateformat.report".
|
||||
+ Added feature #292 that permits alternate line coloration in reports
|
||||
(thanks to Richard Querin).
|
||||
+ Added feature #307 that provides vim with syntax highlighting for .taskrc.
|
||||
+ Added feature #336 which gives task a 'prepend' command for symmetry
|
||||
with the 'append' command.
|
||||
+ Added feature #341 that makes explicit references to the task and taskrc
|
||||
man pages, both in the auto-generated .taskrc file and the version command
|
||||
output (thanks to Cory Donnelly).
|
||||
+ The 'delete' command is now aliased to 'rm' (thanks to Ivo Jimenez).
|
||||
+ Added new attribute modifiers 'word' and 'noword' which find the existence
|
||||
of whole words, or prove the non-existence of whole words. If a task has
|
||||
the description "Pay the bill", then "description.word:the" will match, but
|
||||
"description.word:th" will not. For partial word matches, there is still
|
||||
"description.contains:th".
|
||||
+ Added new 'config' command to display the configuration settings of task.
|
||||
As a consequence 'version' now only shows the version number and legal
|
||||
information.
|
||||
+ The 'config' command now complains about use of deprecated color names in
|
||||
your .taskrc file.
|
||||
+ Added feature #296, that allows the 'config' command to modify your .taskrc
|
||||
settings directly, with the command 'task config <name> <value>', or
|
||||
'task config <name>' to remove the setting.
|
||||
+ Task now supports nested .taskrc files using the "include /path" directive.
|
||||
+ The 'entry', 'start' and 'end' columns now have equivalents that include the
|
||||
time, and are called 'entry_time', 'start_time', and 'end_time', for use in
|
||||
custom reports.
|
||||
+ 2 new columns have been added to the reports: countdown and
|
||||
countdown_compact. They show the days left until a task is due or how many
|
||||
days a task has been overdue.
|
||||
+ The new 'priority_long' field can be shown in custom reports, and will
|
||||
display 'High' rather than the abbreviated 'H'.
|
||||
+ Task now supports .taskrc command line overrides using rc.name:value and
|
||||
the new rc.name=value to accommodate a frequent mistake.
|
||||
+ The color rules for projects (color.project.foo) now matches on partial
|
||||
project names, the same way as filters.
|
||||
+ The color command now takes a color as an argument, and displays that color
|
||||
with sample text.
|
||||
+ Added 2 new configuration variables to display the details of tasks with due
|
||||
dates when doing a 'task cal' for the corresponding months:
|
||||
'calendar.details' and 'calendar.details.report'
|
||||
+ Added 5 new color configuration variables to colorize today, days with due
|
||||
tasks, days with overdue tasks, weekend days and week numbers in the
|
||||
calendar:
|
||||
'calendar.color.today', 'color.calendar.due', 'calendar.calendar.overdue',
|
||||
'color.calendar.weekend'and 'color.calendar.weeknumber'.
|
||||
+ Added support for holidays in the calendar by using calendar.holidays
|
||||
and the corresponding holiday.X.name and holiday.X.date variables.
|
||||
The default dateformat being YMD (20101224) set by dateformat.holiday.
|
||||
+ The coloring of due tasks in reports can now be enabled for all tasks, and
|
||||
not only the imminent ones, by setting the configuration variable due=0.
|
||||
+ Tasks due on the current day ("today") can now have their own color setting
|
||||
color.due.today and color.calendar.due.today.
|
||||
+ Added a new 'task-faq' man page for common questions and answers.
|
||||
+ 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).
|
||||
+ 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
|
||||
active.indicator configuration variable to something other than the default
|
||||
of *.
|
||||
+ Task can now use an alternate recurrence indicator by setting the
|
||||
recurrence.indicator configuration variable to something other than the
|
||||
default of R.
|
||||
+ Added a new file, README.build, which provides assistance troubleshooting
|
||||
build-related problems on different operating systems and environments.
|
||||
+ Fixed bug #316 which caused the timesheet report to display an oddly sorted
|
||||
list.
|
||||
+ Fixed bug #317 which colored tasks in the 'completed' report according to
|
||||
due dates, which are no longer relevant to a completed task (thanks to
|
||||
Cory Donnelly).
|
||||
+ Fixed bug #347 which used only a lowercase "all" to confirm multiple changes
|
||||
instead of an uppercase "All" like the "Yes" answer.
|
||||
+ Fixed bug that was causing the 'completed' report to sort incorrectly.
|
||||
+ Fixed bug that showed a calendar for the year 2037 when 'task calendar due'
|
||||
was run, and there are no tasks with due dates.
|
||||
+ Fixed bug #360 which prevented certain modifications to recurring tasks
|
||||
(thanks to John Florian).
|
||||
+ Fixed bug #299 which prevented excluding multiple projects from a report,
|
||||
by using "task list project.isnt:foo project.isnt:bar" (thanks to John
|
||||
Florian).
|
||||
+ Fixed bug #368 which caused recurring tasks 'until' dates to be rendered as
|
||||
epoch numbers instead of dates (thanks to Cory Donnelly).
|
||||
+ Fixed bug #369 which prevented the config command from setting quoted or
|
||||
unquoted multi-word values (thanks to Richard Querin).
|
||||
+ Fixed bug #370 which prevented the removal of a due date from a task,
|
||||
mis-identifying the task as recurring just because it had a due date
|
||||
(thanks to John Florian).
|
||||
+ Fixed bug #371 which caused task to mis-apply certain color rules, like
|
||||
color.alternate, which was (a) not applied first, and (b) not blended
|
||||
with the other color rules (thanks to Richard Querin).
|
||||
+ Fixed bug #372 which incorrectly mapped 16-color backgrounds into the
|
||||
256-color space.
|
||||
|
||||
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)".
|
||||
+ Added feature #341 that makes explicit references to the task and taskrc
|
||||
man pages, both in the auto-generated .taskrc file and the version command
|
||||
output (thanks to Cory Donnelly).
|
||||
+ Added feature - #310 that simplified and make clearer an error message
|
||||
that complained about things that were beyond user control (thanks to
|
||||
John Florian).
|
||||
+ Fixed bug that was causing the 'completed' report to sort incorrectly.
|
||||
+ Fixed bug #321 where all shell input was converted to lower case (thanks
|
||||
to Juergen Daubert).
|
||||
+ Fixed bug #327 that allowed the removal of a due date from a recurring
|
||||
task.
|
||||
+ Fixed bug #317 which colored tasks in the 'completed' report according
|
||||
to due dates, which are no longer relevant to a completed task (thanks
|
||||
to Cory Donnelly).
|
||||
+ Fixed bug that was causing the 'completed' report to sort incorrectly.
|
||||
+ Fixed bug #322 which failed to propagate rc overrides to shell commands.
|
||||
+ Fixed redundant messages when exiting shell mode.
|
||||
+ Fixed bug #333 which failed to display the ID of a duplicated task (thanks
|
||||
to Cory Donnelly).
|
||||
+ Fixed bug #332 where task complained that the 'recur_ind' custom report
|
||||
column was invalid. It was misnamed in the documentation, which should
|
||||
have read 'recurrence_indicator'. Also, the 'tag_indicator' column was
|
||||
not mentioned anywhere (thanks to T. Charles Yun).
|
||||
+ Fixed bug #319 that caused task to not properly detect the removal of a
|
||||
tag when obtaining confirmation from the user fora bulk modification
|
||||
(thanks to Cory Donnelly).
|
||||
|
||||
1.8.4 (11/17/2009) 12c4983936d27317df100f05da8244139dd06a3f
|
||||
+ Fixed bug that caused wait: dates to not be properly rendered in a
|
||||
readable and preferred format with the "edit" command.
|
||||
+ Fixed bug that caused a hang on cygwin, when a task with multiple
|
||||
annotations was edited (thanks to Joe Pulliam).
|
||||
+ Fixed bug #314 where the edit command fails when data.location includes
|
||||
directories containing spaces (thanks to Cory Donnelly).
|
||||
+ Added a warning (issue #312) when modifying recurring tasks, that all
|
||||
instances of that task may be modified. When task confirms a bulk edit
|
||||
the recurrence is again indicated (thanks to Cory Donnelly).
|
||||
|
||||
1.8.3 (10/21/2009) bcdcbeeea0d92f21c3565aebfaf6332b959f4025
|
||||
+ Added support for Haiku R1/alpha1
|
||||
|
||||
1.8.2 (9/7/2009) f243f0ed443ecd7dde779de8a6525222591024db
|
||||
+ Added feature #282 that returns useful exit codes to the shell. Now a
|
||||
script can detect whether no tasks were returned by a report (thanks to
|
||||
Pietro Cerutti).
|
||||
+ Fixed bug #287 that causes color control codes to be written to shadow
|
||||
files (thanks to Richard Querin).
|
||||
+ Fixed bug #289 which imported task from todo.sh without valid uuids
|
||||
(thanks to Ben Jackson).
|
||||
+ Fixed bug #291 which generated a false warning about an unrecognized
|
||||
variable when enabling default.projects in .taskrc (thanks to Thomas@BIC).
|
||||
+ Fixed bug #288 which failed to propagate rc file overrides on the command
|
||||
line to the default command (thanks to Zach Frazier).
|
||||
|
||||
1.8.1 (8/20/2009) 35792e7874d2bb664abb1a0a67960b7fe7e0fccf
|
||||
+ Fixed bug #231 that broke the build on OpenBSD 32-bit due to a time_t
|
||||
and int collision (thanks to Pietro Cerutti).
|
||||
+ Fixed bug #241 that prevented bash's tab-completion of projects in Fedora
|
||||
11 and likely anything using bash-4 (thanks to John Florian).
|
||||
+ Fixed bug #242 that sometimes causes the ID echoed after a task is added
|
||||
to be incorrect (thanks to John Florian).
|
||||
+ Fixed bug #245 that quoted date fields on export, that were subsequently
|
||||
improperly parsed on import (thanks to John Florian).
|
||||
+ Fixed bug #248 where single and double quotes are both stored as
|
||||
ampersand-quot-semi (thanks to John Florian).
|
||||
+ Fixed bug #249 that caused annotations with the same date to be lost after
|
||||
a "task edit" command (thanks to Federico Hernandez).
|
||||
+ Fixed bug #250 whereby rc.dateformat was not observed when parsing the
|
||||
creation date of an annotation (thanks to Federico Hernandez).
|
||||
+ Fixed bug #251 whereby the presence of annotations cause the .hasnt attribute
|
||||
modifier to not work (thanks to John Florian).
|
||||
+ Fixed bug #252 that prevented use of attribute modifiers on dates to effect
|
||||
a range, such as "task ls due.after:eom due.before:eoy" (thanks to John
|
||||
Florian).
|
||||
+ Fixed bug #256 that allowed a recurring task with no due date.
|
||||
+ Fixed bug #257 where an extant ~/.taskrc file prevented the override and
|
||||
automatic creation of an alternate rc file (thanks to Zach Frazier).
|
||||
+ Fixed bug #259 that cause a build failure on Snow Leopard 10a432.
|
||||
+ Fixed bug #260 whereby the start, stop and delete commands did not complain
|
||||
when filter arguments were specified, even though they were ignored
|
||||
(thanks to T. Charles Yun).
|
||||
+ Fixed bug that allowed a recurring task to be added without a due date.
|
||||
+ Fixed bug that displays the wrong .taskrc file name on override (thanks to
|
||||
Federico Hernandez).
|
||||
+ Fixed bug that failed to suppress color control code in the header and
|
||||
footnote when redirecting output to a file (thanks to John Florian).
|
||||
|
||||
1.8.0 (7/21/2009) 14977ef317bd004dae2f2c313e806af9f2a2140c
|
||||
1.8.0 (7/21/2009)
|
||||
+ Added zsh tab completion script (thanks to P.C. Shyamshankar).
|
||||
+ Fixed bug that cause the _forcecolor configuration variable to be
|
||||
considered obsolete (thank to Bruce Dillahunty).
|
||||
@@ -346,7 +70,9 @@
|
||||
and completed tasks.
|
||||
+ Now over 1,600 unit tests, helping to maintain code quality.
|
||||
|
||||
1.7.1 (6/8/2009) 1422a15cbc470cff590bf06daad20d01fe1b05ef
|
||||
------ old releases ------------------------------
|
||||
|
||||
1.7.1 (6/8/2009)
|
||||
+ Fixed build failure on OpenBSD (thanks to Mike Adonay).
|
||||
+ Took the opportunity of a patch release to update the various email
|
||||
addresses and URLs in the various documents.
|
||||
@@ -592,8 +318,7 @@
|
||||
+ Bug: configure.ac does not properly determine ncurses availability.
|
||||
+ Bug: Cannot seem to use the percent character in a task description.
|
||||
+ Bug: New installation "task stats" reports newest task 12/31/1969.
|
||||
+ Bug: New installation task projects displays header but no data - should
|
||||
short-circuit.
|
||||
+ Bug: New installation task projects displays header but no data - should short-circuit.
|
||||
+ Bug: incorrect color specification in sample .taskrc file.
|
||||
+ Bug: when run without arguments, task dumps core on Solaris 10.
|
||||
+ "task calendar" now reports all months with due pending tasks.
|
||||
|
||||
12
Makefile.am
12
Makefile.am
@@ -1,11 +1,11 @@
|
||||
SUBDIRS = src
|
||||
|
||||
dist_man_MANS = doc/man/task.1 doc/man/taskrc.5 doc/man/task-tutorial.5 doc/man/task-faq.5 doc/man/task-color.5
|
||||
dist_man_MANS = doc/man/task.1 doc/man/taskrc.5 doc/man/task-tutorial.5
|
||||
|
||||
#docdir = $(datadir)/doc/${PACKAGE}-${VERSION}
|
||||
docdir = $(datadir)/doc/${PACKAGE}-${VERSION}
|
||||
doc_DATA = AUTHORS ChangeLog COPYING NEWS README
|
||||
|
||||
EXTRA_DIST = INSTALL README.build
|
||||
EXTRA_DIST = INSTALL
|
||||
|
||||
bashscriptsdir = $(docdir)
|
||||
nobase_dist_bashscripts_DATA = scripts/bash/task_completion.sh
|
||||
@@ -14,11 +14,7 @@ zshscriptsdir = $(docdir)
|
||||
nobase_dist_zshscripts_DATA = scripts/zsh/_task
|
||||
|
||||
vimscriptsdir = $(docdir)
|
||||
nobase_dist_vimscripts_DATA = scripts/vim/README scripts/vim/ftdetect/task.vim scripts/vim/syntax/taskdata.vim scripts/vim/syntax/taskedit.vim scripts/vim/syntax/taskrc.vim
|
||||
nobase_dist_vimscripts_DATA = scripts/vim/README scripts/vim/ftdetect/task.vim scripts/vim/syntax/taskdata.vim scripts/vim/syntax/taskedit.vim
|
||||
|
||||
i18ndir = $(docdir)
|
||||
nobase_dist_i18n_DATA = i18n/strings.de-DE i18n/strings.en-US i18n/strings.es-ES i18n/strings.fr-FR i18n/strings.nl-NL i18n/strings.sv-SE i18n/tips.de-DE i18n/tips.en-US i18n/tips.sv-SE
|
||||
|
||||
rcfiledir = $(docdir)/rc
|
||||
dist_rcfile_DATA = doc/rc/holidays-US.rc doc/rc/holidays-SE.rc doc/rc/dark-16.theme doc/rc/dark-256.theme doc/rc/light-16.theme doc/rc/light-256.theme doc/rc/dark-blue-256.theme doc/rc/dark-green-256.theme doc/rc/dark-red-256.theme
|
||||
|
||||
|
||||
47
NEWS
47
NEWS
@@ -1,35 +1,34 @@
|
||||
|
||||
New Features in task 1.9.2
|
||||
New Features in task 1.8.0
|
||||
|
||||
- New 'log' command to add tasks that are already completed.
|
||||
- New annual history and ghistory command variations.
|
||||
- Alias support in shell completion scripts.
|
||||
- New iCalendar/vcalendar export format (RFC-2445, RFC-5545, RFC-5546).
|
||||
- New 'show' command to display configuration settings.
|
||||
- New 'denotate' command to delete annotations.
|
||||
- New 16-color and 256-color themes included.
|
||||
- New limit:page filter to show only one page of tasks.
|
||||
- Performance enhancements.
|
||||
- Attribute modifiers, for precise queries
|
||||
- Improved calendar feature
|
||||
- Full undo capability
|
||||
- All reports now customizable
|
||||
- Command aliases can now be created
|
||||
- In addition to being a standard part of Fedora 10 and 11 (yum install task),
|
||||
task is now also a standard part of Cygwin 1.5
|
||||
- There are new demo movies on taskwarrior.org
|
||||
|
||||
Please refer to the ChangeLog file for full details. There are too many to
|
||||
list here.
|
||||
|
||||
Task has been built and tested on the following configurations:
|
||||
|
||||
* OS X 10.6 Snow Leopard and 10.5 Leopard
|
||||
* Fedora 13 Goddard, 12 Constantine
|
||||
* Ubuntu 10.04 Lucid Lynx, 9.10 Karmic Koala
|
||||
* Debian Sid
|
||||
* Slackware 12.2
|
||||
* Arch Linux
|
||||
* Gentoo Linux
|
||||
* SliTaz Linux
|
||||
* CRUX Linux
|
||||
* Solaris 10 and 8
|
||||
* OpenBSD 4.5
|
||||
* FreeBSD
|
||||
* Cygwin 1.7 and 1.5
|
||||
* Haiku R1/alpha1
|
||||
- OS X 10.5 Leopard
|
||||
- OS X 10.4 Tiger
|
||||
- Fedora Core 11 Leonidas
|
||||
- Fedora Core 10 Cambridge
|
||||
- Ubuntu 9.04 Jaunty Jackalope
|
||||
- Ubuntu 8.10 Intrepid Ibex
|
||||
- Ubuntu 8.04 Hardy Heron
|
||||
- Slackware 12.2
|
||||
- Arch Linux
|
||||
- Solaris 10
|
||||
- Solaris 8
|
||||
- OpenBSD 4.5
|
||||
- FreeBSD
|
||||
- Cygwin 1.5.25-14
|
||||
|
||||
While Task has undergone testing, bugs are sure to remain. If you encounter a
|
||||
bug, please enter a new issue at:
|
||||
|
||||
7
README
7
README
@@ -4,15 +4,16 @@ Thank you for taking a look at task!
|
||||
Task is a GTD, todo list, task management, command line utility with a multitude
|
||||
of features. It is a portable, well supported, very active project, and it is
|
||||
Open Source. Task has binary distributions, online documentation, demonstration
|
||||
movies, and you'll find all the details at:
|
||||
movies, and you'll find all the details at the site:
|
||||
|
||||
http://taskwarrior.org
|
||||
|
||||
At the site you'll find a wiki, discussion forums, downloads, news and more.
|
||||
|
||||
|
||||
Your contributions are especially welcome. Whether it comes in the form of
|
||||
code patches, ideas, discussion, bug reports, encouragement or criticism, your
|
||||
input is needed.
|
||||
code patches, ideas, discussion, bug reports or just encouragement, your input
|
||||
is needed.
|
||||
|
||||
Please send your support questions and code patches to:
|
||||
|
||||
|
||||
98
README.build
98
README.build
@@ -1,98 +0,0 @@
|
||||
|
||||
Task Build Notes
|
||||
----------------
|
||||
|
||||
Task 1.9 has dependencies that are detected by the configure program in almost
|
||||
all cases, but there are situations and operating systems that mean you will
|
||||
need to offer configure a little help.
|
||||
|
||||
If task will not build on your system, first take a look at the Operating System
|
||||
notes below. If this doesn't help, then go to the Troubleshooting section,
|
||||
which includes instructions on how to contact us for help.
|
||||
|
||||
|
||||
|
||||
Operating System Notes
|
||||
----------------------
|
||||
|
||||
Cygwin 1.7
|
||||
Building task on Cygwin 1.7 requires a configure option:
|
||||
|
||||
./configure --with-ncurses-inc=/usr/include/ncurses
|
||||
|
||||
This is because the ncurses include files are in a different location to
|
||||
Cygwin 1.5.
|
||||
|
||||
|
||||
Haiku Alpha/R1
|
||||
Task must be built with gcc version 4.x, so make sure you run:
|
||||
|
||||
$ setgcc gcc4
|
||||
|
||||
To switch from gcc 2.95 to gcc 4.x.
|
||||
|
||||
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
In most cases, it is sufficient to run the configure program like this:
|
||||
|
||||
$ ./configure
|
||||
|
||||
Configure will run and locate all the necessary pieces for the build, and create
|
||||
a Makefile. There may be errors and warnings when running configure, or there
|
||||
may be compiler errors and warnings when running 'make'. Sometimes you will run
|
||||
configure with no reported problems, and the build will fail later. This is
|
||||
almost always because configure is mistaken about some assumption.
|
||||
|
||||
The configure program can accept several options that help with its ability to
|
||||
locate and use the ncurses library. They are:
|
||||
|
||||
--with-ncurses
|
||||
|
||||
This option tells configure that no matter what it thinks, ncurses is
|
||||
definitely on this system and should be enabled. If needed, this option
|
||||
probable needs to be accompanied by the next two options.
|
||||
|
||||
--with-ncurses-inc=/usr/include
|
||||
|
||||
If configure cannot find ncurses header files, this option will tell it
|
||||
exactly where to look. The path specified in this example is the default,
|
||||
so that probably won't help you. The path should be the directory in which
|
||||
the file 'ncurses.h' resides. Here are some possible values to try:
|
||||
|
||||
/usr/include (the default shown above)
|
||||
/usr/include/ncurses
|
||||
/usr/local/include
|
||||
/usr/local/include/ncurses
|
||||
|
||||
This should cover most systems, but new variations keeps cropping up.
|
||||
|
||||
--with-ncurses-lib=/usr/lib
|
||||
|
||||
If configure cannot find the ncurses library, this option will tell it
|
||||
exactly where to look. The path specified in this example is the default,
|
||||
so that probably won't help you. The path should be the directory in which
|
||||
the file 'libncurses.a' (or your system's equivalent) resides. Here are
|
||||
some possible values to try:
|
||||
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
|
||||
This should cover most systems, but new variations keeps cropping up.
|
||||
|
||||
--without-ncurses
|
||||
|
||||
This disables ncurses support in task, and should really be used as a last
|
||||
resort. We know of no systems where this is needed.
|
||||
|
||||
If trying these options does not succeed, please send the contents of the
|
||||
'config.log' files to support@taskwarrior.org, or post a message in the support
|
||||
forums at taskwarrior.org along with the information.
|
||||
|
||||
If configure runs, but task does not build, when ideally you would send both the
|
||||
contents of config.log, and a transcript from the build, which is not written to
|
||||
a file, and must be captured from the terminal.
|
||||
|
||||
---
|
||||
164
configure.ac
164
configure.ac
@@ -2,20 +2,10 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.61)
|
||||
AC_INIT(task, 1.9.2, support@taskwarrior.org)
|
||||
AC_INIT(task, 1.8.0, support@taskwarrior.org)
|
||||
|
||||
|
||||
# Source type.
|
||||
AC_PROG_CXX
|
||||
AC_PROG_CC
|
||||
AC_LANG(C++)
|
||||
|
||||
|
||||
# Local copies for modification and later AC_SUBST.
|
||||
CFLAGS="${CFLAGS=}"
|
||||
CXXFLAGS="${CXXFLAGS=}"
|
||||
|
||||
|
||||
# this macro is used to get the arguments supplied
|
||||
# to the configure script (./configure --enable-debug)
|
||||
# Check if we have enable debug support.
|
||||
@@ -23,158 +13,44 @@ AC_MSG_CHECKING(whether to enable debugging)
|
||||
debug_default="no"
|
||||
AC_ARG_ENABLE(debug, [ --enable-debug=[no/yes] turn on debugging
|
||||
[default=$debug_default]],, enable_debug=$debug_default)
|
||||
|
||||
if test "x$enable_debug" = "xyes"; then
|
||||
CFLAGS="$CFLAGS -Wall -pedantic -ggdb3 -DDEBUG"
|
||||
CXXFLAGS="$CXXFLAGS -Wall -pedantic -ggdb3 -DDEBUG"
|
||||
# Yes, shell scripts can be used
|
||||
if test "$enable_debug" = "yes"; then
|
||||
CXXFLAGS="$CFLAGS -Wall -pedantic -ggdb3 -DDEBUG"
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
CFLAGS="$CFLAGS -Wall -pedantic -O3"
|
||||
CXXFLAGS="$CXXFLAGS -Wall -pedantic -O3"
|
||||
CXXFLAGS="$CFLAGS -Wall -pedantic -O3"
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
|
||||
# Check for OS.
|
||||
OS=`uname|sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'|cut -c 1-5`
|
||||
OS=`uname|sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
|
||||
if test "$OS" = "sunos"; then
|
||||
AC_MSG_NOTICE([OS Solaris detected])
|
||||
AC_DEFINE([SOLARIS], [], [Compiling on Solaris])
|
||||
elif test "$OS" = "darwi"; then
|
||||
AC_MSG_NOTICE([OS Darwin detected])
|
||||
AC_DEFINE([DARWIN], [], [Compiling on Darwin])
|
||||
elif test "$OS" = "cygwi"; then
|
||||
AC_MSG_NOTICE([OS Cygwin detected])
|
||||
AC_DEFINE([CYGWIN], [], [Compiling on Cygwin])
|
||||
elif test "$OS" = "openb"; then
|
||||
AC_MSG_NOTICE([OS OpenBSD detected])
|
||||
AC_DEFINE([OPENBSD], [], [Compiling on OpenBSD])
|
||||
elif test "$OS" = "haiku"; then
|
||||
AC_MSG_NOTICE([OS Haiku detected])
|
||||
AC_DEFINE([HAIKU], [], [Compiling on Haiku])
|
||||
elif test "$OS" = "freeb"; then
|
||||
AC_MSG_NOTICE([OS FreeBSD detected])
|
||||
AC_DEFINE([FREEBSD], [], [Compiling on FreeBSD])
|
||||
elif test "$OS" = "linux"; then
|
||||
AC_MSG_NOTICE([OS Linux detected])
|
||||
AC_DEFINE([LINUX], [], [Compiling on Linux])
|
||||
else
|
||||
AC_MSG_NOTICE([OS not detected])
|
||||
AC_DEFINE([UNKNOWN], [], [Compiling on Unknown])
|
||||
AC_MSG_NOTICE([OS Non-Solaris detected])
|
||||
AC_DEFINE([LINUX], [], [Compiling on Non-Solaris])
|
||||
fi
|
||||
|
||||
|
||||
# ncurses enabled by default.
|
||||
AC_ARG_WITH([ncurses],
|
||||
[AS_HELP_STRING([--without-ncurses], [disable support for ncurses])],
|
||||
[with_ncurses=no],
|
||||
[with_ncurses=yes])
|
||||
|
||||
AC_ARG_WITH([ncurses-inc],
|
||||
[AS_HELP_STRING ([--with-ncurses-inc=DIR], [ncurses include files are in DIR])],
|
||||
[ncurses_inc=$withval],
|
||||
[ncurses_inc=''])
|
||||
|
||||
AC_ARG_WITH([ncurses-lib],
|
||||
[AS_HELP_STRING ([--with-ncurses-lib=DIR], [ncurses lib files are in DIR])],
|
||||
[ncurses_lib=$withval],
|
||||
[ncurses_lib=''])
|
||||
|
||||
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"
|
||||
CXXFLAGS="$CXXFLAGS -I$ncurses_inc"
|
||||
fi
|
||||
|
||||
if test -n "$ncurses_lib"; then
|
||||
LDFLAGS="$LDFLAGS -L$ncurses_lib"
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB([ncurses],[main])
|
||||
fi
|
||||
|
||||
|
||||
# Readline enabled by default.
|
||||
#AC_ARG_WITH([readline],
|
||||
# [AS_HELP_STRING([--without-readline], [disable support for readline])],
|
||||
# [with_readline=no],
|
||||
# [with_readline=yes])
|
||||
#
|
||||
#AC_ARG_WITH([readline-inc],
|
||||
# [AS_HELP_STRING ([--with-readline-inc=DIR], [readline include files are in DIR])],
|
||||
# [readline_inc=$withval],
|
||||
# [readline_inc=''])
|
||||
#
|
||||
#AC_ARG_WITH([readline-lib],
|
||||
# [AS_HELP_STRING ([--with-readline-lib=DIR], [readline lib files are in DIR])],
|
||||
# [readline_lib=$withval],
|
||||
# [readline_lib=''])
|
||||
#
|
||||
#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"
|
||||
# CXXFLAGS="$CXXFLAGS -I$readline_inc"
|
||||
# fi
|
||||
#
|
||||
# if test -n "$readline_lib"; then
|
||||
# LDFLAGS="$LDFLAGS -L$readline_lib"
|
||||
# fi
|
||||
#
|
||||
# AC_CHECK_LIB([readline],[main])
|
||||
#fi
|
||||
|
||||
|
||||
# Lua disabled by default.
|
||||
AC_ARG_WITH([lua],
|
||||
[AS_HELP_STRING([--with-lua], [enable support for lua])],
|
||||
[with_lua=yes],
|
||||
[with_lua=no])
|
||||
|
||||
AC_ARG_WITH([lua-inc],
|
||||
[AS_HELP_STRING ([--with-lua-inc=DIR], [lua include files are in DIR])],
|
||||
[lua_inc=$withval],
|
||||
[lua_inc=''])
|
||||
|
||||
AC_ARG_WITH([lua-lib],
|
||||
[AS_HELP_STRING ([--with-lua-lib=DIR], [lua lib files are in DIR])],
|
||||
[lua_lib=$withval],
|
||||
[lua_lib=''])
|
||||
|
||||
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"
|
||||
CXXFLAGS="$CXXFLAGS -I$lua_inc"
|
||||
fi
|
||||
|
||||
if test -n "$lua_lib"; then
|
||||
LDFLAGS="$LDFLAGS -L$lua_lib"
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB([lua],[main])
|
||||
fi
|
||||
|
||||
|
||||
# Allow the changes above to take effect.
|
||||
AC_SUBST(CFLAGS)
|
||||
AC_SUBST(CXXFLAGS)
|
||||
AC_SUBST(LDFLAGS)
|
||||
|
||||
|
||||
# Now the smaller details.
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_CONFIG_SRCDIR([src/main.cpp])
|
||||
AC_CONFIG_HEADER([auto.h])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CXX
|
||||
AC_PROG_CC
|
||||
AC_LANG(C++)
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
|
||||
# Checks for libraries.
|
||||
AC_CHECK_LIB(ncurses,initscr)
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([stdlib.h sys/file.h sys/stat.h sys/time.h unistd.h])
|
||||
AC_CHECK_HEADERS([sstream string vector map])
|
||||
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_HEADER_STDBOOL
|
||||
AC_C_CONST
|
||||
@@ -183,19 +59,15 @@ AC_TYPE_SIZE_T
|
||||
AC_HEADER_TIME
|
||||
AC_STRUCT_TM
|
||||
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_MKTIME
|
||||
AC_FUNC_SELECT_ARGTYPES
|
||||
AC_CHECK_FUNCS([select])
|
||||
#AC_CHECK_FUNC(flock, [AC_DEFINE([HAVE_FLOCK], [1], [Found flock])])
|
||||
AC_CHECK_FUNC(uuid_unparse_lower, [AC_DEFINE([HAVE_UUID], [1], [Found uuid_unparse_lower])])
|
||||
AC_CHECK_FUNC(random, [AC_DEFINE([HAVE_RANDOM], [1], [Found random])])
|
||||
AC_CHECK_FUNC(srandom, [AC_DEFINE([HAVE_SRANDOM], [1], [Found srandom])])
|
||||
|
||||
|
||||
# Generate the Makefiles.
|
||||
AC_CONFIG_FILES([Makefile src/Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
# End.
|
||||
|
||||
|
||||
@@ -1,295 +0,0 @@
|
||||
.TH task-color 5 2010-05-22 "task 1.9.2" "User Manuals"
|
||||
|
||||
.SH NAME
|
||||
task-color \- A color tutorial for the task(1) command line todo manager.
|
||||
|
||||
.SH SETUP
|
||||
The first thing you need is a terminal program that supports color. All
|
||||
terminal programs support color, but only a few support lots of colors. First
|
||||
tell your terminal program to use color by specifying the TERM environment
|
||||
variable like this:
|
||||
|
||||
TERM=xterm-color
|
||||
|
||||
In this example, xterm-color is used - a common value, and one that doesn't
|
||||
require that you use xterm. This works for most setups. This setting belongs
|
||||
in your shell profile (~/.bash_profile, ~/.bashrc, ~/.cshrc etc, depending on
|
||||
which shell you use). If this is a new setting, you will need to either run
|
||||
that profile script, or close and reopen the terminal window (which does the
|
||||
same thing).
|
||||
|
||||
Now tell task that you want to use color. This is the default for task, so
|
||||
the following step may be unnecessary.
|
||||
|
||||
$ task config color on
|
||||
|
||||
This command will make sure there is an entry in your ~/.taskrc file that looks
|
||||
like:
|
||||
|
||||
color=on
|
||||
|
||||
Now task is ready.
|
||||
|
||||
.SH AUTOMATIC MONOCHROME
|
||||
It should be mentioned that task is aware of whether it's output is going to a
|
||||
terminal, or to a file or through a pipe. When task output goes to a terminal,
|
||||
color is desirable, but consider the following command:
|
||||
|
||||
$ task list > file.txt
|
||||
|
||||
Do we really want all those color control codes in the file? Task assumes that
|
||||
you do not, and temporarily sets color to 'off' while generating the output.
|
||||
This explains the output from the following command:
|
||||
|
||||
$ task config | grep '^color '
|
||||
color off
|
||||
|
||||
it always returns 'off', no matter what the setting.
|
||||
|
||||
The reason is that the task output gets piped into grep, and the color is
|
||||
disabled. If you wanted those color codes, you can override this behavior by
|
||||
setting the _forcecolor variable to on, like this:
|
||||
|
||||
$ task config _forcecolor on
|
||||
$ task config | grep '^color '
|
||||
color on
|
||||
|
||||
or by temporarily overriding it like this:
|
||||
|
||||
$ task rc._forcecolor=on config | grep '^color '
|
||||
color on
|
||||
|
||||
.SH AVAILABLE COLORS
|
||||
Task has a 'color' command that will show all the colors it is capable of
|
||||
displaying. Try this:
|
||||
|
||||
$ task color
|
||||
|
||||
The output cannot be replicated here in a man page, but you should see a set of
|
||||
color samples. How many you see depends on your terminal program's ability to
|
||||
render them.
|
||||
|
||||
You should at least see the Basic colors and Effects - if you do, then you have
|
||||
16-color support. If your terminal supports 256 colors, you'll know it!
|
||||
|
||||
.SH 16-COLOR SUPPORT
|
||||
The basic color support is provided through named colors:
|
||||
|
||||
black, red, blue, green, magenta, cyan, yellow, white
|
||||
|
||||
Foreground color (for text) is simply specified as one of the above colors, or
|
||||
not specified at all to use the default terminal text color.
|
||||
|
||||
Background color is specified by using the word 'on', and one of the above
|
||||
colors. Some examples:
|
||||
|
||||
green # green text, default background color
|
||||
green on yellow # green text, yellow background
|
||||
on yellow # default text color, yellow background
|
||||
|
||||
These colors can be modified further, by making the foreground bold, or by
|
||||
making the background bright. Some examples:
|
||||
|
||||
bold green
|
||||
bold white on bright red
|
||||
on bright cyan
|
||||
|
||||
The order of the words is not important, so the following are equivalent:
|
||||
|
||||
bold green
|
||||
green bold
|
||||
|
||||
But the 'on' is important - colors before the 'on' are foreground, and colors
|
||||
after 'on' are background.
|
||||
|
||||
There is an additional 'underline' attribute that may be used:
|
||||
|
||||
underline bright red on black
|
||||
|
||||
Task has a command that helps you visualize these color combinations. Try this:
|
||||
|
||||
$ task color underline bright red on black
|
||||
|
||||
You can use this command to see how the various color combinations work. You
|
||||
will also see some sample colors displayed, like the ones above, in addition to
|
||||
the sample requested.
|
||||
|
||||
Some combinations look very nice, some look terrible. Different terminal
|
||||
programs do implement slightly different versions of 'red', for example, so you
|
||||
may see some unwanted variation due to the program. The brightness of your
|
||||
display is also a factor.
|
||||
|
||||
.SH 256-COLOR SUPPORT
|
||||
|
||||
Using 256 colors follows the same form, but the names are different, and some
|
||||
colors can be referenced in different ways. First there is by color ordinal,
|
||||
which is like this:
|
||||
|
||||
color0
|
||||
color1
|
||||
color2
|
||||
...
|
||||
color255
|
||||
|
||||
This gives you access to all 256 colors, but doesn't help you much. This range
|
||||
is a combination of 8 basic colors (color0 - color7), then 8 brighter variations
|
||||
(color8 - color15). Then a block of 216 colors (color16 - color231). Then a
|
||||
block of 24 gray colors (color232 - color255).
|
||||
|
||||
The large block of 216 colors (6x6x6 = 216) represents a color cube, which can
|
||||
be addressed via RGB values from 0 to 5 for each component color. A value of 0
|
||||
means none of this component color, and a value of 5 means the most intense
|
||||
component color. For example, a bright red is specified as:
|
||||
|
||||
rgb500
|
||||
|
||||
And a darker red would be:
|
||||
|
||||
rgb300
|
||||
|
||||
Note that the three digits represent the three component values, so in this
|
||||
example the 5, 0 and 0 represent red=5, green=0, blue=0. Combining intense red
|
||||
with no green and no blue yields red. Similarly, blue and green are:
|
||||
|
||||
rgb005
|
||||
rgb050
|
||||
|
||||
Another example - bright yellow - is a mix of bright red and bright green, but
|
||||
no blue component, so bright yellow is addressed as:
|
||||
|
||||
rgb550
|
||||
|
||||
A soft pink would be addressed as:
|
||||
|
||||
rgb515
|
||||
|
||||
See if you agree, by running:
|
||||
|
||||
$ task color black on rgb515
|
||||
|
||||
You may notice that the large color block is represented as 6 squares. All
|
||||
colors in the first square have a red value of 0. All colors in the 6th square
|
||||
have a red value of 5. Within each square, blue ranges from 0 to 5 left to
|
||||
right, and within each square green ranges from 0 to 5, top to bottom. This
|
||||
scheme takes some getting used to.
|
||||
|
||||
The block of 24 gray colors can also be accessed as gray0 - gray23, in a
|
||||
continuous ramp from black to white.
|
||||
|
||||
.SH MIXING 16- AND 256-COLORS
|
||||
|
||||
If you specify 16-colors, and view on a 256-color terminal, no problem. If you
|
||||
try the reverse, specifying 256-colors and viewing on a 16-color terminal, you
|
||||
will be disappointed, perhaps even appalled.
|
||||
|
||||
There is some limited color mapping - for example, if you were to specify this
|
||||
combination:
|
||||
|
||||
red on gray3
|
||||
|
||||
you are mixing a 16-color and 256-color specification. Task will map red to
|
||||
color1, and proceed. Note that red and color1 are not quite the same.
|
||||
|
||||
Note also that there is no bold or bright attributes when dealing with 256
|
||||
colors, but there is still underline available.
|
||||
|
||||
.SH RULES
|
||||
Task supports colorization rules. These are configuration values that specify
|
||||
a color, and the conditions under which that color is used. By example, let's
|
||||
add a few tasks:
|
||||
|
||||
$ task add project:Home priority:H pay the bills (1)
|
||||
$ task add project:Home clean the rug (2)
|
||||
$ task add project:Garden clean out the garage (3)
|
||||
|
||||
We can add a color rule that uses a blue background for all tasks in the Home
|
||||
project:
|
||||
|
||||
$ task config color.project.Home on blue
|
||||
|
||||
We use quotes around "on blue" because there are two words, but they represent
|
||||
one value in the .taskrc file. Now suppose we which to use a bold yellow text
|
||||
color for all cleaning work:
|
||||
|
||||
$ task config color.keyword.clean bold yellow
|
||||
|
||||
Now what happens to task 2, which belongs to project Home (blue background), and
|
||||
is also a cleaning task (bold yellow foreground)? The colors are combined, and
|
||||
the task is shown as "bold yellow on blue".
|
||||
|
||||
Color rules can be applied by project and description keyword, as shown, and
|
||||
also by priority (or lack of priority), by active status, by being due or
|
||||
overdue, by being tagged, or having a specific tag (perhaps the most useful
|
||||
rule) or by being a recurring task.
|
||||
|
||||
It is possible to create a very colorful mix of rules. With 256-color support,
|
||||
those colors can be made subtle, and complementary, but without care, this can
|
||||
be a visual mess. Beware!
|
||||
|
||||
.SH THEMES
|
||||
Task supports themes. What this really means is that with the ability to
|
||||
include other files into the .taskrc file, different sets of color rules can
|
||||
be included.
|
||||
|
||||
To get a good idea of what a color theme looks like, try adding this entry to
|
||||
your .taskrc file:
|
||||
|
||||
.RS
|
||||
include /usr/local/share/doc/task/rc/dark-256.theme
|
||||
.RE
|
||||
|
||||
You can use any of the standard task themes:
|
||||
|
||||
.RS
|
||||
light-16.theme
|
||||
.br
|
||||
light-256.theme
|
||||
.br
|
||||
dark-16.theme
|
||||
.br
|
||||
dark-256.theme
|
||||
.br
|
||||
dark-red-256.theme
|
||||
.br
|
||||
dark-green-256.theme
|
||||
.br
|
||||
dark-blue-256.theme
|
||||
.RE
|
||||
|
||||
Better yet, create your own, and share it. We will gladly host the theme file
|
||||
on <http://taskwarrior.org>.
|
||||
|
||||
.SH "CREDITS & COPYRIGHTS"
|
||||
task was written by P. Beckingham <paul@beckingham.net>.
|
||||
.br
|
||||
Copyright (C) 2006 \- 2010 P. Beckingham
|
||||
|
||||
This man page was originally written by Paul Beckingham.
|
||||
|
||||
task is distributed under the GNU General Public License. See
|
||||
http://www.gnu.org/licenses/gpl-2.0.txt for more information.
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR task(1),
|
||||
.BR taskrc(5),
|
||||
.BR task-faq(5)
|
||||
.BR task-tutorial(5)
|
||||
|
||||
For more information regarding task, the following may be referenced:
|
||||
|
||||
.TP
|
||||
The official site at
|
||||
<http://taskwarrior.org>
|
||||
|
||||
.TP
|
||||
The official code repository at
|
||||
<git://tasktools.org/task.git/>
|
||||
|
||||
.TP
|
||||
You can contact the project by writing an email to
|
||||
<support@taskwarrior.org>
|
||||
|
||||
.SH REPORTING BUGS
|
||||
.TP
|
||||
Bugs in task may be reported to the issue-tracker at
|
||||
<http://taskwarrior.org>
|
||||
@@ -1,322 +0,0 @@
|
||||
.TH task-faq 5 2010-05-22 "task 1.9.2" "User Manuals"
|
||||
|
||||
.SH NAME
|
||||
task-faq \- A FAQ for the task(1) command line todo manager.
|
||||
|
||||
.SH DESCRIPTION
|
||||
Task is a command line TODO list manager. It maintains a list of tasks that you
|
||||
want to do, allowing you to add/remove, and otherwise manipulate them. Task
|
||||
has a rich list of commands that allow you to do various things with it.
|
||||
|
||||
.SH WELCOME
|
||||
Welcome to the task FAQ. If you have would like to see a question answered
|
||||
here, please send us a note at <support@taskwarrior.org>.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.TP
|
||||
.B Q: When I redirect the output of task to a file, I lose all the colors. How do I fix this?
|
||||
A: Task knows (or thinks it knows) when the output is not going directly to a
|
||||
terminal, and strips out all the color control characters. This is based on
|
||||
the assumption that the color control codes are not wanted in the file. Prevent
|
||||
this with the following entry in your .taskrc file:
|
||||
|
||||
_forcecolor=on
|
||||
|
||||
.TP
|
||||
.B Q: How do I backup my task data files? Where are they?
|
||||
A: Task writes all pending tasks to the file
|
||||
|
||||
~/.task/pending.data
|
||||
|
||||
and all completed and deleted tasks to
|
||||
|
||||
~/.task/completed.data
|
||||
|
||||
They are text files, so they can just be copied to another location for
|
||||
safekeeping. Don't forget there is also the ~/.taskrc file that contains your
|
||||
task configuration data. To be sure, and to future-proof your backup, consider
|
||||
backing up all the files in the ~/.task directory.
|
||||
|
||||
.TP
|
||||
.B Q: How can I separate my work tasks from my home tasks? Specifically, can I keep them completely separate?
|
||||
A: You can do this by creating an alternate .taskrc file, then using shell
|
||||
aliases. Here are example Bash commands to achieve this:
|
||||
|
||||
% cp ~/.taskrc ~/.taskrc_home
|
||||
% (now edit .taskrc_home to change the value of data.location)
|
||||
% alias wtask="task"
|
||||
% alias htask="task rc:~/.taskrc_home"
|
||||
|
||||
This gives you two commands, 'wtask' and 'htask' that operate using two
|
||||
different sets of task data files.
|
||||
|
||||
.TP
|
||||
.B Q: Can I revert to a previous version of task? How?
|
||||
A: Yes, you can revert to a previous version of task, simply by downloading an
|
||||
older version and installing it. If you find a bug in task, then this may be the
|
||||
only way to work around the bug, until a patch release is made.
|
||||
|
||||
Note that it is possible that the task file format will change. For example, the
|
||||
format changed between versions 1.5.0 and 1.6.0. Task will automatically upgrade
|
||||
the file but if you need to revert to a previous version of task, there is the
|
||||
file format to consider. This is yet another good reason to back up your task
|
||||
data files!
|
||||
|
||||
.TP
|
||||
.B Q: I'm using Ubuntu 9.04, and I want task to word-wrap descriptions. How do I do this?
|
||||
A: You need to install ncurses, by doing this:
|
||||
|
||||
% sudo apt-get install libncurses5-dev
|
||||
|
||||
Then you need to rebuild task from scratch, starting with
|
||||
|
||||
% cd task-X.X.X
|
||||
% ./configure
|
||||
...
|
||||
|
||||
The result should be a task program that knows the width of the terminal window,
|
||||
and wraps accordingly.
|
||||
|
||||
Note that there are binary packages that all include this capability.
|
||||
|
||||
.TP
|
||||
.B Q: How do I build task under Cygwin?
|
||||
A: Task is built the same way everywhere. But under Cygwin, you'll need to make
|
||||
sure you have the following packages available first:
|
||||
|
||||
gcc
|
||||
make
|
||||
libncurses-devel
|
||||
libncurses8
|
||||
|
||||
The gcc and make packages allow you to compile the code, and are therefore
|
||||
required, but the ncurses packages are optional. Ncurses will allow task to
|
||||
determine the width of the window, and therefore use the whole width and wrap
|
||||
text accordingly, for a more aesthetically pleasing display.
|
||||
|
||||
Note that there are binary packages that all include this capability.
|
||||
|
||||
.TP
|
||||
.B Q: Do colors work under Cygwin?
|
||||
A: They do, but only in a limited way. You can use regular foreground colors
|
||||
(black, red, green ...) and you can regular background colors (on_black, on_red,
|
||||
on_green ...), but underline and bold are not supported.
|
||||
|
||||
If you run the command:
|
||||
|
||||
% task colors
|
||||
|
||||
Task will display all the colors it can use, and you will see which ones you can use.
|
||||
|
||||
See the 'man task-color' for more details on which colors can be used.
|
||||
|
||||
.TP
|
||||
.B Q: Where does task store the data?
|
||||
By default, task creates a .taskrc file in your home directory and populates it
|
||||
with defaults. Task also creates a .task directory in your home directory and
|
||||
puts data files there.
|
||||
|
||||
.TP
|
||||
.B Q: Can I edit that data?
|
||||
Of course you can. It is a simple text file, and looks somewhat like the JSON
|
||||
format, and if you are careful not to break the format, there is no reason not
|
||||
to edit it. But task provides a rich command set to do that manipulation for
|
||||
you, so it is probably best to leave those files alone.
|
||||
|
||||
.TP
|
||||
.B Q: How do I restore my .taskrc file to defaults?
|
||||
If you delete (or rename) your .taskrc file, task will offer to create a default
|
||||
one for you. Another way to do this is with the command:
|
||||
|
||||
$ task rc:new-file version
|
||||
|
||||
Task will create 'new-file' if it doesn't already exist. Note that this is a
|
||||
good way to learn about new configuration settings, if your .taskrc file was
|
||||
created by an older version of task.
|
||||
|
||||
.TP
|
||||
.B Q: Do I need to back up my task data?
|
||||
Yes. You should back up your ~/.task directory, and probably your ~/.taskrc
|
||||
file too.
|
||||
|
||||
.TP
|
||||
.B Q: Can I share my tasks between different machines?
|
||||
Yes, you can. Most people have success with a DropBox - a free and secure file
|
||||
synching tool. Simply configure task to store it's data in a dropbox folder, by
|
||||
modifying the:
|
||||
|
||||
data.location=...
|
||||
|
||||
configuration variable. Check out DropBox at http://www.dropbox.com.
|
||||
|
||||
.TP
|
||||
.B Q: The undo.data file gets very large - do I need it?
|
||||
You need it if you want the undo capability. But if it gets large, you can
|
||||
certainly truncate it to save space, just be careful to delete lines from the
|
||||
top of the file, up to and including a separator '---'. The simplest way is to
|
||||
simply delete the undo.data file. Note that it does not slow down task, because
|
||||
task never reads it until you want to undo. Otherwise task only appends to the
|
||||
file.
|
||||
|
||||
.TP
|
||||
.B Q: How do I know whether my terminal support 256 colors?
|
||||
You will need to make sure your TERM environment variable is set to xterm-color,
|
||||
otherwise the easiest way is to just try it! With task 1.9 or later, you simply
|
||||
run
|
||||
|
||||
$ task color
|
||||
|
||||
and a full color palette is displayed. If you see only 8 or 16 colors, perhaps
|
||||
with those colors repeated, then your terminal does not support 256 colors.
|
||||
|
||||
See the task-color(5) man page for more details.
|
||||
|
||||
.TP
|
||||
.B Q: How do I make use of all these colors?
|
||||
See the task-color(5) man page for an in-depth explanation of the task color
|
||||
rules.
|
||||
|
||||
.TP
|
||||
.B Q: How can I make task put the command in the terminal window title?
|
||||
You cannot. But you can make the shell do it, and you can make the shell
|
||||
call the task program. Here is a Bash script that does this:
|
||||
|
||||
#! /bin/bash
|
||||
|
||||
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
|
||||
function that does the same thing:
|
||||
|
||||
t ()
|
||||
{
|
||||
printf "\\033]0;task $*\a"
|
||||
/usr/local/bin/task $*
|
||||
}
|
||||
|
||||
.TP
|
||||
.B Q: Task searches in a case-sensitive fashion - can I change that?
|
||||
You can. Just set the following value in your .taskrc file:
|
||||
|
||||
search.case.sensitive=no
|
||||
|
||||
This will affect searching for keywords:
|
||||
|
||||
$ task list Document
|
||||
|
||||
task will perform a caseless search in the description and any annotations for
|
||||
the keyword 'Document'. It also affects description and annotation
|
||||
substitutions:
|
||||
|
||||
$ task 1 /teh/the/
|
||||
|
||||
The pattern on the left will now be a caseless search term.
|
||||
|
||||
.TP
|
||||
.B Q: Why do the task ID numbers change?
|
||||
Task does this to always show you the smallest numbers it can. The idea is that
|
||||
if your tasks are numbered 1 - 33, for example, those are easy to type in. If
|
||||
instead task kept a rolling sequence number, after a while your tasks might be
|
||||
numbered 481 - 513, which makes it more likely to enter one incorrectly, because
|
||||
there are more digits.
|
||||
|
||||
When you run a report (such as "list"), task assigns the numbers before it
|
||||
displays them. For example, you can do this:
|
||||
|
||||
$ task list
|
||||
$ task do 12
|
||||
$ task add Pay the rent
|
||||
$ task delete 31
|
||||
|
||||
Those id numbers are then good until the next report is run. This is because
|
||||
task performs a garbage-collect operation on the pending tasks file when a
|
||||
report is run, which moves the deleted and completed tasks from the pending.data
|
||||
file to the completed.data file. This keeps the pending tasks file small, and
|
||||
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.
|
||||
|
||||
.TP
|
||||
.B Q: How do I delete an annotation?
|
||||
Task now has a 'denotate' command to remove annotations. First here is an
|
||||
example task:
|
||||
|
||||
$ task add Original task
|
||||
$ task 1 annotate foo
|
||||
$ task 1 annotate bar
|
||||
$ task 1 annotate foo bar
|
||||
|
||||
Now to delete the first annotation, use:
|
||||
|
||||
$ task 1 denotate foo
|
||||
|
||||
This takes the fragment 'foo' and compares it to each of the annotations. In
|
||||
this example, it will remove the first annotation, not the third, because it is
|
||||
an exact match. If there are no exact matches, it will remove the first
|
||||
non-exact match:
|
||||
|
||||
$ task 1 denotate ar
|
||||
|
||||
This will remove the second annotation - the first non-exact match.
|
||||
|
||||
.SH "CREDITS & COPYRIGHTS"
|
||||
task was written by P. Beckingham <paul@beckingham.net>.
|
||||
.br
|
||||
Copyright (C) 2006 \- 2010 P. Beckingham
|
||||
|
||||
This man page was originally written by P. Beckingham.
|
||||
|
||||
task is distributed under the GNU General Public License. See
|
||||
http://www.gnu.org/licenses/gpl-2.0.txt for more information.
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR task(1),
|
||||
.BR taskrc(5),
|
||||
.BR task-tutorial(5)
|
||||
.BR task-color(5)
|
||||
|
||||
For more information regarding task, the following may be referenced:
|
||||
|
||||
.TP
|
||||
The official site at
|
||||
<http://taskwarrior.org>
|
||||
|
||||
.TP
|
||||
The official code repository at
|
||||
<git://tasktools.org/task.git/>
|
||||
|
||||
.TP
|
||||
You can contact the project by writing an email to
|
||||
<support@taskwarrior.org>
|
||||
|
||||
.SH REPORTING BUGS
|
||||
.TP
|
||||
Bugs in task may be reported to the issue-tracker at
|
||||
<http://taskwarrior.org>
|
||||
@@ -1,17 +1,12 @@
|
||||
.TH task-tutorial 5 2010-05-22 "task 1.9.2" "User Manuals"
|
||||
.TH task-tutorial 5 2009-07-14 "Task 1.8.0" "User Manuals"
|
||||
|
||||
.SH NAME
|
||||
task-tutorial \- A tutorial for the task(1) command line todo manager.
|
||||
|
||||
.SH NOTE
|
||||
Please note that this tutorial was written for task 1.7.0. Though it is still
|
||||
accurate on the general usage of task, it might not longer be 100% correct in
|
||||
all details. A new tutorial for task is planned for task 2.0.0.
|
||||
|
||||
.SH DESCRIPTION
|
||||
Task is a command line TODO list manager. It maintains a list of tasks that you
|
||||
want to do, allowing you to add/remove, and otherwise manipulate them. Task
|
||||
has a rich list of commands that allow you to do various things with it.
|
||||
has a rich list of subcommands that allow you to do various things with it.
|
||||
|
||||
.SH 30 second tutorial
|
||||
|
||||
@@ -58,8 +53,7 @@ $ task ls
|
||||
No matches
|
||||
.RE
|
||||
|
||||
That's how easy managing your task list can be. But now consider learning what
|
||||
task can really do...
|
||||
Easy. But now consider checking out what task can really do...
|
||||
|
||||
.SH Simple usage of task
|
||||
Let us begin by adding some tasks:
|
||||
@@ -74,8 +68,8 @@ $ task add Reserve a rental car
|
||||
$ task add Reserve a hotel room
|
||||
.RE
|
||||
|
||||
You'll notice immediately that task has a very minimalist interface. Let us take
|
||||
a look at those tasks:
|
||||
That's it. You'll notice immediately that task has a very minimalist
|
||||
interface. Let us take a look at those tasks:
|
||||
.br
|
||||
.RS
|
||||
$ task ls
|
||||
@@ -102,18 +96,18 @@ $ task 2 delete
|
||||
Permanently delete task? (y/n) y
|
||||
.RE
|
||||
|
||||
Task wants you to confirm deletions. To suppress the confirmation, edit
|
||||
Task wants you to confirm deletions. To remove the confirmation, edit
|
||||
your .taskrc file and change the line:
|
||||
.br
|
||||
.RS
|
||||
confirmation=yes
|
||||
.RE
|
||||
.br
|
||||
to have a value of "no". If the entry is not there, then add it.
|
||||
to have a value of "no".
|
||||
|
||||
While the use of projects and priorities are not essential, they can be very
|
||||
useful when the list of tasks grows large. Let's assign projects to these
|
||||
tasks:
|
||||
While the use of projects and priorities are not essential to benefiting
|
||||
from task, they can be very useful when the list of tasks grows large.
|
||||
Let's assign a project to these tasks:
|
||||
.br
|
||||
.RS
|
||||
$ task 1 project:Wedding
|
||||
@@ -159,8 +153,8 @@ ID Project Pri Description
|
||||
1 Wedding Book plane ticket
|
||||
.RE
|
||||
|
||||
Task matches the leftmost part of the project when searching, so projects may be
|
||||
abbreviated:
|
||||
Task matches the leftmost part of the project when searching, so projects may
|
||||
be abbreviated:
|
||||
.br
|
||||
.RS
|
||||
$ task ls project:Wedding.Tra
|
||||
@@ -246,37 +240,20 @@ ID Project Pri Description
|
||||
2 Wedding M Reserve a rental car
|
||||
.RE
|
||||
|
||||
Notice that task supports the abbreviation of words such as priority and
|
||||
project. Priority can be abbreviated to pri, but not pr, because it is
|
||||
ambiguous. Now that tasks have been prioritized, you can see that the tasks are
|
||||
being sorted by priority, with the highest priority tasks at the top.
|
||||
Notice that task supports the abbreviation of words such as priority,
|
||||
project. Priority can be abbreviated to pri, but not pr, because it
|
||||
is ambiguous. Now that tasks have been prioritized, you can see that
|
||||
the tasks are being sorted by priority, with the highest priority
|
||||
tasks at the top.
|
||||
|
||||
These attributes can all be provided when the task is added, instead of applying
|
||||
them afterwards, as shown. The following command shows how to set all the
|
||||
attributes at once:
|
||||
These attributes can all be provided when the task is added, instead of
|
||||
applying them afterwards, as shown. The following command shows how to
|
||||
set all the attributes at once:
|
||||
.br
|
||||
.RS
|
||||
$ task add project:Wedding priority:H Book plane ticket
|
||||
.RE
|
||||
|
||||
The sequence of those arguments is not important, so you could have entered the
|
||||
following command instead:
|
||||
.br
|
||||
.RS
|
||||
$ task project:Wedding add Book plane priority:H ticket
|
||||
.RE
|
||||
|
||||
This is because task knows what attributes look like (name:value), knows what
|
||||
commands it supports (add, ...), and just assumes the rest is part of the
|
||||
description. Incidentally, if you wanted 'priority:H' to be part of your task
|
||||
description, you need to fool task into ignoring it as an attribute. That can
|
||||
be done in two ways:
|
||||
.br
|
||||
.RS
|
||||
$ task add "quoting makes task consider priority:H part of one big argument"
|
||||
$ task add -- the hyphens make task treat everything after it as description
|
||||
.RE
|
||||
|
||||
The 'ls' command provides the least information for each task. The 'list'
|
||||
command provides more:
|
||||
.br
|
||||
@@ -311,8 +288,29 @@ ID Project Pri Due Active Age Description
|
||||
2 Wedding M 7 mins Reserve a rental car
|
||||
.RE
|
||||
|
||||
Note that due tasks may be colored to highlight the importance. See the
|
||||
task-color(5) man page for full details.
|
||||
If today's date is 6/23/2008, then task 3 is due in 2 days. It will be colored
|
||||
yellow if your terminal supports color. To change this color, edit your .taskrc
|
||||
file, and change the line to one of these alternatives:
|
||||
.br
|
||||
.RS
|
||||
color.due=red
|
||||
.br
|
||||
color.due=on_blue
|
||||
.br
|
||||
color.due=red on_blue
|
||||
.br
|
||||
color.due=bold_red on_blue
|
||||
.RE
|
||||
|
||||
Where color is one of the following:
|
||||
|
||||
.br
|
||||
.RS
|
||||
black, blue, red, green, cyan, magenta, yellow or white
|
||||
.RE
|
||||
|
||||
All colors are specified in this way. Take a look in .taskrc for all the other
|
||||
color rules that you control.
|
||||
|
||||
Tagging tasks is a good way to group them, aside from specifying a project.
|
||||
To add a tag to a task:
|
||||
@@ -358,23 +356,14 @@ To remove a tag from a task, use the minus sign:
|
||||
$ task 3 \-john
|
||||
.RE
|
||||
|
||||
To add a task that you have already completed, use the log command:
|
||||
.br
|
||||
.RS
|
||||
$ task log Notify postal service
|
||||
.RE
|
||||
|
||||
This is equivalent to first adding a new task, then marking that new task
|
||||
as done. It is simple a shortcut.
|
||||
|
||||
.SH Advanced usage of task
|
||||
Advanced examples of the usage of task can be found at the official site at
|
||||
<http://taskwarrior.org>
|
||||
Advanced examples of the usage of task can be found at
|
||||
the official site at <http://taskwarrior.org>
|
||||
|
||||
.SH "CREDITS & COPYRIGHTS"
|
||||
task was written by P. Beckingham <paul@beckingham.net>.
|
||||
.br
|
||||
Copyright (C) 2006 \- 2010 P. Beckingham
|
||||
Copyright (C) 2006 \- 2009 P. Beckingham
|
||||
|
||||
This man page was originally written by Federico Hernandez.
|
||||
|
||||
@@ -383,9 +372,7 @@ http://www.gnu.org/licenses/gpl-2.0.txt for more information.
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR task(1),
|
||||
.BR taskrc(5),
|
||||
.BR task-faq(5)
|
||||
.BR task-color(5)
|
||||
.BR taskrc(5)
|
||||
|
||||
For more information regarding task, the following may be referenced:
|
||||
|
||||
@@ -395,7 +382,7 @@ The official site at
|
||||
|
||||
.TP
|
||||
The official code repository at
|
||||
<git://tasktools.org/task.git/>
|
||||
<http://github.com/pbeckingham/task/>
|
||||
|
||||
.TP
|
||||
You can contact the project by writing an email to
|
||||
|
||||
262
doc/man/task.1
262
doc/man/task.1
@@ -1,4 +1,4 @@
|
||||
.TH task 1 2010-05-22 "task 1.9.2" "User Manuals"
|
||||
.TH task 1 2009-07-14 "Task 1.8.0" "User Manuals"
|
||||
|
||||
.SH NAME
|
||||
task \- A command line todo manager.
|
||||
@@ -11,14 +11,6 @@ Task is a command line todo list manager. It maintains a list of tasks that you
|
||||
want to do, allowing you to add/remove, and otherwise manipulate them. Task
|
||||
has a rich list of subcommands that allow you to do various things with it.
|
||||
|
||||
At the core, task is a list processing program. You add text and additional
|
||||
related parameters and task redisplays the information in a nice way. It turns
|
||||
into a todo list program when you add due dates and recurrence. It turns into an
|
||||
organized todo list program when you add priorities, tags (one word descriptors),
|
||||
project groups, etc. Task turns into an organized to do list program when you
|
||||
modify the configuration file to have the output displayed the way you want to
|
||||
see it.
|
||||
|
||||
.SH SUBCOMMANDS
|
||||
|
||||
.TP
|
||||
@@ -26,148 +18,14 @@ see it.
|
||||
Adds a new task to the task list.
|
||||
|
||||
.TP
|
||||
.B log [tags] [attrs] description
|
||||
Adds a new task that is already completed, to the task list.
|
||||
.B append [tags] [attrs] description
|
||||
Appends more information to an existing
|
||||
task.
|
||||
|
||||
.TP
|
||||
.B annotate ID description
|
||||
Adds an annotation to an existing task.
|
||||
|
||||
.TP
|
||||
.B denotate ID description
|
||||
Deletes an annotation for the specified task. If the provided description matches an
|
||||
annotation exactly, the corresponding annotation is deleted. If the provided description
|
||||
matches annotations partly, the first partly matched annotation is deleted.
|
||||
|
||||
.TP
|
||||
.B info ID
|
||||
Shows all data and metadata for the specified task.
|
||||
|
||||
.TP
|
||||
.B ID
|
||||
With an ID but no specific command, task runs the "info" command.
|
||||
|
||||
.TP
|
||||
.B undo
|
||||
Reverts the most recent action.
|
||||
|
||||
.TP
|
||||
.B shell
|
||||
Launches an interactive shell with all the task commands available.
|
||||
|
||||
.TP
|
||||
.B duplicate ID [tags] [attrs] [description]
|
||||
Duplicates the specified task and allows modifications.
|
||||
|
||||
.TP
|
||||
.B delete ID
|
||||
Deletes the specified task from task list.
|
||||
|
||||
.TP
|
||||
.B start ID
|
||||
Marks the specified task as started.
|
||||
|
||||
.TP
|
||||
.B stop ID
|
||||
Removes the
|
||||
.I start
|
||||
time from the specified task.
|
||||
|
||||
.TP
|
||||
.B done ID [tags] [attrs] [description]
|
||||
Marks the specified task as done.
|
||||
|
||||
.TP
|
||||
.B projects
|
||||
Lists all project names that are currently used by pending tasks, and the
|
||||
number of tasks for each.
|
||||
|
||||
.TP
|
||||
.B tags
|
||||
Show a list of all tags used.
|
||||
|
||||
.TP
|
||||
.B summary
|
||||
Shows a report of task status by project.
|
||||
|
||||
.TP
|
||||
.B timesheet [weeks]
|
||||
Shows a weekly report of tasks completed and started.
|
||||
|
||||
.TP
|
||||
.B history
|
||||
Shows a report of task history by month. Alias to history.monthly.
|
||||
|
||||
.TP
|
||||
.B history.annual
|
||||
Shows a report of task history by year.
|
||||
|
||||
.TP
|
||||
.B ghistory
|
||||
Shows a graphical report of task status by month. Alias to ghistory.monthly.
|
||||
|
||||
.TP
|
||||
.B ghistory.annual
|
||||
Shows a graphical report of task status by year.
|
||||
|
||||
.TP
|
||||
.B calendar [ y | due [y] | month year [y] | year ]
|
||||
Shows a monthly calendar with due tasks marked.
|
||||
|
||||
.TP
|
||||
.B stats
|
||||
Shows task database statistics.
|
||||
|
||||
.TP
|
||||
.B import \fIfile
|
||||
Imports tasks from a variety of formats.
|
||||
|
||||
.TP
|
||||
.B export
|
||||
Exports all tasks in CSV format. This command is an alias to the export.csv command.
|
||||
Redirect the output to a file, if you wish to save it, or pipe it to another command.
|
||||
|
||||
.TP
|
||||
.B export.ical
|
||||
Exports all tasks in iCalendar format.
|
||||
Redirect the output to a file, if you wish to save it, or pipe it to another command.
|
||||
|
||||
.TP
|
||||
.B color [sample]
|
||||
Displays all possible colors, or a sample.
|
||||
|
||||
.TP
|
||||
.B version
|
||||
Shows the task version number
|
||||
|
||||
.TP
|
||||
.B help
|
||||
Shows the long usage text.
|
||||
|
||||
.TP
|
||||
.B show [all | substring]"
|
||||
Shows all the current settings in the task configuration file. If a substring
|
||||
is specified just the settings containing that substring will be displayed.
|
||||
|
||||
.TP
|
||||
.B config [name [value | '']]
|
||||
Add, modify and remove settings directly in the task configuration.
|
||||
This command either modifies the 'name' setting with a new value of 'value',
|
||||
or adds a new entry that is equivalent to 'name=value':
|
||||
|
||||
task config name value
|
||||
|
||||
This command sets a blank value. This has the effect of suppressing any
|
||||
default value:
|
||||
|
||||
task config name ''
|
||||
|
||||
Finally, this command removes any 'name=...' entry from the .taskrc file:
|
||||
|
||||
task config name
|
||||
|
||||
.SH MODIFYING SUBCOMMANDS
|
||||
|
||||
.TP
|
||||
.B ID [tags] [attrs] [description]
|
||||
Modifies the existing task with provided information.
|
||||
@@ -186,12 +44,91 @@ Launches an editor to let you modify all aspects of a task directly.
|
||||
Use carefully.
|
||||
|
||||
.TP
|
||||
.B append [tags] [attrs] description
|
||||
Appends information to an existing task.
|
||||
.B undo
|
||||
Reverts the most recent action.
|
||||
|
||||
.TP
|
||||
.B prepend [tags] [attrs] description
|
||||
Prepends information to an existing task.
|
||||
.B shell
|
||||
Launches an interactive shell with all the task commands available.
|
||||
|
||||
.TP
|
||||
.B duplicate ID [tags] [attrs] [description]
|
||||
Duplicates the specified task and allows modifications.
|
||||
|
||||
.TP
|
||||
.B delete ID
|
||||
Deletes the specified task from task list.
|
||||
|
||||
.TP
|
||||
.B info ID
|
||||
Shows all data and metadata for the specified task.
|
||||
|
||||
.TP
|
||||
.B start ID
|
||||
Marks the specified task as started.
|
||||
|
||||
.TP
|
||||
.B stop ID
|
||||
Removes the
|
||||
.I start
|
||||
time from the specified task.
|
||||
|
||||
.TP
|
||||
.B done ID [tags] [attrs] [description]
|
||||
Marks the specified task as done.
|
||||
|
||||
.TP
|
||||
.B projects
|
||||
Lists all project names used, and the number of tasks for each.
|
||||
|
||||
.TP
|
||||
.B tags
|
||||
Show a list of all tags used.
|
||||
|
||||
.TP
|
||||
.B summary
|
||||
Shows a report of task status by project.
|
||||
|
||||
.TP
|
||||
.B timesheet [weeks]
|
||||
Shows a weekly report of tasks completed and started.
|
||||
|
||||
.TP
|
||||
.B history
|
||||
Shows a report of task history by month.
|
||||
|
||||
.TP
|
||||
.B ghistory
|
||||
Shows a graphical report of task status by month.
|
||||
|
||||
.TP
|
||||
.B calendar [ y | due [y] | month year [y] | year ]
|
||||
Shows a monthly calendar with due tasks marked.
|
||||
|
||||
.TP
|
||||
.B stats
|
||||
Shows task database statistics.
|
||||
|
||||
.TP
|
||||
.B import \fIfile
|
||||
Imports tasks from a variety of formats.
|
||||
|
||||
.TP
|
||||
.B export \fIfile
|
||||
Exports all tasks as a CSV file.
|
||||
|
||||
.TP
|
||||
.B color
|
||||
Displays all possible colors.
|
||||
|
||||
.TP
|
||||
.B version
|
||||
Shows the task version number and current settings in the task configuration
|
||||
file.
|
||||
|
||||
.TP
|
||||
.B help
|
||||
Shows the long usage text.
|
||||
|
||||
.SH REPORT SUBCOMMANDS
|
||||
|
||||
@@ -213,13 +150,9 @@ Shows all tasks matching the specified criteria.
|
||||
Shows all tasks matching the specified criteria
|
||||
that are completed.
|
||||
|
||||
.TP
|
||||
.B minimal [tags] [attrs] [description]
|
||||
Provides a minimal listing of tasks with specified criteria.
|
||||
|
||||
.TP
|
||||
.B ls [tags] [attrs] [description]
|
||||
Provides a short listing of tasks with specified criteria.
|
||||
Provides a minimal listing of tasks with specified criteria.
|
||||
|
||||
.TP
|
||||
.B list [tags] [attrs] [description]
|
||||
@@ -301,10 +234,7 @@ Specifies background color.
|
||||
|
||||
.TP
|
||||
.B limit:<number-of-rows>
|
||||
Specifies the desired number of tasks a report should show, if a positive
|
||||
integer is given. The value 'page' may also be used, and will limit the
|
||||
report output to as many lines of text as will fit on screen. This defaults
|
||||
to 25 lines, if ncurses is not installed or enabled.
|
||||
Specifies the desired number of rows a report should have.
|
||||
|
||||
.TP
|
||||
.B wait:<wait-date>
|
||||
@@ -333,10 +263,6 @@ Attribute modifiers improve filters. Supported modifiers are:
|
||||
.B startswith (synonym left)
|
||||
.br
|
||||
.B endswith (synonym right)
|
||||
.br
|
||||
.B word
|
||||
.br
|
||||
.B noword
|
||||
.RE
|
||||
|
||||
For example:
|
||||
@@ -511,21 +437,17 @@ can be configured in the configuration file.
|
||||
.SH "CREDITS & COPYRIGHTS"
|
||||
task was written by P. Beckingham <paul@beckingham.net>.
|
||||
.br
|
||||
Copyright (C) 2006 \- 2010 P. Beckingham
|
||||
Copyright (C) 2006 \- 2009 P. Beckingham
|
||||
|
||||
This man page was originally written by P.C. Shyamshankar, and has been modified
|
||||
and supplemented by Federico Hernandez.
|
||||
|
||||
Thank also to T. Charles Yun.
|
||||
|
||||
task is distributed under the GNU General Public License. See
|
||||
http://www.gnu.org/licenses/gpl-2.0.txt for more information.
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR taskrc(5),
|
||||
.BR task-tutorial(5),
|
||||
.BR task-faq(5)
|
||||
.BR task-color(5)
|
||||
.BR task-tutorial(5)
|
||||
|
||||
For more information regarding task, the following may be referenced:
|
||||
|
||||
@@ -535,7 +457,7 @@ The official site at
|
||||
|
||||
.TP
|
||||
The official code repository at
|
||||
<git://tasktools.org/task.git/>
|
||||
<http://github.com/pbeckingham/task/>
|
||||
|
||||
.TP
|
||||
You can contact the project by writing an email to
|
||||
|
||||
606
doc/man/taskrc.5
606
doc/man/taskrc.5
@@ -1,4 +1,4 @@
|
||||
.TH taskrc 5 2010-05-22 "task 1.9.2" "User Manuals"
|
||||
.TH taskrc 5 2009-07-14 "Task 1.8.0" "User Manuals"
|
||||
|
||||
.SH NAME
|
||||
taskrc \- Configuration file for the task(1) command
|
||||
@@ -36,13 +36,11 @@ $ task rc.<name>:<value> ...
|
||||
|
||||
If
|
||||
.B task
|
||||
is run without an existing configuration file it will ask if it should create a
|
||||
default, sample
|
||||
is run without an existing configuration file it will ask if it should create a default, sample
|
||||
.I .taskrc
|
||||
file in the user's home directory.
|
||||
|
||||
The task configuration file consists of a series of "assignments" in each line.
|
||||
The "assignments" have the syntax:
|
||||
The task configuration file consists of a series of "assignments" in each line. The "assignments" have the syntax:
|
||||
|
||||
.RS
|
||||
<name-of-configuration-variable>=<value-to-be-set>
|
||||
@@ -59,69 +57,11 @@ is one of the variables described below
|
||||
is the value the variable is to be set to.
|
||||
.RE
|
||||
|
||||
and set a configuration variable to a certain value. The equal sign ("=") is
|
||||
used to separate the variable name from the value to be set.
|
||||
and set a configuration variable to a certain value. The equal sign ("=") is used to separate the variable
|
||||
name from the value to be set.
|
||||
|
||||
The hash mark, or pound sign ("#") is used as a "comment" character. It can be
|
||||
used to annotate the configuration file. All text after the character to the end
|
||||
of the line is ignored.
|
||||
|
||||
Note that task is flexible about the values used to represent Boolean items.
|
||||
You can use "on", "yes", "y", "1", "true", "t", "+", "enabled". Anything else
|
||||
means "off".
|
||||
|
||||
.SH EDITING
|
||||
You can edit your .taskrc file by hand if you wish, or you can use the 'config'
|
||||
command. To permanently set a value in your .taskrc file, use this command:
|
||||
|
||||
.RS
|
||||
$ task config nag "You have higher priority tasks!"
|
||||
.RE
|
||||
|
||||
To delete an entry, use this command:
|
||||
|
||||
.RS
|
||||
$ task config nag
|
||||
.RE
|
||||
|
||||
Task will then use the default value. To explicitly set a value to blank, and
|
||||
therefore avoid using the default value, use this command:
|
||||
|
||||
.RS
|
||||
$ task config nag ""
|
||||
.RE
|
||||
|
||||
Task will also display all your settings with this command:
|
||||
|
||||
.RS
|
||||
$ task config
|
||||
.RE
|
||||
|
||||
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.
|
||||
|
||||
There are two excellent uses of includes in your .taskrc, shown here:
|
||||
|
||||
.RS
|
||||
include /usr/local/share/doc/task/rc/holidays-US.rc
|
||||
.br
|
||||
include /usr/local/share/doc/task/rc/dark-16.theme
|
||||
.RE
|
||||
|
||||
This includes two standard files that are distributed with task, which define a
|
||||
set of US holidays, and set up a 16-color theme for task to use, to color the
|
||||
reports and calendar.
|
||||
The hash mark, or pound sign ("#") is used as a "comment" character. It can be used to annotate the
|
||||
configuration file. All text after the character to the end of the line is ignored.
|
||||
|
||||
.SH CONFIGURATION VARIABLES
|
||||
Valid variable names and their default values are:
|
||||
@@ -130,20 +70,15 @@ Valid variable names and their default values are:
|
||||
|
||||
.TP
|
||||
.B data.location=$HOME/.task
|
||||
This is a path to the directory containing all the task files. By default, it is
|
||||
set up to be ~/.task, for example: /home/paul/.task
|
||||
|
||||
Note that you can use the
|
||||
.B ~
|
||||
shell meta character, which will be properly expanded.
|
||||
This is a path to the directory containing all the task files. By default, it is set up to be ~/.task,
|
||||
for example: /home/paul/.task
|
||||
|
||||
.TP
|
||||
.B locking=on
|
||||
Determines whether task uses file locking when accessing the pending.data and
|
||||
completed.data files. Defaults to "on". Solaris users who store the task data
|
||||
files on an NFS mount may need to set locking to "off". Note that there is
|
||||
danger in setting this value to "off" - another program (or another instance of
|
||||
task) may write to the task.pending file at the same time.
|
||||
Determines whether task uses file locking when accessing the pending.data and completed.data files.
|
||||
Default to "on". Solaris users who store the task data files on an NFS mount may need to set locking
|
||||
to "off". Note that setting this value to "off" is dangerous. It means that another program may write
|
||||
to the task.pending file when task is attempting to do the same.
|
||||
|
||||
.SS TERMINAL
|
||||
.TP
|
||||
@@ -159,9 +94,9 @@ The width of tables used when ncurses support is not available. Defaults to 80.
|
||||
.B editor=vi
|
||||
Specifies which text editor you wish to use for when the
|
||||
.B task edit <ID>
|
||||
command is used. Task will first look for this configuration variable. If found,
|
||||
it is used. Otherwise task will look for the $VISUAL or $EDITOR environment
|
||||
variables, before it defaults to using "vi".
|
||||
command is used. Task will first look for this configuration variable. If found, it is used.
|
||||
Otherwise task will look for the $VISUAL or $EDITOR environment variables, before it defaults
|
||||
to using "vi".
|
||||
|
||||
.SS MISCELLANEOUS
|
||||
|
||||
@@ -174,320 +109,93 @@ locale for which there is no strings file.
|
||||
|
||||
.TP
|
||||
.B confirmation=yes
|
||||
May be "yes" or "no", and determines whether task will ask for confirmation
|
||||
before deleting a task or doing bulk changes. The default value is "yes".
|
||||
May be "yes" or "no", and determines whether task will ask for confirmation before deleting a task or doing bulk changes.
|
||||
|
||||
.TP
|
||||
.B echo.command=yes
|
||||
May be "yes" or "no", and causes task to display the ID and description of any
|
||||
task when you run the start, stop, do, undo or delete commands. The default
|
||||
value is "yes".
|
||||
|
||||
.TP
|
||||
.B annotations=full
|
||||
.TP
|
||||
.B report.X.annotations=full
|
||||
Controls the display of annotations in reports. Defaults to full - all
|
||||
annotations are displayed. Set to "sparse" only the last (newest) annotation
|
||||
is displayed and if there are more than one present for a task a "+" sign is
|
||||
added to the description. Set to "none" the output of annotations is disabled
|
||||
and a "+" sign will be added if there are any annotations present. The default
|
||||
value is "full".
|
||||
May be "yes" or "no", and causes task to display the ID and description of any task when you run the start, stop, do, undo or delete commands. The default value is "yes".
|
||||
|
||||
.TP
|
||||
.B next=2
|
||||
Is a number, defaulting to 2, which is the number of tasks for each project that
|
||||
are shown in the
|
||||
Is a number, defaulting to 2, which is the number of tasks for each project that are shown in the
|
||||
.B task next
|
||||
command.
|
||||
|
||||
.TP
|
||||
.B bulk=2
|
||||
Is a number, defaulting to 2. When more than this number of tasks are modified
|
||||
in a single command, confirmation will be required, unless the
|
||||
Is a number, defaulting to 2. When more than this number of tasks are modified in a single command, confirmation will be required, unless the
|
||||
.B confirmation
|
||||
variable is "no".
|
||||
|
||||
This is useful for preventing large-scale unintended changes.
|
||||
|
||||
.TP
|
||||
.B nag=You have higher priority tasks.
|
||||
This may be a string of text, or blank. It is used as a prompt when a task is
|
||||
started or completed that is not considered high priority. The "task next"
|
||||
command lists important tasks, and completing one of those does not generate
|
||||
this nagging. Default value is: You have higher priority tasks. It is a gentle
|
||||
reminder that you are contradicting your own priority settings.
|
||||
This may be a string of text, or blank. It is used as a prompt when a task is completed
|
||||
that is not considered high priority. The "task next" command lists important tasks, and
|
||||
completing one of those does not generate this nagging. Default value is: You have higher
|
||||
priority tasks.
|
||||
|
||||
.TP
|
||||
.B complete.all.projects=yes
|
||||
May be yes or no, and determines whether the tab completion scripts consider all
|
||||
the project names you have used, or just the ones used in active tasks. The
|
||||
default value is "no".
|
||||
|
||||
.TP
|
||||
.B list.all.projects=yes
|
||||
May be yes or no, and determines whether 'projects' command lists all the project
|
||||
names you have used, or just the ones used in active tasks. The default value is
|
||||
"no".
|
||||
May be yes or no, and determines whether the tab completion scripts consider all the
|
||||
project names you have used, or just the ones used in active tasks.
|
||||
|
||||
.TP
|
||||
.B complete.all.tags=yes
|
||||
May be yes or no, and determines whether the tab completion scripts consider all
|
||||
the tag names you have used, or just the ones used in active tasks. The default
|
||||
value is "no".
|
||||
|
||||
.TP
|
||||
.B list.all.tags=yes
|
||||
May be yes or no, and determines whether the 'tags' command lists all the tag
|
||||
names you have used, or just the ones used in active tasks. The default value is
|
||||
"no".
|
||||
|
||||
.TP
|
||||
.B search.case.sensitive=yes
|
||||
May be yes or no, and determines whether keyword lookup and substitutions on the
|
||||
description and annotations are done in a case sensitive way. Defaults to yes.
|
||||
|
||||
.TP
|
||||
.B _forcecolor=no
|
||||
Task shuts off color automatically when the output is not sent directly to a
|
||||
a TTY. For example, this command:
|
||||
|
||||
.RS
|
||||
.RS
|
||||
$ task list > file
|
||||
.RE
|
||||
|
||||
will not use any color. To override this, use:
|
||||
|
||||
.RS
|
||||
$ task rc._forcecolor=yes list > file
|
||||
.RE
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B blanklines=yes
|
||||
Turning this value off causes task to generate a more vertically compact output.
|
||||
|
||||
.TP
|
||||
.B shell.prompt=task>
|
||||
The task shell command uses this value as a prompt. You can change it to any
|
||||
string you like.
|
||||
|
||||
.TP
|
||||
.B active.indicator=*
|
||||
The character or string to show in the active column. Defaults to *.
|
||||
|
||||
.TP
|
||||
.B tag.indicator=+
|
||||
The character or string to show in the tag_indicator column. Defaults to +.
|
||||
|
||||
.TP
|
||||
.B recurrence.indicator=R
|
||||
The character or string to show in the recurrence_indicator column. Defaults to R.
|
||||
|
||||
.TP
|
||||
.B recurrence.limit=1
|
||||
The number of future recurring tasks to show. Defaults to 1. For example, if a
|
||||
weekly recurring task is added with a due date of tomorrow, and recurrence.limit
|
||||
is set to 2, then a report will list 2 pending recurring tasks, one for tomorrow,
|
||||
and one for a week from tomorrow.
|
||||
|
||||
.TP
|
||||
.B undo.style=side
|
||||
When the 'undo' command is run, task presents a before and after comparison of the
|
||||
data. This can be in either the 'side' style, which compares values side-by-side
|
||||
in a table, or 'diff' style, which uses a format similar to the 'diff' command.
|
||||
|
||||
.TP
|
||||
.B debug=off
|
||||
Task has a debug mode that causes diagnostic output to be displayed. Typically
|
||||
this is not something anyone would want, but when reporting a bug, debug output
|
||||
can be useful. It can also help explain how the command line is being parsed,
|
||||
but the information is displayed in a developer-friendly, not a user-friendly
|
||||
way.
|
||||
|
||||
.TP
|
||||
.B alias.rm=delete
|
||||
Task supports command aliases. This alias provides an alternate name (rm) for
|
||||
the delete command. You can use aliases to provide alternate names for any of
|
||||
task's commands. Several commands you may use are actually aliases - 'history',
|
||||
for example, or 'export'.
|
||||
May be yes or no, and determines whether the tab completion scripts consider all the
|
||||
tag names you have used, or just the ones used in active tasks.
|
||||
|
||||
.SS DATES
|
||||
|
||||
.TP
|
||||
.B dateformat=m/d/Y
|
||||
.TP
|
||||
.B dateformat.report=m/d/Y
|
||||
.TP
|
||||
.B dateformat.holiday=YMD
|
||||
.TP
|
||||
.B dateformat.annotation=m/d/Y
|
||||
.TP
|
||||
.B report.X.dateformat=m/d/Y
|
||||
This is a string of characters that define how task formats date values. The
|
||||
precedence order for the configuration variable is report.X.dateformat then
|
||||
reportdateformat then dateformat. While report.X.dateformat only formats the
|
||||
due date in reports, reportdateformat formats the due date both in reports
|
||||
and "task info". If both of these are not set then dateformat will be applied
|
||||
to the due date. Entered dates as well as all other displayed dates in reports
|
||||
are formatted according to dateformat.
|
||||
|
||||
The default value is: m/d/Y. The string should contain the characters:
|
||||
This is a string of characters that define how task formats dates. The default value is: m/d/Y.
|
||||
The string should contain the characters
|
||||
|
||||
.RS
|
||||
.RS
|
||||
m minimal-digit month, for example 1 or 12
|
||||
m minimal-digit month, for example 1 or 12
|
||||
.br
|
||||
d minimal-digit day, for example 1 or 30
|
||||
d minimal-digit day, for example 1 or 30
|
||||
.br
|
||||
y two-digit year, for example 09
|
||||
y two-digit year, for example 09
|
||||
.br
|
||||
D two-digit day, for example 01 or 30
|
||||
D two-digit day, for example 01 or 30
|
||||
.br
|
||||
M two-digit month, for example 01 or 12
|
||||
M two-digit month, for example 01 or 12
|
||||
.br
|
||||
Y four-digit year, for example 2009
|
||||
.br
|
||||
a short name of weekday, for example Mon or Wed
|
||||
.br
|
||||
A long name of weekday, for example Monday or Wednesday
|
||||
.br
|
||||
b short name of month, for example Jan or Aug
|
||||
.br
|
||||
B long name of month, for example January or August
|
||||
.br
|
||||
V weeknumber, for example 03 or 37
|
||||
.br
|
||||
H two-digit hour, for example 03 or 11
|
||||
.br
|
||||
N two-digit minutes, for example 05 or 42
|
||||
.br
|
||||
S two-digit seconds, for example 07 or 47
|
||||
.RE
|
||||
Y four-digit year, for example 2009
|
||||
.RE
|
||||
|
||||
.RS
|
||||
The string may also contain other characters to act as spacers, or formatting.
|
||||
Examples for other values of dateformat:
|
||||
.RE
|
||||
The string may also contain other characters to act as spacers, or formatting. Examples for other
|
||||
variable values:
|
||||
|
||||
.RS
|
||||
.RS
|
||||
.br
|
||||
d/m/Y would use for input and output 24/7/2009
|
||||
d/m/Y would output 24/7/2009
|
||||
.br
|
||||
yMD would use for input and output 090724
|
||||
YMD would output 20090724
|
||||
.br
|
||||
M-D-Y would use for input and output 07-24-2009
|
||||
.RE
|
||||
.RE
|
||||
|
||||
.RS
|
||||
Examples for other values of reportdateformat:
|
||||
.RE
|
||||
|
||||
.RS
|
||||
.RS
|
||||
.br
|
||||
a D b Y (V) would do an output as "Fri 24 Jul 2009 (30)"
|
||||
.br
|
||||
A, B D, Y would do an output as "Friday, July 24, 2009"
|
||||
.br
|
||||
vV a Y-M-D would do an output as "v30 Fri 2009-07.24"
|
||||
.RE
|
||||
m-d-y would output 07-24-09
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B weekstart=Sunday
|
||||
Determines the day a week starts. Valid values are Sunday or Monday only. The
|
||||
default value is "Sunday".
|
||||
Determines the day a week starts. Valid values are Sunday or Monday only.
|
||||
|
||||
.TP
|
||||
.B displayweeknumber=yes
|
||||
Determines if week numbers are displayed when using the "task calendar" command.
|
||||
The week number is dependent on the day a week starts. The default value is
|
||||
"yes".
|
||||
The week number is dependent on the day a week starts.
|
||||
|
||||
.TP
|
||||
.B due=7
|
||||
This is the number of days into the future that define when a task is
|
||||
considered due, and is colored accordingly. The default value is 7.
|
||||
This is the number of days into the future that define when a task is considered due,
|
||||
and is colored accordingly. Defaults to 7.
|
||||
|
||||
.TP
|
||||
.B calendar.details=sparse
|
||||
If set to full running "task calendar" will display the details of tasks with
|
||||
due dates that fall into the calendar period. The corresponding days will be
|
||||
color-coded in the calendar. If set to sparse only the corresponding days will
|
||||
be color coded and no details will be displayed. The displaying of due dates
|
||||
with details is turned off by setting the variable to none. The default value
|
||||
is "sparse".
|
||||
|
||||
.TP
|
||||
.B calendar.details.report=list
|
||||
The report to run when displaying the details of tasks with due date when
|
||||
running the "task calendar" command. The default value is "list".
|
||||
|
||||
.TP
|
||||
.B calendar.holidays=full
|
||||
If set to full running "task calendar" will display holidays in the calendar by
|
||||
color-coding the corresponding days. A detailed list with the dates and names
|
||||
of the holidays is also shown. If set to sparse only the days are color-coded
|
||||
and no details on the holidays will be displayed. The displaying of holidays is
|
||||
turned off by setting the variable to none. The default value is "none".
|
||||
|
||||
.TP
|
||||
.B Holidays
|
||||
Holidays are entered either directly in the .taskrc file or via an include file
|
||||
that is specified in .taskrc. For each holiday the name and the date is
|
||||
required to be given:
|
||||
|
||||
.RS
|
||||
.RS
|
||||
.br
|
||||
holiday.towel.name=Day of the towel
|
||||
.br
|
||||
holiday.towel.date=20100525
|
||||
.br
|
||||
holiday.sysadmin.name=System Administrator Appreciation Day
|
||||
.br
|
||||
holiday.sysadmin.date=20100730
|
||||
.RE
|
||||
.RE
|
||||
|
||||
.RS
|
||||
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
|
||||
|
||||
Note that the task distribution contains example holiday files that can be
|
||||
included like this:
|
||||
|
||||
.RS
|
||||
.RS
|
||||
.br
|
||||
include /usr/local/share/doc/task/rc/holidays-US.rc
|
||||
.RE
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B monthsperline=3
|
||||
Determines how many months the "task calendar" command renders across the
|
||||
screen. Defaults to however many will fit. If more months than will fit are
|
||||
specified, task will only show as many that will fit.
|
||||
.B monthsperline=2
|
||||
Determines how many months the "task calendar" command renders across the screen.
|
||||
Defaults to however many will fit. If more months that will fit are specified,
|
||||
task will only show as many that will fit.
|
||||
|
||||
.SS COLOR CONTROLS
|
||||
|
||||
@@ -499,13 +207,12 @@ use dashes (-----) to underline column headings.
|
||||
.TP
|
||||
.B fontunderline=on
|
||||
Determines if font underlines or ASCII dashes should be used to underline
|
||||
headers, even when color is enabled.
|
||||
.RE
|
||||
headers.
|
||||
|
||||
Task has a number of coloration rules. They correspond to a particular
|
||||
attribute of a task, such as it being due, or being active, and specifies the
|
||||
automatic coloring of that task. A list of valid colors, depending on your
|
||||
terminal, can be obtained by running the command:
|
||||
Task has a number of coloration rules. They correspond to a particular attribute
|
||||
of a task, such as it being due, or being active, and specifies the automatic
|
||||
coloring of that task. A list of valid color, depending on your terminal, can be
|
||||
obtained by running the command
|
||||
|
||||
.RS
|
||||
.B task color
|
||||
@@ -516,166 +223,87 @@ The coloration rules and their defaults are:
|
||||
.RE
|
||||
|
||||
.RS
|
||||
.B color.overdue=bold red
|
||||
.RS
|
||||
.B color.overdue=bold_red
|
||||
The color for overdue tasks.
|
||||
.br
|
||||
.B color.due.today=bold magenta
|
||||
The color of tasks due today.
|
||||
.br
|
||||
.B color.due=bold yellow
|
||||
.B color.due=bold_yellow
|
||||
The color of due tasks.
|
||||
.br
|
||||
.B color.pri.H=bold
|
||||
The color of priority:H tasks.
|
||||
.br
|
||||
.B color.pri.M=on yellow
|
||||
The color of priority:M tasks. No default value.
|
||||
.B color.pri.M=on_yellow
|
||||
The color of priority:M tasks.
|
||||
.br
|
||||
.B color.pri.L=on green
|
||||
The color of priority:L tasks. No default value.
|
||||
.B color.pri.L=on_green
|
||||
The color of priority:L tasks.
|
||||
.br
|
||||
.B color.pri.none=white on blue
|
||||
The color of priority: tasks. No default value.
|
||||
.B color.pri.none=white on_blue
|
||||
The color of priority: tasks.
|
||||
.br
|
||||
.B color.active=bold cyan
|
||||
.B color.active=bold_cyan
|
||||
The color of active tasks.
|
||||
.br
|
||||
.B color.tagged=yellow
|
||||
The color of tagged tasks.
|
||||
.br
|
||||
.B color.recurring=on red
|
||||
.B color.recurring=on_red
|
||||
The color for recurring tasks.
|
||||
.RE
|
||||
.RE
|
||||
|
||||
.RS
|
||||
To disable a coloration rule for which there is a default, set the value to
|
||||
nothing, for example:
|
||||
The value for the coloration rules may be one optional foreground color and one optional
|
||||
color. For example, the value may be
|
||||
.RE
|
||||
|
||||
.RS
|
||||
.B color.tagged=
|
||||
.RS
|
||||
bold_red on_bright_yellow
|
||||
.RE
|
||||
.RE
|
||||
|
||||
See the task-color(5) man pages for color details.
|
||||
.RE
|
||||
|
||||
Certain attributes like tags, projects and keywords can have their own
|
||||
coloration rules.
|
||||
.RS
|
||||
Certain attributes like tags, projects and keywords can also have their own coloration rules.
|
||||
.RE
|
||||
|
||||
.RS
|
||||
.TP
|
||||
.B color.tag.X=yellow
|
||||
Colors any task that has the tag X.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.project.X=on green
|
||||
.B color.project.X=on_green
|
||||
Colors any task assigned to project X.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.keyword.X=on blue
|
||||
Colors any task where the description or any annotation contains X.
|
||||
.RE
|
||||
.B color.keyword.X=on_blue
|
||||
Colors any task where the description contains X.
|
||||
|
||||
.TP
|
||||
.B color.header=green
|
||||
Colors any of the messages printed prior to the report output.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.message=green
|
||||
Colors any of the messages printed after the report output.
|
||||
|
||||
.TP
|
||||
.B color.footnote=green
|
||||
Colors any of the messages printed last.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.summary.bar=on green
|
||||
Colors the summary progress bar. Should consist of a background color.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.summary.background=on black
|
||||
Colors the summary progress bar. Should consist of a background color.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.calendar.today=black on cyan
|
||||
Color of today in calendar.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.calendar.due=black on green
|
||||
Color of days with due tasks in calendar.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.calendar.due.today=black on magenta
|
||||
Color of today with due tasks in calendar.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.calendar.overdue=black on red
|
||||
Color of days with overdue tasks in calendar.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.calendar.weekend=bright white on black
|
||||
Color of weekend days in calendar.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.calendar.holiday=black on bright yellow
|
||||
Color of holidays in calendar.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.calendar.weeknumber=black on white
|
||||
Color of weeknumbers in calendar.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.alternate=on rgb253
|
||||
Color of alternate tasks.
|
||||
This is to apply a specific color to every other task in a report,
|
||||
which can make it easier to visually separate tasks. This is especially
|
||||
useful when tasks are displayed over multiple lines due to long descriptions
|
||||
or annotations.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.history.add=on red
|
||||
.RE
|
||||
.br
|
||||
.B color.history.done=on green
|
||||
.RE
|
||||
.br
|
||||
.B color.history.delete=on yellow
|
||||
.RS
|
||||
Colors the bars on the ghistory report graphs. Defaults to red, green and
|
||||
yellow bars.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B color.undo.before=red
|
||||
.RE
|
||||
.br
|
||||
.B color.undo.after=green
|
||||
.RS
|
||||
Colors used by the undo command, to indicate the values both before and after
|
||||
a change that is to be reverted.
|
||||
.RE
|
||||
|
||||
.SS SHADOW FILE
|
||||
|
||||
.TP
|
||||
.B
|
||||
shadow.file=$HOME/.task/shadow.txt
|
||||
If specified, designates a file path that will be automatically written to by
|
||||
task, whenever the task database changes. In other words, it is automatically
|
||||
kept up to date. The shadow.command configuration variable is used to determine
|
||||
which report is written to the shadow file. There is no color used in the
|
||||
shadow file. This feature can be useful in maintaining a current file for use by
|
||||
programs like GeekTool, Conky or Samurize.
|
||||
If specified, designates a file path that will be automatically written to by task,
|
||||
whenever the task database changes. In other words, it is automatically kept up to date.
|
||||
The shadow.command configuration variable is used to determine which report is written
|
||||
to the shadow file. There is no color used in the shadow file. This feature can be useful
|
||||
in maintaining a current file for use by programs like GeekTool, Conky or Samurize.
|
||||
|
||||
.TP
|
||||
.B
|
||||
@@ -699,20 +327,20 @@ file is updated by some task command.
|
||||
default.project=foo
|
||||
Provides a default project name for the
|
||||
.I task add
|
||||
command, if you don't specify one. The default is blank.
|
||||
command.
|
||||
|
||||
.TP
|
||||
.B
|
||||
default.priority=M
|
||||
Provides a default priority for the
|
||||
.I task add
|
||||
command, if you don't specify one. The default is blank.
|
||||
command.
|
||||
|
||||
.TP
|
||||
.B
|
||||
default.command=list
|
||||
Provides a default command that is run every time task is invoked with no
|
||||
arguments. For example, if set to:
|
||||
Provides a default command that is run every time task is invoked with no arguments.
|
||||
For example, if set to:
|
||||
|
||||
.RS
|
||||
.RS
|
||||
@@ -721,8 +349,8 @@ default.command=list project:foo
|
||||
.RE
|
||||
|
||||
.RS
|
||||
then task will run the "list project:foo" command if no command is specified.
|
||||
This means that by merely typing
|
||||
then task will run the "list project:foo" command if no command is specified. This means that
|
||||
by merely typing
|
||||
.RE
|
||||
|
||||
.RS
|
||||
@@ -756,41 +384,24 @@ The description for report X when running the "task help" command.
|
||||
.TP
|
||||
.B report.X.columns
|
||||
The columns that will be used when generating the report X. Valid columns are:
|
||||
id, uuid, project, priority, entry, start, due, recur, recur_indicator, age,
|
||||
age_compact, active, tags, tag_indicator, description, description_only,
|
||||
countdown, countdown_compact.
|
||||
The IDs are separated by commas.
|
||||
id, uuid, project, priority, entry, start, due, recur, recur_ind, age, age_compact,
|
||||
active, tags, description, description_only. The IDs are separated by commas.
|
||||
|
||||
.TP
|
||||
.B report.X.labels
|
||||
The labels for each column that will be used when generating report X. The
|
||||
labels are a comma separated list.
|
||||
The labels for each column that will be used when generating report X. The labels
|
||||
are a comma separated list.
|
||||
|
||||
.TP
|
||||
.B report.X.sort
|
||||
The sort order of the tasks in the generated report X. The sort order is
|
||||
specified by using the column ids post-fixed by a "+" for ascending sort order
|
||||
or a "-" for descending sort order. The sort IDs are separated by commas
|
||||
The sort order of the tasks in the generated report X. The sort order is specified
|
||||
by using the column ids post-fixed by a "+" for ascending sort order or a "-" for
|
||||
descending sort order. The sort IDs are separated by commas
|
||||
|
||||
.TP
|
||||
.B report.X.filter
|
||||
This adds a filter to the report X so that only tasks matching the filter
|
||||
criteria are displayed in the generated report.
|
||||
|
||||
.TP
|
||||
.B report.X.dateformat
|
||||
This adds a dateformat to the report X that will be used by the "due date"
|
||||
column. If it is not set then reportdateformat and dateformat will be used in
|
||||
this order. See the
|
||||
.B DATES
|
||||
section for details on the sequence placeholders.
|
||||
|
||||
.TP
|
||||
.B report.X.annotations
|
||||
This adds the possibility to control the output of annotations for a task in a
|
||||
report. See the
|
||||
.B annotations
|
||||
variable for details on the possible values.
|
||||
This adds a filter to the report X so that only tasks matching the filter criteria
|
||||
are displayed in the generated report.
|
||||
|
||||
.TP
|
||||
.B report.X.limit
|
||||
@@ -798,8 +409,7 @@ An optional value to a report limiting the number of displayed tasks in the
|
||||
generated report.
|
||||
|
||||
.TP
|
||||
Task comes with a number of predefined reports in its default configuration
|
||||
file. These reports are:
|
||||
Task comes with a number of predefined reports in its default configuration file. These reports are:
|
||||
|
||||
.TP
|
||||
.B long
|
||||
@@ -811,10 +421,6 @@ Lists all tasks matching the specified criteria.
|
||||
|
||||
.TP
|
||||
.B ls
|
||||
Short listing of all tasks matching the specified criteria.
|
||||
|
||||
.TP
|
||||
.B minimal
|
||||
Minimal listing of all tasks matching the specified criteria.
|
||||
|
||||
.TP
|
||||
@@ -856,7 +462,7 @@ Lists all tasks with upcoming due dates matching the specified criteria.
|
||||
.SH "CREDITS & COPYRIGHTS"
|
||||
task was written by P. Beckingham <paul@beckingham.net>.
|
||||
.br
|
||||
Copyright (C) 2006 \- 2010 P. Beckingham
|
||||
Copyright (C) 2006 \- 2009 P. Beckingham
|
||||
|
||||
This man page was originally written by Federico Hernandez.
|
||||
|
||||
@@ -865,9 +471,7 @@ http://www.gnu.org/licenses/gpl-2.0.txt for more information.
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR task(1),
|
||||
.BR task-tutorial(5),
|
||||
.BR task-faq(5)
|
||||
.BR task-color(5)
|
||||
.BR task-tutorial(5)
|
||||
|
||||
For more information regarding task, the following may be referenced:
|
||||
|
||||
@@ -877,7 +481,7 @@ The official site at
|
||||
|
||||
.TP
|
||||
The official code repository at
|
||||
<git://tasktools.org/task.git/>
|
||||
<http://github.com/pbeckingham/task/>
|
||||
|
||||
.TP
|
||||
You can contact the project by writing an email to
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
Hello. This is a demonstration of the
|
||||
task program color capabilities coming
|
||||
in version 1.9.
|
||||
|
||||
task color The color command shows the various
|
||||
supported colors. For this you will
|
||||
need an xterm with 256-color support,
|
||||
or an equivalent.
|
||||
|
||||
This demo uses iTerm running on Snow
|
||||
Leopard.
|
||||
|
||||
task add Prepare 1.9 for release Let's create a few tasks, to illustrate
|
||||
task add Update the various docs the features. Five should be enough.
|
||||
task add Run the regression tests
|
||||
task add Make the packages
|
||||
task add Upload to distributions
|
||||
|
||||
--- NOTES
|
||||
|
||||
16-color mode
|
||||
upgrade
|
||||
blending
|
||||
alternate lines
|
||||
|
||||
--- NOTES
|
||||
|
||||
task ls Okay, let's color any tasks that
|
||||
mention tests a nice medium blue.
|
||||
|
||||
echo 'color.keyword.test=color23' >> ~/.taskrc
|
||||
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
$ # Q: What is a formatting hook?
|
||||
$ # A: Lua code that modifies task output at run time.
|
||||
$
|
||||
$ cat > hooks.lua
|
||||
|
||||
-- Make ID not show up
|
||||
function id (name, value)
|
||||
return "(shhh - it's a secret)", 0, nil
|
||||
end
|
||||
|
||||
-- Decorate the UUID
|
||||
function uuid (name, value)
|
||||
return '<<<' .. value .. '>>>', 0, nil
|
||||
end
|
||||
|
||||
^D
|
||||
|
||||
$ # Q: What is a command hook?
|
||||
$ # A: Lua code that changes the way commands work.
|
||||
$
|
||||
$ cat >> hooks.lua
|
||||
|
||||
-- Disable tags
|
||||
function notags ()
|
||||
return 1, 'Tags have been disabled'
|
||||
end
|
||||
|
||||
^D
|
||||
|
||||
$
|
||||
$ task config -- hook.format-id ~/demo/hooks.lua:id
|
||||
$ task config -- hook.format-uuid ~/demo/hooks.lua:uuid
|
||||
$ task config -- hook.pre-tag ~/demo/hooks.lua:notags
|
||||
$ task list
|
||||
$ task add Demonstrate formatting hooks
|
||||
$ task 1 info
|
||||
$ task config hooks on
|
||||
$ task 1 info
|
||||
$ task 1 +try_to_tag
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
$
|
||||
$ # Task now has Lua 5.1.4 built in.
|
||||
$
|
||||
$ task version
|
||||
$ cat > hooks.lua
|
||||
function foo ()
|
||||
print ("Hello from Lua")
|
||||
return 0, nil
|
||||
end
|
||||
^D
|
||||
$
|
||||
$ # Task can call into Lua at many points during execution.
|
||||
$ # This one is called immediately before task quits.
|
||||
$
|
||||
$ task rc.hook.pre-exit=~/hooks.lua:foo version
|
||||
$
|
||||
$ # While task is calling Lua code, the Lua can also call
|
||||
$ # back into a task API, for information.
|
||||
$
|
||||
$ cat > hooks.lua
|
||||
function foo ()
|
||||
print "Lua version is " .. task_lua_version ())
|
||||
print "Task version is " .. task_version ())
|
||||
return 0, nil
|
||||
end
|
||||
^D
|
||||
$
|
||||
$ cat >> .taskrc
|
||||
hook.pre-exit=~/hooks.lua:foo
|
||||
^D
|
||||
$
|
||||
$ task version
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# Sample task 1.9 (or later) dark 16-color theme
|
||||
|
||||
color=on
|
||||
color.header=yellow
|
||||
color.footnote=yellow
|
||||
color.debug=yellow
|
||||
|
||||
color.summary.bar=on green
|
||||
color.summary.background=on black
|
||||
|
||||
color.history.add=black on red
|
||||
color.history.done=black on green
|
||||
color.history.delete=black on yellow
|
||||
|
||||
color.undo.before=red
|
||||
color.undo.after=green
|
||||
|
||||
color.calendar.today=bold white on bright blue
|
||||
color.calendar.due=white on red
|
||||
color.calendar.due.today=bold white on red
|
||||
color.calendar.overdue=black on bright red
|
||||
color.calendar.weekend=white on bright black
|
||||
color.calendar.holiday=black on bright yellow
|
||||
color.calendar.weeknumber=bold blue
|
||||
|
||||
color.recurring=magenta
|
||||
color.overdue=bold red
|
||||
color.due.today=red
|
||||
color.due=red
|
||||
color.active=black on bright green
|
||||
color.pri.none=
|
||||
color.pri.H=bold white
|
||||
color.pri.M=white
|
||||
color.pri.L=
|
||||
color.tagged=green
|
||||
color.alternate=
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# Sample task 1.9 (or later) dark 256-color theme
|
||||
|
||||
color=on
|
||||
color.header=color3
|
||||
color.footnote=color3
|
||||
color.debug=color3
|
||||
|
||||
color.summary.bar=on rgb141
|
||||
color.summary.background=on color0
|
||||
|
||||
color.history.add=color0 on rgb500
|
||||
color.history.done=color0 on rgb050
|
||||
color.history.delete=color0 on rgb550
|
||||
|
||||
color.undo.before=color1
|
||||
color.undo.after=color2
|
||||
|
||||
color.calendar.today=color15 on rgb013
|
||||
color.calendar.due=color0 on color1
|
||||
color.calendar.due.today=color15 on color1
|
||||
color.calendar.overdue=color0 on color9
|
||||
color.calendar.weekend=on color235
|
||||
color.calendar.holiday=color0 on color11
|
||||
color.calendar.weeknumber=rgb013
|
||||
|
||||
color.recurring=rgb013
|
||||
color.overdue=color9
|
||||
color.due.today=rgb400
|
||||
color.due=color1
|
||||
color.active=rgb555 on rgb410
|
||||
color.pri.none=
|
||||
color.pri.H=color255
|
||||
color.pri.M=color250
|
||||
color.pri.L=color245
|
||||
color.tagged=rgb031
|
||||
color.alternate=on color233
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# Sample task 1.9 (or later) dark 256-color theme, featuring blue.
|
||||
|
||||
color=on
|
||||
color.header=rgb013
|
||||
color.footnote=rgb013
|
||||
color.debug=rgb013
|
||||
|
||||
color.summary.bar=on rgb003
|
||||
color.summary.background=on color0
|
||||
|
||||
color.history.add=color0 on rgb015
|
||||
color.history.done=color0 on rgb025
|
||||
color.history.delete=color0 on rgb035
|
||||
|
||||
color.undo.before=rgb013
|
||||
color.undo.after=rgb035
|
||||
|
||||
color.calendar.today=color0 on rgb115
|
||||
color.calendar.due=color0 on color249
|
||||
color.calendar.due.today=color0 on color252
|
||||
color.calendar.overdue=color0 on color255
|
||||
color.calendar.weekend=on color235
|
||||
color.calendar.holiday=color255 on rgb013
|
||||
color.calendar.weeknumber=rgb015
|
||||
|
||||
color.recurring=rgb115
|
||||
color.overdue=color255
|
||||
color.due.today=color252
|
||||
color.due=color249
|
||||
color.active=rgb045 on rgb015
|
||||
color.pri.none=
|
||||
color.pri.H=rgb035
|
||||
color.pri.M=rgb025
|
||||
color.pri.L=rgb015
|
||||
color.tagged=color246
|
||||
color.alternate=on color233
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# Sample task 1.9 (or later) dark 256-color theme, featuring green.
|
||||
|
||||
color=on
|
||||
color.header=rgb031
|
||||
color.footnote=rgb031
|
||||
color.debug=rgb031
|
||||
|
||||
color.summary.bar=on rgb030
|
||||
color.summary.background=on color0
|
||||
|
||||
color.history.add=color0 on rgb010
|
||||
color.history.done=color0 on rgb030
|
||||
color.history.delete=color0 on rgb050
|
||||
|
||||
color.undo.before=rgb031
|
||||
color.undo.after=rgb053
|
||||
|
||||
color.calendar.today=color0 on rgb151
|
||||
color.calendar.due=color0 on color249
|
||||
color.calendar.due.today=color0 on color225
|
||||
color.calendar.overdue=color0 on color255
|
||||
color.calendar.weekend=on color235
|
||||
color.calendar.holiday=rgb151 on rgb020
|
||||
color.calendar.weeknumber=rgb010
|
||||
|
||||
color.recurring=rgb151
|
||||
color.overdue=color255
|
||||
color.due.today=color252
|
||||
color.due=color249
|
||||
color.active=rgb050 on rgb010
|
||||
color.pri.none=
|
||||
color.pri.H=rgb050
|
||||
color.pri.M=rgb030
|
||||
color.pri.L=rgb010
|
||||
color.tagged=color246
|
||||
color.alternate=on color233
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# Sample task 1.9 (or later) dark 256-color theme, featuring red.
|
||||
|
||||
color=on
|
||||
color.header=rgb100
|
||||
color.footnote=rgb100
|
||||
color.debug=rgb100
|
||||
|
||||
color.summary.bar=on rgb300
|
||||
color.summary.background=on color0
|
||||
|
||||
color.history.add=color0 on rgb100
|
||||
color.history.done=color0 on rgb300
|
||||
color.history.delete=color0 on rgb500
|
||||
|
||||
color.undo.before=rgb301
|
||||
color.undo.after=rgb503
|
||||
|
||||
color.calendar.today=color0 on rgb511
|
||||
color.calendar.due=color0 on color249
|
||||
color.calendar.due.today=color0 on color252
|
||||
color.calendar.overdue=color0 on color255
|
||||
color.calendar.weekend=on color235
|
||||
color.calendar.holiday=rgb522 on rgb300
|
||||
color.calendar.weeknumber=rgb100
|
||||
|
||||
color.recurring=rgb511
|
||||
color.overdue=color255
|
||||
color.due.today=color252
|
||||
color.due=color249
|
||||
color.active=rgb500 on rgb100
|
||||
color.pri.none=
|
||||
color.pri.H=rgb500
|
||||
color.pri.M=rgb400
|
||||
color.pri.L=rgb300
|
||||
color.tagged=color246
|
||||
color.alternate=on color233
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
calendar.holidays=sparse
|
||||
|
||||
holiday.nyårsdagen.name=Nyårsdagen
|
||||
holiday.nyårsdagen.date=20100101
|
||||
holiday.trettondedagjul.name=Trettondedag jul
|
||||
holiday.trettondedagjul.date=20100106
|
||||
holiday.långfredagen.name=Långfredagen
|
||||
holiday.långfredagen.date=20100402
|
||||
holiday.påskdagen.name=Påskdagen
|
||||
holiday.påskdagen.date=20100404
|
||||
holiday.annandagpåsk.name=Annandag påsk
|
||||
holiday.annandagpåsk.date=20100405
|
||||
holiday.valborgmässoafton.name=Valborgmässoafton
|
||||
holiday.valborgmässoafton.date=20100430
|
||||
holiday.förstamaj.name=Första maj
|
||||
holiday.förstamaj.date=20100501
|
||||
holiday.kristihimmelfärdsdag.name=Kristi Himmelsfärdsdag
|
||||
holiday.kristihimmelfärdsdag.date=20100513
|
||||
holiday.pingstdagen.name=Pingstdagen
|
||||
holiday.pingstdagen.date=20100523
|
||||
holiday.nationaldagen.name=Nationaldagen
|
||||
holiday.nationaldagen.date=20100606
|
||||
holiday.midsommarafton.name=Midsommarafton
|
||||
holiday.midsommarafton.date=20100625
|
||||
holiday.midsommardagen.name=Midsommardagen
|
||||
holiday.midsommardagen.date=20100626
|
||||
holiday.allahelgonsdag.name=Alla Helgons Dag
|
||||
holiday.allahelgonsdag.date=20101106
|
||||
holiday.julafton.name=Julafton
|
||||
holiday.julafton.date=20101224
|
||||
holiday.juldagen.name=Juldagen
|
||||
holiday.juldagen.date=20101225
|
||||
holiday.annandagjul.name=Annandag jul
|
||||
holiday.annandagjul.date=20101226
|
||||
holiday.nyårsafton.name=Nyårsafton
|
||||
holiday.nyårsafton.date=20101231
|
||||
@@ -1,28 +0,0 @@
|
||||
calendar.holidays=sparse
|
||||
|
||||
holiday.newyearsday.name=New Years Day
|
||||
holiday.newyearsday.date=20100101
|
||||
holiday.martinlutherkingday.name=Martin Luther King Day
|
||||
holiday.martinlutherkingday.date=20100118
|
||||
holiday.presidentsday.name=Presidents Day
|
||||
holiday.presidentsday.date=20100215
|
||||
holiday.patriotsday.name=Patriots Day
|
||||
holiday.patriotsday.date=20100419
|
||||
holiday.memorialday.name=Memorial Day
|
||||
holiday.memorialday.date=20100531
|
||||
holiday.independenceday.name=Independence Day
|
||||
holiday.independenceday.date=20100704
|
||||
holiday.independenceday2.name=Independence Day observed
|
||||
holiday.independenceday2.date=20100705
|
||||
holiday.laborday.name=Labor Day
|
||||
holiday.laborday.date=20100906
|
||||
holiday.columbusday.name=Columbus Day
|
||||
holiday.columbusday.date=20101011
|
||||
holiday.veteransdays.name=Veterans Day
|
||||
holiday.veteransdays.date=20101111
|
||||
holiday.thanksgiving.name=Thanksgiving Day
|
||||
holiday.thanksgiving.date=20101125
|
||||
holiday.christmasday.name=Christmas Day
|
||||
holiday.christmasday.date=20101225
|
||||
holiday.newyearseve.name=New Years Eve
|
||||
holiday.newyearseve.date=20101231
|
||||
@@ -1,37 +0,0 @@
|
||||
# Sample task 1.9 (or later) light 16-color theme
|
||||
|
||||
color=on
|
||||
color.header=blue
|
||||
color.footnote=blue
|
||||
color.debug=blue
|
||||
|
||||
color.summary.bar=on green
|
||||
color.summary.background=on black
|
||||
|
||||
color.history.add=black on red
|
||||
color.history.done=black on green
|
||||
color.history.delete=black on yellow
|
||||
|
||||
color.undo.before=red
|
||||
color.undo.after=green
|
||||
|
||||
color.calendar.today=black on bright blue
|
||||
color.calendar.due=white on red
|
||||
color.calendar.due.today=bold white on red
|
||||
color.calendar.overdue=black on bright red
|
||||
color.calendar.weekend=white on bright black
|
||||
color.calendar.holiday=black on yellow
|
||||
color.calendar.weeknumber=bold blue
|
||||
|
||||
color.recurring=blue
|
||||
color.overdue=bold red
|
||||
color.due.today=red
|
||||
color.due=red
|
||||
color.active=black on green
|
||||
color.pri.none=
|
||||
color.pri.H=bold black
|
||||
color.pri.M=black
|
||||
color.pri.L=
|
||||
color.tagged=green
|
||||
color.alternate=
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# Sample task 1.9 (or later) light 256-color theme
|
||||
|
||||
color=on
|
||||
color.header=color4
|
||||
color.footnote=color4
|
||||
color.debug=color4
|
||||
|
||||
color.summary.bar=on rgb141
|
||||
color.summary.background=on color0
|
||||
|
||||
color.history.add=color0 on rgb500
|
||||
color.history.done=color0 on rgb050
|
||||
color.history.delete=color0 on rgb550
|
||||
|
||||
color.undo.before=color1
|
||||
color.undo.after=color2
|
||||
|
||||
color.calendar.today=color15 on rgb013
|
||||
color.calendar.due=color0 on color9
|
||||
color.calendar.due.today=color15 on color1
|
||||
color.calendar.overdue=color0 on color1
|
||||
color.calendar.weekend=on color253
|
||||
color.calendar.holiday=color0 on color3
|
||||
color.calendar.weeknumber=rgb013
|
||||
|
||||
color.recurring=rgb013
|
||||
color.overdue=color1
|
||||
color.due.today=rgb400
|
||||
color.due=color9
|
||||
color.active=rgb555 on rgb520
|
||||
color.pri.none=
|
||||
color.pri.H=color232
|
||||
color.pri.M=color237
|
||||
color.pri.L=color242
|
||||
color.tagged=rgb020
|
||||
color.alternate=on color254
|
||||
|
||||
@@ -40,12 +40,13 @@
|
||||
208 done
|
||||
209 duplicate
|
||||
210 edit
|
||||
|
||||
211 export
|
||||
212 help
|
||||
|
||||
213 history
|
||||
214 ghistory
|
||||
215 import
|
||||
216 info
|
||||
217 prepend
|
||||
|
||||
218 overdue
|
||||
219 projects
|
||||
220 start
|
||||
@@ -54,12 +55,10 @@
|
||||
223 summary
|
||||
224 tags
|
||||
225 timesheet
|
||||
226 log
|
||||
|
||||
227 undo
|
||||
228 version
|
||||
229 shell
|
||||
230 config
|
||||
231 show
|
||||
|
||||
# 3xx Attributes - must be sequential
|
||||
300 project
|
||||
@@ -100,20 +99,57 @@
|
||||
# 5xx Colors
|
||||
500 bold
|
||||
501 underline
|
||||
502 on
|
||||
503 bright
|
||||
|
||||
504 black
|
||||
505 red
|
||||
506 green
|
||||
507 yellow
|
||||
508 blue
|
||||
509 magenta
|
||||
510 cyan
|
||||
511 white
|
||||
|
||||
520 off
|
||||
521 Unknown color name
|
||||
502 bold_underline
|
||||
503 black
|
||||
504 red
|
||||
505 green
|
||||
506 yellow
|
||||
507 blue
|
||||
508 magenta
|
||||
509 cyan
|
||||
510 white
|
||||
511 bold_black
|
||||
512 bold_red
|
||||
513 bold_green
|
||||
514 bold_yellow
|
||||
515 bold_blue
|
||||
516 bold_magenta
|
||||
517 bold_cyan
|
||||
518 bold_white
|
||||
519 underline_black
|
||||
520 underline_red
|
||||
521 underline_green
|
||||
522 underline_yellow
|
||||
523 underline_blue
|
||||
524 underline_magenta
|
||||
525 underline_cyan
|
||||
526 underline_white
|
||||
527 bold_underline_black
|
||||
528 bold_underline_red
|
||||
529 bold_underline_green
|
||||
530 bold_underline_yellow
|
||||
531 bold_underline_blue
|
||||
532 bold_underline_magenta
|
||||
533 bold_underline_cyan
|
||||
534 bold_underline_white
|
||||
535 on_black
|
||||
536 on_red
|
||||
537 on_green
|
||||
538 on_yellow
|
||||
539 on_blue
|
||||
540 on_magenta
|
||||
541 on_cyan
|
||||
542 on_white
|
||||
543 on_bright_black
|
||||
544 on_bright_red
|
||||
545 on_bright_green
|
||||
546 on_bright_yellow
|
||||
547 on_bright_blue
|
||||
548 on_bright_magenta
|
||||
549 on_bright_cyan
|
||||
550 on_bright_white
|
||||
551 off
|
||||
552 Unknown color name
|
||||
|
||||
# 6xx Config
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# setup.hint for task 1.8.1-1
|
||||
# setup.hint for task 1.7.1-1
|
||||
category: Utils
|
||||
requires: libncurses9 cygwin
|
||||
sdesc: A command-line to do list manager
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
task 1.8.1-1
|
||||
task 1.7.1-1
|
||||
------------------------------------------
|
||||
|
||||
A command-line to do list manager that can be used
|
||||
@@ -28,10 +28,10 @@ Language:
|
||||
------------------------------------
|
||||
|
||||
Build instructions:
|
||||
unpack task-1.8.1-1-src.tar.bz2
|
||||
unpack task-1.7.1-1-src.tar.bz2
|
||||
if you use setup to install this src package,
|
||||
it will be unpacked under /usr/src automatically
|
||||
cd /usr/src/task-1.8.1-1
|
||||
cd /usr/src/task-1.7.1-1
|
||||
./configure --prefix=/usr
|
||||
make
|
||||
make install
|
||||
@@ -42,4 +42,4 @@ task was packaged for cygwin by
|
||||
Federico Hernandez <ultrafredde@gmail.com> and
|
||||
is licensed under the GPL
|
||||
|
||||
---- task-1.8.1-1 -- 2009-08-20 ----
|
||||
---- task-1.7.1-1 -- 2009-06-17 ----
|
||||
@@ -1,8 +1,8 @@
|
||||
diff -Nrup task-1.8.1-1/CYGWIN-PATCHES/setup.hint task-1.8.1-1.cygwin/CYGWIN-PATCHES/setup.hint
|
||||
--- task-1.8.1-1/CYGWIN-PATCHES/setup.hint 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ task-1.8.1-1.cygwin/CYGWIN-PATCHES/setup.hint 2009-08-20 15:47:56.304750000 +0200
|
||||
diff -Nrup task-1.7.1-1/CYGWIN-PATCHES/setup.hint task-1.7.1-1.cygwin/CYGWIN-PATCHES/setup.hint
|
||||
--- task-1.7.1-1/CYGWIN-PATCHES/setup.hint 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ task-1.7.1-1.cygwin/CYGWIN-PATCHES/setup.hint 2009-06-17 15:47:56.304750000 +0200
|
||||
@@ -0,0 +1,10 @@
|
||||
+# setup.hint for task 1.8.1-1
|
||||
+# setup.hint for task 1.7.1-1
|
||||
+category: Utils
|
||||
+requires: libncurses9 cygwin
|
||||
+sdesc: A command-line to do list manager
|
||||
@@ -12,11 +12,11 @@ diff -Nrup task-1.8.1-1/CYGWIN-PATCHES/setup.hint task-1.8.1-1.cygwin/CYGWIN-PAT
|
||||
+reports and graphs, lots of manipulation commands,
|
||||
+low-level API, abbreviations for all commands and
|
||||
+options, multiuser file locking, recurring tasks."
|
||||
diff -Nrup task-1.8.1-1/CYGWIN-PATCHES/task-1.8.1-1.README task-1.8.1-1.cygwin/CYGWIN-PATCHES/task-1.8.1-1.README
|
||||
--- task-1.8.1-1/CYGWIN-PATCHES/task-1.8.1-1.README 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ task-1.8.1-1.cygwin/CYGWIN-PATCHES/task-1.8.1-1.README 2009-08-20 15:47:44.320375000 +0200
|
||||
diff -Nrup task-1.7.1-1/CYGWIN-PATCHES/task-1.7.1-1.README task-1.7.1-1.cygwin/CYGWIN-PATCHES/task-1.7.1-1.README
|
||||
--- task-1.7.1-1/CYGWIN-PATCHES/task-1.7.1-1.README 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ task-1.7.1-1.cygwin/CYGWIN-PATCHES/task-1.7.1-1.README 2009-06-17 15:47:44.320375000 +0200
|
||||
@@ -0,0 +1,45 @@
|
||||
+task 1.8.1-1
|
||||
+task 1.7.1-1
|
||||
+------------------------------------------
|
||||
+
|
||||
+A command-line to do list manager that can be used
|
||||
@@ -46,10 +46,10 @@ diff -Nrup task-1.8.1-1/CYGWIN-PATCHES/task-1.8.1-1.README task-1.8.1-1.cygwin/C
|
||||
+------------------------------------
|
||||
+
|
||||
+Build instructions:
|
||||
+ unpack task-1.8.1-1-src.tar.bz2
|
||||
+ unpack task-1.7.1-1-src.tar.bz2
|
||||
+ if you use setup to install this src package,
|
||||
+ it will be unpacked under /usr/src automatically
|
||||
+ cd /usr/src/task-1.8.1-1
|
||||
+ cd /usr/src/task-1.7.1-1
|
||||
+ ./configure --prefix=/usr
|
||||
+ make
|
||||
+ make install
|
||||
@@ -60,4 +60,4 @@ diff -Nrup task-1.8.1-1/CYGWIN-PATCHES/task-1.8.1-1.README task-1.8.1-1.cygwin/C
|
||||
+Federico Hernandez <ultrafredde@gmail.com> and
|
||||
+is licensed under the GPL
|
||||
+
|
||||
+---- task-1.8.1-1 -- 2009-08-20 ----
|
||||
+---- task-1.7.1-1 -- 2009-06-17 ----
|
||||
@@ -1,4 +1,4 @@
|
||||
task 1.8.1-1
|
||||
task 1.7.1-1
|
||||
------------------------------------------
|
||||
|
||||
A command-line to do list manager that can be used
|
||||
@@ -28,10 +28,10 @@ Language:
|
||||
------------------------------------
|
||||
|
||||
Build instructions:
|
||||
unpack task-1.8.1-1-src.tar.bz2
|
||||
unpack task-1.7.1-1-src.tar.bz2
|
||||
if you use setup to install this src package,
|
||||
it will be unpacked under /usr/src automatically
|
||||
cd /usr/src/task-1.8.1-1
|
||||
cd /usr/src/task-1.7.1-1
|
||||
./configure --prefix=/usr
|
||||
make
|
||||
make install
|
||||
@@ -42,4 +42,4 @@ task was packaged for cygwin by
|
||||
Federico Hernandez <ultrafredde@gmail.com> and
|
||||
is licensed under the GPL
|
||||
|
||||
---- task-1.8.1-1 -- 2009-08-20 ----
|
||||
---- task-1.7.1-1 -- 2009-06-17 ----
|
||||
@@ -1,6 +1,6 @@
|
||||
Name: task
|
||||
Version: 1.9.1
|
||||
Release: 1%{?dist}
|
||||
Version: 1.8.0
|
||||
Release: 0%{?dist}
|
||||
Summary: A command-line to do list manager
|
||||
|
||||
Group: Applications/Productivity
|
||||
@@ -17,7 +17,7 @@ support for GTD functionality and includes the
|
||||
following features: tags, colorful tabular output,
|
||||
reports and graphs, lots of manipulation commands,
|
||||
low-level API, abbreviations for all commands and
|
||||
options, multi-user file locking, recurring tasks.
|
||||
options, multiuser file locking, recurring tasks.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
@@ -40,54 +40,25 @@ rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%doc AUTHORS ChangeLog COPYING NEWS README scripts i18n doc/rc
|
||||
%doc AUTHORS ChangeLog COPYING NEWS README scripts
|
||||
%{_bindir}/task
|
||||
%{_mandir}/man1/task.1.gz
|
||||
%{_mandir}/man5/taskrc.5.gz
|
||||
%{_mandir}/man5/task-tutorial.5.gz
|
||||
%{_mandir}/man5/task-color.5.gz
|
||||
%{_mandir}/man5/task-faq.5.gz
|
||||
%config(noreplace) %{_sysconfdir}/bash_completion.d
|
||||
%{_sysconfdir}/bash_completion.d
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon May 22 2010 Federico Hernandez <ultrafredde@gmail.com> - 1.9.1-1
|
||||
Intial RPM for task beta release 1.9.1
|
||||
* Mon Feb 22 2010 Federico Hernandez <ultrafredde@gmail.com> - 1.9.0-1
|
||||
Intial RPM for task beta release 1.9.0
|
||||
* Mon Feb 15 2010 Federico Hernandez <ultrafredde@gmail.com> - 1.9.0.beta3-1
|
||||
Intial RPM for task beta release 1.9.0.beta3
|
||||
* Mon Feb 08 2010 Federico Hernandez <ultrafredde@gmail.com> - 1.9.0.beta2-1
|
||||
Intial RPM for task beta release 1.9.0.beta2
|
||||
* Wed Feb 03 2010 Federico Hernandez <ultrafredde@gmail.com> - 1.9.0.beta1-1
|
||||
Intial RPM for task beta release 1.9.0.beta1
|
||||
* Sat Dec 05 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.8.5-2
|
||||
Fixed wrong ChangeLog file
|
||||
* Sat Dec 05 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.8.5-1
|
||||
Intial RPM for task bugfix release 1.8.5
|
||||
* Tue Nov 17 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.8.4-1
|
||||
Intial RPM for task bugfix release 1.8.4
|
||||
* Wed Oct 21 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.8.3-1
|
||||
Intial RPM for task bugfix release 1.8.3
|
||||
* Mon Sep 07 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.8.2-1
|
||||
Intial RPM for task bugfix release 1.8.2
|
||||
* Thu Aug 20 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.8.1-1
|
||||
Intial RPM for task bugfix release 1.8.1
|
||||
* Tue Jul 21 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.8.0-1
|
||||
* Mon Jun 15 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.8.0-0
|
||||
Intial RPM for task release 1.8.0
|
||||
* Mon Jul 13 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.8.0.beta3-1
|
||||
Intial RPM for task beta release 1.8.0.beta3
|
||||
* Wed Jul 08 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.8.0.beta2-1
|
||||
Intial RPM for task beta release 1.8.0.beta2
|
||||
* Tue Jul 07 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.8.0.beta1-1
|
||||
Intial RPM for task beta release 1.8.0.beta1
|
||||
Installs now bash_completion file
|
||||
* Tue Jun 08 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.7.1-2
|
||||
Fixed inclusion of manpages.
|
||||
- Fixed inclusion of manpages.
|
||||
* Tue Jun 08 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.7.1-1
|
||||
Initial RPM for bugfix release 1.7.1.
|
||||
Updated references to new project homepage in spec file.
|
||||
- Initial RPM for bugfix release 1.7.1.
|
||||
- Updated references to new project homepage in spec file.
|
||||
* Tue May 19 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.7.0-2
|
||||
Changed license to GPLv2+ and removed Requires macro.
|
||||
See https://bugzilla.redhat.com/show_bug.cgi?id=501498
|
||||
- Changed license to GPLv2+ and removed Requires macro.
|
||||
- See https://bugzilla.redhat.com/show_bug.cgi?id=501498
|
||||
* Tue May 19 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.7.0-1
|
||||
Initial RPM.
|
||||
- Initial RPM.
|
||||
|
||||
Binary file not shown.
@@ -1,278 +0,0 @@
|
||||
How to make an OSX package
|
||||
--------------------------
|
||||
|
||||
Note: This is being written from the OSX 10.6 perspective, and may therefore
|
||||
contain steps that are different for 10.5, although I don't recall any
|
||||
actual differences.
|
||||
|
||||
|
||||
0. Philosophy
|
||||
|
||||
Only Fredde tags releases. We only make builds from tagged commits. We
|
||||
only release builds that build cleanly without errors or warnings. We only
|
||||
release builds that pass 100% of the unit tests.
|
||||
|
||||
|
||||
1. Prerequisites
|
||||
|
||||
You will need an Intel Mac, running OSX 10.5 or later.
|
||||
You will need to install the Developer Tools, which are found on your OSX DVD.
|
||||
You will need git installed, version 1.5 or later. See http://git-scm.com
|
||||
You will need autotools installed. See http://www.gnu.org/software/autoconf
|
||||
|
||||
2. Get the code
|
||||
|
||||
2.1 Clone the task git repository. It is important that this is a throwaway
|
||||
clone of the repository, because we will do (locally) destructive things
|
||||
to it.
|
||||
|
||||
$ git clone git://tasktools.org/task.git ~/task-package.git
|
||||
...
|
||||
$ cd ~/task-package.git
|
||||
|
||||
2.2 Making sure you have the right version of the code. This assumes you are
|
||||
building task 1.9.2, but any version number is interchangeable. Check out
|
||||
the correct branch, and make sure it is sitting at the correct commit, via
|
||||
a tag. Note that while 1.9.2 is a branch name, v1.9.2 is a tag name.
|
||||
|
||||
$ git checkout 1.9.2
|
||||
$ git reset --hard v1.9.2
|
||||
|
||||
If there is an error in this step, stop, capture the output, and report the
|
||||
errors.
|
||||
|
||||
3. Build task
|
||||
|
||||
3.1 First build the task binary. Note the "-j 2" tells make to use both cores
|
||||
in your dual-core Intel CPU, which means faster compiles. If you own a quad
|
||||
core Mac, use "-j 4". If you own a single core Mac, just type "make".
|
||||
|
||||
$ autoreconf -f
|
||||
$ ./configure
|
||||
...
|
||||
|
||||
If any errors are reported, stop, capture the output, and report the errors.
|
||||
|
||||
$ make -j 2
|
||||
|
||||
If there are any errors, or there are any warnings generated by the compiler
|
||||
stop, capture the output, and report the problem. You'll need to watch as
|
||||
it builds.
|
||||
|
||||
4. Build the test suite
|
||||
|
||||
4.1 The test suite exists to prove that we do not break task features from one
|
||||
release to the next. While this is not a perfect solution, it has saved us
|
||||
many times from releasing code that is inferior.
|
||||
|
||||
The first step is to modify the test suite Makefile to remove the Lua line.
|
||||
This is because we do not yet have dynamic detection of the Lua library for
|
||||
the unit tests.
|
||||
|
||||
$ cd ~/task-package.git/src/tests
|
||||
$ vi Makefile
|
||||
|
||||
Any text editor will do, but look for this line (line 5):
|
||||
|
||||
LFLAGS = -L/usr/local/lib -lncurses -llua
|
||||
|
||||
and change it to:
|
||||
|
||||
LFLAGS = -L/usr/local/lib -lncurses
|
||||
|
||||
Now build the unit tests:
|
||||
|
||||
$ make -j 2
|
||||
...
|
||||
|
||||
4.2 Run all the unit tests.
|
||||
|
||||
$ ./run_all
|
||||
Skipping benchmarks
|
||||
|
||||
Pass: 4241
|
||||
Fail: 0
|
||||
Skipped: 0
|
||||
Runtime: 86
|
||||
|
||||
The output should look something like this, with 0 failed, and 0 skipped
|
||||
tests. If there are any failures or skips, stop and mailed the log file,
|
||||
named 'all.log' to Paul & Fredde.
|
||||
|
||||
5. Assemble the parts
|
||||
|
||||
5.1 There is a script that copies all the necessary files (binary, man pages
|
||||
etc) in the right place, ready for packaging. Run this:
|
||||
|
||||
$ cd ~/task-package.git/package-config/osx
|
||||
$ ./update
|
||||
|
||||
6. Adjust the package details
|
||||
|
||||
6.1 Launch the package manager.
|
||||
|
||||
$ open -a /Developer/Applications/Utilies/PackageManager.app
|
||||
|
||||
6.2 Close the 'Untitled' window that opens - we will be using a different
|
||||
file. Note that PackageManager is still running - it just has no windows.
|
||||
|
||||
6.3 Using the File -> Open menu, open the file
|
||||
|
||||
~/task-package.git/package-config/osx/task.pmdoc
|
||||
|
||||
<figure 1>
|
||||
|
||||
This is the file from the last time a package was created. It needs some
|
||||
adjustments. Start by clicking on the "Task x.x.x Distribution" with a
|
||||
package icon in the top left part of the window.
|
||||
|
||||
6.4 Click on the "Configuration" button/tab.
|
||||
|
||||
- Change the "Title" to "Task 1.9.2"
|
||||
- Change the "Description" to "Task 1.9.2 install for Snow Leopard"
|
||||
|
||||
<figure 2>
|
||||
|
||||
6.5 Click on "Edit Interface..."
|
||||
|
||||
There are 5 radio buttons on the left hand side - we will visit each and
|
||||
make changes. Click on "Background", make sure it matches the figure.
|
||||
|
||||
<figure 3>
|
||||
|
||||
Click on "Introduction", make sure it matches the figure.
|
||||
|
||||
<figure 4>
|
||||
|
||||
Click on "Read Me", and on the right hand side, under "Read Me Panel", click
|
||||
on "File" and select the file:
|
||||
|
||||
/Users/<your-account>/task-package.git/package-config/osx/README.txt
|
||||
|
||||
<figure 5>
|
||||
|
||||
Click on "License", and on the right hand side, under "License Panel", click
|
||||
on "File" and select the file:
|
||||
|
||||
/Users/<your-account>/task-package.git/package-config/osx/COPYING.txt
|
||||
|
||||
<figure 6>
|
||||
|
||||
Click on "Finish Up", and make sure it matches the figure.
|
||||
|
||||
<figure 7>
|
||||
|
||||
Close the Interface Editor window (it saves automatically).
|
||||
|
||||
6.6 Back in the "task.pmdoc" window, click on the "Requirements" tab/button,
|
||||
then click on the "+" button, and add a requirement rule as shown in the
|
||||
figure. The minimum system should be 10.5.0 or 10.6.0, depending on which
|
||||
package is being built.
|
||||
|
||||
<figure 8>
|
||||
|
||||
6.7 Click on the "Actions" tab/button and make sure it matches the figure.
|
||||
|
||||
<figure 9>
|
||||
|
||||
6.8 Click on the triangle next to the "local" item in the "Contents" vertical
|
||||
bar on the left to expand and show a folder called "local", with the path
|
||||
"/usr/local", but click on the "local" next to the blue radio button, not
|
||||
the one next to the folder. Then click on the "Configuration" tab/button.
|
||||
|
||||
- Change the "Choice Name" to "local"
|
||||
- Leave the "Identifier" alone - it is automatic
|
||||
- Make sure "Selected" and "Enabled" are checked, but "Hidden" is not
|
||||
|
||||
<figure 10>
|
||||
|
||||
6.9 Click on the "Requirements" tab/button and make sure it is all blank.
|
||||
|
||||
<figure 11>
|
||||
|
||||
6.10 Click on the blue folder on the left, which is labelled "local", and has
|
||||
a path of "/usr/local". Click on the "Configuration" tab/button.
|
||||
|
||||
- Change the "Install" to /Users/<your-account>/task-package.git/package-config/osx/local
|
||||
- Make sure the "Destination" is "/usr/local"
|
||||
- Make sure "Allow custom location" is checked
|
||||
- Make sure the "Package Identifier is "com.beckingham.task192.local.pkg"
|
||||
- Make sure the "Package Version" is 1.0. If you needed to make a
|
||||
subsequent OSX package, *for the same version of task*, then this number
|
||||
would be increased to show OSX that this package supersedes the earlier
|
||||
one
|
||||
- Make sure "Restart Action" is "None"
|
||||
- Make sure "Require admin authentication" is checked
|
||||
- Make sure "PAckage Location" is "Self-Contained"
|
||||
|
||||
<figure 12>
|
||||
|
||||
6.11 Click on the "Contents" tab/button.
|
||||
|
||||
- Click on all the triangles in the "local" folder to expand all directories
|
||||
- Make sure "Include root in package is not checked"
|
||||
- Click on the "Apply Recommendations" button
|
||||
|
||||
Make sure it matches the figure.
|
||||
|
||||
<figure 13>
|
||||
|
||||
6.12 Click on the "Components" tab/button, make sure it is all blank.
|
||||
|
||||
6.13 Click on the "Scripts" tab/button, make sure it is all blank.
|
||||
|
||||
7. Building the package
|
||||
|
||||
7.1 Click on the "Build" hammer icon to build the package.
|
||||
|
||||
Provide a filename of "task-1.9.1-sl.pkg" for Snow Leopard (10.6), or
|
||||
"task-1.9.2.pkg" for Leopard (10.5), and save it somewhere, for example the
|
||||
Desktop.
|
||||
|
||||
All should succeed. You can click on the "Return" button to end the build
|
||||
phase, and you can quit PackageManager, but make sure you save the changes
|
||||
you made, because you may need to go through the whole process again, if there
|
||||
is an emergency change, or the package is somehow corrupt.
|
||||
|
||||
<figure 14>
|
||||
|
||||
8. Test the package
|
||||
|
||||
8.1 Double-click on the package you just created, and install task. You
|
||||
should see the README file in the UI, and the COPYING file on another
|
||||
page. It should succeed.
|
||||
|
||||
<figure 14>
|
||||
<figure 15>
|
||||
<figure 16>
|
||||
<figure 17>
|
||||
<figure 18>
|
||||
<figure 19>
|
||||
<figure 20>
|
||||
<figure 21>
|
||||
|
||||
8.2 Run the following commands to test the installation
|
||||
|
||||
$ /usr/local/bin/task version
|
||||
|
||||
task 1.9.2 built for darwin-ncurses
|
||||
Copyright (C) 2006 - 2010 P. Beckingham, F. Hernandez.
|
||||
|
||||
Task may be copied only under the terms of the GNU General Public License,
|
||||
which may be found in the task source kit.
|
||||
|
||||
Documentation for task can be found using 'man task', 'man taskrc', 'man
|
||||
task-tutorial', 'man task-color', 'man task-faq' or at http://taskwarrior.org
|
||||
|
||||
$ man task
|
||||
...
|
||||
...
|
||||
task 1.9.2 2010-05-22 task 1.9.2
|
||||
|
||||
The man page should list 1.9.2 as the version number, but the date will be
|
||||
different.
|
||||
|
||||
9. Email the package to Fredde.
|
||||
|
||||
---
|
||||
|
||||
281
package-config/osx/binary/COPYING.txt
Normal file
281
package-config/osx/binary/COPYING.txt
Normal file
@@ -0,0 +1,281 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
24
package-config/osx/binary/README.txt
Normal file
24
package-config/osx/binary/README.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
Thank you for taking a look at task!
|
||||
|
||||
Task is a GTD, todo list, task management, command line utility with a multitude
|
||||
of features. It is a portable, well supported, very active project, and it is
|
||||
Open Source. Task has binary distributions, online documentation, demonstration
|
||||
movies, and you'll find all the details at the site:
|
||||
|
||||
http://taskwarrior.org
|
||||
|
||||
At the site you'll find a wiki, discussion forums, downloads, news and more.
|
||||
|
||||
|
||||
Your contributions are especially welcome. Whether it comes in the form of
|
||||
code patches, ideas, discussion, bug reports or just encouragement, your input
|
||||
is needed.
|
||||
|
||||
Please send your support questions and code patches to:
|
||||
|
||||
support@taskwarrior.org
|
||||
|
||||
Consider joining taskwarrior.org and participating in the future of task.
|
||||
|
||||
---
|
||||
@@ -1 +0,0 @@
|
||||
<pkg-contents spec="1.12"><f n="local" o="root" g="wheel" p="16877" pt="/Users/paul/task-1.9.1.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"/></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"/><f n="ChangeLog" o="root" g="wheel" p="33188"/><f n="COPYING" o="root" g="wheel" p="33188"/><f n="NEWS" o="root" g="wheel" p="33188"/><f n="README" o="root" g="wheel" p="33188"/><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"/></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"/></f><f n="README" o="root" g="wheel" p="33188"/><f n="syntax" o="root" g="wheel" p="16877"><f n="taskdata.vim" o="root" g="wheel" p="33188"/><f n="taskedit.vim" o="root" g="wheel" p="33188"/><f n="taskrc.vim" o="root" g="wheel" p="33188"/></f></f><f n="zsh" o="root" g="wheel" p="16877"><f n="_task" o="root" g="wheel" p="33188"/></f></f></f></f><f n="man" o="root" g="wheel" p="17917"><f n="man1" o="root" g="wheel" p="17901"><f n="task.1" o="root" g="wheel" p="33188"/><mod>group</mod><mod>owner</mod></f><f n="man5" o="root" g="wheel" p="17901"><f n="task-color.5" o="root" g="wheel" p="33188"/><f n="task-faq.5" o="root" g="wheel" p="33188"/><f n="task-tutorial.5" o="root" g="wheel" p="33188"/><f n="taskrc.5" o="root" g="wheel" p="33188"/><mod>group</mod><mod>owner</mod></f><mod>group</mod><mod>owner</mod></f></f><mod>group</mod><mod>owner</mod></f></pkg-contents>
|
||||
@@ -1 +0,0 @@
|
||||
<pkgref spec="1.12" uuid="B93940C5-2C4F-47D6-8038-3D24062FBC85"><config><identifier>com.beckingham.task191.local.pkg</identifier><version>1.0</version><description/><post-install type="none"/><requireAuthorization/><installFrom>/Users/paul/task-1.9.1.git/package-config/osx/local</installFrom><installTo mod="true" relocatable="true">/usr/local</installTo><flags><followSymbolicLinks/></flags><packageStore type="internal"/><mod>installTo.path</mod><mod>identifier</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
package-config/osx/task.pmdoc/01task-contents.xml
Normal file
1
package-config/osx/task.pmdoc/01task-contents.xml
Normal file
@@ -0,0 +1 @@
|
||||
<pkg-contents spec="1.12"><f n="task" o="paul" g="staff" p="33261" pt="/Users/paul/task.git/package-config/osx/binary/task" m="false" t="file"/></pkg-contents>
|
||||
1
package-config/osx/task.pmdoc/01task.xml
Normal file
1
package-config/osx/task.pmdoc/01task.xml
Normal file
@@ -0,0 +1 @@
|
||||
<pkgref spec="1.12" uuid="C71026FD-E252-42CD-89C3-2F6F087AAF17"><config><identifier>com.beckingham.task180.task.pkg</identifier><version>1.8.0</version><description></description><post-install type="none"/><requireAuthorization/><installFrom mod="true">/Users/paul/task.git/package-config/osx/binary/task</installFrom><installTo mod="true" relocatable="true">/usr/local/bin</installTo><flags><followSymbolicLinks/></flags><packageStore type="internal"></packageStore><mod>parent</mod><mod>locationType</mod><mod>relocatable</mod><mod>version</mod><mod>installTo.path</mod><mod>installTo</mod></config><contents><file-list>01task-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.1</title><build>/Users/paul/Desktop/task-1.9.1-sl.pkg</build><organization>com.beckingham</organization><userSees ui="both"/><min-target os="3"/><domain anywhere="true" system="true"/></properties><distribution><versions min-spec="1.000000"/><scripts></scripts></distribution><description>Task 1.9.1 install for Snow Leopard.</description><contents><choice title="local" id="choice37" starts_selected="true" starts_enabled="true" starts_hidden="false"><pkgref id="com.beckingham.task191.local.pkg"/></choice></contents><resources bg-scale="proportional" bg-align="center"><locale lang="en"><resource mod="true" type="license">/Users/paul/task-1.9.1.git/package-config/osx/COPYING.txt</resource><resource mod="true" type="readme">/Users/paul/task-1.9.1.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.8.0</title><build>/Users/paul/Desktop/task-1.8.0.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><contents><choice title="task" id="choice0" starts_selected="true" starts_enabled="true" starts_hidden="false"><pkgref id="com.beckingham.task180.task.pkg"/><choice-reqs><requirement id="tosv" operator="ge" value="'10.5.0'" selected="no" enabled="no" hidden="unchanged" startSelected="unchanged" startEnabled="unchanged" startHidden="unchanged"/></choice-reqs></choice></contents><resources bg-scale="proportional" bg-align="center"><locale lang="en"><resource mod="true" type="license">/Users/paul/task.git/package-config/osx/binary/COPYING.txt</resource><resource mod="true" type="readme">/Users/paul/task.git/package-config/osx/binary/README.txt</resource></locale></resources><flags/><item type="file">01task.xml</item><mod>properties.title</mod><mod>properties.anywhereDomain</mod><mod>properties.systemDomain</mod></pkmkdoc>
|
||||
@@ -1,34 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p local/bin
|
||||
mkdir -p local/share/doc/task/scripts/bash
|
||||
mkdir -p local/share/doc/task/scripts/vim/ftdetect
|
||||
mkdir -p local/share/doc/task/scripts/vim/syntax
|
||||
mkdir -p local/share/doc/task/scripts/zsh
|
||||
mkdir -p local/share/doc/task/rc
|
||||
mkdir -p local/share/man/man1
|
||||
mkdir -p local/share/man/man5
|
||||
|
||||
cp ../../README README.txt
|
||||
cp ../../COPYING COPYING.txt
|
||||
|
||||
cp ../../src/task local/bin/
|
||||
|
||||
cp ../../AUTHORS local/share/doc/task/
|
||||
cp ../../ChangeLog local/share/doc/task/
|
||||
cp ../../COPYING local/share/doc/task/
|
||||
cp ../../NEWS local/share/doc/task/
|
||||
cp ../../README local/share/doc/task/
|
||||
|
||||
cp ../../scripts/bash/* local/share/doc/task/scripts/bash
|
||||
cp ../../scripts/vim/README local/share/doc/task/scripts/vim
|
||||
cp ../../scripts/vim/ftdetect/* local/share/doc/task/scripts/vim/ftdetect
|
||||
cp ../../scripts/vim/syntax/* local/share/doc/task/scripts/vim/syntax
|
||||
cp ../../scripts/zsh/* local/share/doc/task/scripts/zsh
|
||||
|
||||
cp ../../doc/rc/*.theme local/share/doc/task/rc
|
||||
cp ../../doc/rc/holidays* local/share/doc/task/rc
|
||||
|
||||
cp ../../doc/man/*.1 local/share/man/man1
|
||||
cp ../../doc/man/*.5 local/share/man/man5
|
||||
|
||||
@@ -1,104 +1,8 @@
|
||||
task (1.9.1-2ubuntu1) lucid; urgency=low
|
||||
|
||||
* Initial deb package for task release 1.9.1 on lucid lynx
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Sun, 23 May 2010 00:24:42 +0200
|
||||
|
||||
task (1.9.0-2ubuntu1) lucid; urgency=low
|
||||
|
||||
* Initial deb package for task release 1.9.0 on lucid lynx
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Sat, 15 May 2010 11:02:17 +0200
|
||||
|
||||
task (1.9.0-1ubuntu1) karmic; urgency=low
|
||||
|
||||
* Initial deb package for task beta release 1.9.0 on karmic koala
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Mon, 22 Feb 2010 22:08:41 +0100
|
||||
|
||||
task (1.9.0-1ubuntu1~beta3) karmic; urgency=low
|
||||
|
||||
* Initial deb package for task beta release 1.9.0.beta3 on karmic koala
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Tue, 16 Feb 2010 00:29:31 +0100
|
||||
|
||||
task (1.9.0-1ubuntu1~beta2) karmic; urgency=low
|
||||
|
||||
* Initial deb package for task beta release 1.9.0.beta2 on karmic koala
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Mon, 08 Feb 2010 22:09:41 +0100
|
||||
|
||||
task (1.9.0-1ubuntu1~beta1) karmic; urgency=low
|
||||
|
||||
* Initial deb package for task beta release 1.9.0.beta1 on karmic koala
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Wed, 03 Feb 2010 23:51:08 +0100
|
||||
|
||||
task (1.8.5-1ubuntu2) karmic; urgency=low
|
||||
|
||||
* Fixed wrong ChangeLog file
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Sat, 05 Dec 2009 23:58:36 +0100
|
||||
|
||||
task (1.8.5-1ubuntu1) karmic; urgency=low
|
||||
|
||||
* Initial deb package for task bugfix release 1.8.5
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Sat, 05 Dec 2009 23:56:36 +0100
|
||||
|
||||
task (1.8.4-1ubuntu1) karmic; urgency=low
|
||||
|
||||
* Initial deb package for task bugfix release 1.8.4 on karmic koala
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Tue, 17 Nov 2009 13:12:28 +0100
|
||||
|
||||
task (1.8.3-1ubuntu1) karmic; urgency=low
|
||||
|
||||
* Initial deb package for task bugfix release 1.8.3 on karmic koala
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Sat, 31 Oct 2009 22:45:10 +0100
|
||||
|
||||
task (1.8.3-0ubuntu1) jaunty; urgency=low
|
||||
|
||||
* Initial deb package for task bugfix release 1.8.3
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Wed, 21 Oct 2009 23:22:25 +0200
|
||||
|
||||
task (1.8.2-0ubuntu1) jaunty; urgency=low
|
||||
|
||||
* Initial deb package for task bugfix release 1.8.2
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Mon, 07 Sep 2009 11:35:22 +0200
|
||||
|
||||
task (1.8.1-0ubuntu1) jaunty; urgency=low
|
||||
|
||||
* Initial deb package for task bugfix release 1.8.1
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Thu, 20 Aug 2009 20:26:33 +0200
|
||||
|
||||
task (1.8.0-0ubuntu1) jaunty; urgency=low
|
||||
|
||||
* Initial deb package for task release 1.8.0
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Tue, 21 Jul 2009 15:26:33 +0200
|
||||
|
||||
task (1.8.0-0ubuntu1~beta3) jaunty; urgency=low
|
||||
|
||||
* Initial deb package for task beta release 1.8.0.beta3
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Mon, 13 Jul 2009 15:09:38 +0200
|
||||
|
||||
task (1.8.0-0ubuntu1~beta2) jaunty; urgency=low
|
||||
|
||||
* Initial deb package for task beta release 1.8.0.beta2
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Wed, 08 Jul 2009 15:40:50 +0200
|
||||
|
||||
task (1.8.0-0ubuntu1~beta1) jaunty; urgency=low
|
||||
|
||||
* Initial deb package for task beta release 1.8.0.beta1
|
||||
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Tue, 07 Jul 2009 01:35:28 +0200
|
||||
-- Federico Hernandez <ultrafredde@gmail.com> Thu, 11 Jun 2009 23:02:28 +0200
|
||||
|
||||
task (1.7.1-0ubuntu1) jaunty; urgency=low
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ Section: utils
|
||||
Priority: optional
|
||||
Maintainer: Federico Hernandez <ultrafredde@gmail.com>
|
||||
XSBC-Original-Maintainer: Federico Hernandez <ultrafredde@gmail.com>
|
||||
Build-Depends: cdbs, debhelper (>= 7), autotools-dev, libncurses5-dev
|
||||
Standards-Version: 3.8.4
|
||||
Build-Depends: debhelper (>= 7), autotools-dev, libncurses5-dev
|
||||
Standards-Version: 3.8.0.1
|
||||
Homepage: http://taskwarrior.org
|
||||
|
||||
Package: task
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Depends: ${shlibs:Depends}
|
||||
Description: A command-line to do list manager
|
||||
Task is a command-line to do list manager. It has
|
||||
support for GTD functionality and includes the
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
This package was debianized by:
|
||||
|
||||
Federico Hernandez <ultrafredde@gmail.com> on Sun, 23 May 2010 00:24:42 +0200
|
||||
Federico Hernandez <ultrafredde@gmail.com> on Thu, 11 Jun 2009 23:02:28 +0200
|
||||
|
||||
It was downloaded from:
|
||||
|
||||
@@ -9,9 +9,6 @@ It was downloaded from:
|
||||
Upstream Authors:
|
||||
|
||||
Paul Beckingham <paul@beckingham.net>
|
||||
Federico Hernandez
|
||||
David J Patrick
|
||||
John Florian
|
||||
Damian Glenny
|
||||
Andy Lester
|
||||
H. İbrahim Güngör
|
||||
@@ -20,24 +17,18 @@ Upstream Authors:
|
||||
Benjamin Tegarden
|
||||
Chris Pride
|
||||
Richard Querin
|
||||
Federico Hernandez
|
||||
T. Charles Yun
|
||||
David J Patrick
|
||||
P.C. Shyamshankar
|
||||
Johan Friis
|
||||
Steven de Brouwer
|
||||
Pietro Cerutti
|
||||
Cory Donnelly
|
||||
Alexander Neumann
|
||||
Emil Sköldberg
|
||||
Johannes Schlatow
|
||||
|
||||
Copyright:
|
||||
|
||||
Copyright 2006 - 2010, Paul Beckingham
|
||||
Copyright 2009 - 2010 Federico Hernandez
|
||||
Copyright 2006 - 2010, Paul Beckingham, Federico Hernandez
|
||||
Copyright 2009 - 2010 John Florian
|
||||
Copyright 2006 - 2009, Paul Beckingham
|
||||
Copyright 2009 Federico Hernandez
|
||||
Copyright 2009 P.C. Shyamshankar
|
||||
Copyright © 1994–2008 Lua.org, PUC-Rio
|
||||
|
||||
License:
|
||||
|
||||
@@ -60,6 +51,6 @@ Public License can be found in `/usr/share/common-licenses/GPL-2'.
|
||||
|
||||
The Debian packaging is:
|
||||
|
||||
Copyright (C) 2009 - 2010, Federico Hernandez <ultrafredde@gmail.com>
|
||||
Copyright (C) 2009, Federico Hernandez <ultrafredde@gmail.com>
|
||||
|
||||
and is licensed under the GPL, see above.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
config.status: configure
|
||||
dh_testdir
|
||||
./configure $(CROSS) --prefix=/usr
|
||||
./configure $(CROSS) --prefix=/usr --docdir=$(DATADIR)/doc/task
|
||||
|
||||
build: build-stamp
|
||||
|
||||
@@ -31,7 +31,8 @@ binary-arch: install
|
||||
dh_installchangelogs
|
||||
dh_installdocs
|
||||
dh_installman
|
||||
install -D -m644 scripts/bash/task_completion.sh $(CURDIR)/debian/task/etc/bash_completion.d/task
|
||||
install -D -m644 task_completion.sh $(CURDIR)/debian/task/etc/bash_completion.d/task
|
||||
rm -rf $(CURDIR)/debian/task/usr/share/doc/task-1.7.1
|
||||
dh_strip
|
||||
dh_compress
|
||||
dh_fixperms
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
1.0
|
||||
@@ -1,5 +1,3 @@
|
||||
# Compulsory line, this is a version 3 file
|
||||
version=3
|
||||
|
||||
# the main taskwarrior download website
|
||||
http://taskwarrior.org/wiki/taskwarrior/Download http://www.taskwarrior.org/download/task-(.*)\.tar\.gz
|
||||
|
||||
http://taskwarrior.org/download/task-(.*)\.tar\.gz
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# bash completion support for task
|
||||
#
|
||||
# Copyright 2009-2010 Federico Hernandez
|
||||
# Copyright 2009 Federico Hernandez
|
||||
# All rights reserved.
|
||||
#
|
||||
# This script is part of the task project.
|
||||
@@ -48,6 +48,10 @@
|
||||
# http://taskwarrior.org
|
||||
#
|
||||
|
||||
_task_get_projects() {
|
||||
task _projects
|
||||
}
|
||||
|
||||
_task_get_tags() {
|
||||
task _tags
|
||||
}
|
||||
@@ -56,10 +60,6 @@ _task_get_config() {
|
||||
task _config
|
||||
}
|
||||
|
||||
_task_offer_projects() {
|
||||
COMPREPLY=( $(compgen -W "$(task _projects)" -- ${cur/*:/}) )
|
||||
}
|
||||
|
||||
_task()
|
||||
{
|
||||
local cur prev opts base
|
||||
@@ -67,61 +67,34 @@ _task()
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
if [ ${#COMP_WORDS[*]} -gt 2 ]
|
||||
then
|
||||
prev2="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
else
|
||||
prev2=""
|
||||
fi
|
||||
# echo -e "\ncur='$cur'"
|
||||
# echo "prev='$prev'"
|
||||
# echo "prev2='$prev2'"
|
||||
|
||||
opts="$(task _commands) $(task _ids)"
|
||||
|
||||
case "${prev}" in
|
||||
:)
|
||||
case "${prev2}" in
|
||||
pro*)
|
||||
_task_offer_projects
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
case "${cur}" in
|
||||
pro*:*)
|
||||
local projects=$(_task_get_projects)
|
||||
local partial_project="${cur/*:/}"
|
||||
COMPREPLY=( $(compgen -W "${projects}" -- ${partial_project}) )
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
case "${cur}" in
|
||||
pro*:*)
|
||||
_task_offer_projects
|
||||
return 0
|
||||
;;
|
||||
:)
|
||||
case "${prev}" in
|
||||
pro*)
|
||||
_task_offer_projects
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
+*)
|
||||
local tags=$(_task_get_tags | sed 's/^/+/')
|
||||
COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
-*)
|
||||
local tags=$(_task_get_tags | sed 's/^/-/')
|
||||
COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
rc.*)
|
||||
local config=$(_task_get_config | sed -e 's/^/rc\./' -e 's/$/:/')
|
||||
COMPREPLY=( $(compgen -W "${config}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
+*)
|
||||
local tags=$(_task_get_tags | sed 's/^/+/')
|
||||
COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
-*)
|
||||
local tags=$(_task_get_tags | sed 's/^/-/')
|
||||
COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
rc.*)
|
||||
local config=$(_task_get_config | sed 's/^/rc\./')
|
||||
COMPREPLY=( $(compgen -W "${config}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
}
|
||||
complete -o nospace -F _task task
|
||||
complete -F _task task
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
Configure VIM for Syntax Highlighting of Task Data
|
||||
|
||||
|
||||
The task data files (pending.data, completed.data and undo.data),
|
||||
configuration file (.taskrc) as well as edits made via commands like "task 1
|
||||
edit" can be color-highlighted if you happen to use VIM as your preferred text
|
||||
editor. Eventually this will happen automatically in newer versions of VIM,
|
||||
but for now you have to do a little bit of file shuffling.
|
||||
The task data files (pending.data, completed.data and undo.data) as well as
|
||||
edits made via commands like "task 1 edit" can be color-highlighted if you
|
||||
happen to use VIM as your preferred text editor. Eventually this will happen
|
||||
automatically in newer versions of VIM, but for now you have to do a little
|
||||
bit of file shuffling.
|
||||
|
||||
|
||||
Prerequisites
|
||||
|
||||
For this to work, you need to first have syntax highlighting enabled when you
|
||||
use VIM. This happens to be the default for most VIM installations, but it is
|
||||
usually quite simple if that doesn't happen to be so in your case. Rather
|
||||
than repeat the excellent VIM documentation here, please see the appropriate
|
||||
VIM documentation itself. Generally this can be made seen by starting
|
||||
vim/gvim and issuing the following command:
|
||||
use VIM. This happens to be the default for most VIM installations, but it is
|
||||
usually quite simple if that doesn't happen to be so in your case. Rather than
|
||||
repeat the excellent VIM documentation here, please see the appropriate VIM
|
||||
documentation itself. Generally this can be made seen by starting vim/gvim and
|
||||
issuing the following command:
|
||||
|
||||
:help syntax
|
||||
|
||||
@@ -27,20 +27,18 @@ You may prefer instead to read the help online at:
|
||||
Configuring VIM to Understand Task Data
|
||||
|
||||
Once you have VIM's syntax highlighting enabled and working with other file
|
||||
types properly, configuring it for use with task is simple. You simply need
|
||||
to copy some files that came with task into your home directory so that you
|
||||
have:
|
||||
types properly, configuring it for use with task is simple. You simply need to
|
||||
copy some files that came with task into your home directory so that you have:
|
||||
|
||||
~/.vim/ftdetect/task.vim
|
||||
~/.vim/syntax/taskdata.vim
|
||||
~/.vim/syntax/taskedit.vim
|
||||
~/.vim/syntax/taskrc.vim
|
||||
|
||||
The source of these files varies depending on how you installed task. If you
|
||||
The source of these files varies depending on how you installed task. If you
|
||||
installed task via a regular package (rpm or deb) you can find these files in
|
||||
/usr/share/doc/task-VERSION/scripts/vim/. If you built task yourself from the
|
||||
/usr/share/doc/task-VERSION/scripts/vim/. If you built task yourself from the
|
||||
tarball (using the default configure options), these will be in
|
||||
/usr/local/share/doc/task-VERSION/scripts/vim/ instead. So you should be able
|
||||
/usr/local/share/doc/task-VERSION/scripts/vim/ instead. So you should be able
|
||||
to do one of the following:
|
||||
|
||||
cp -av /usr/share/doc/task-VERSION/scripts/vim/* ~/.vim/
|
||||
@@ -51,9 +49,9 @@ or
|
||||
|
||||
You should then be ready to go.
|
||||
---
|
||||
All four above mentioned files are
|
||||
All three above mentioned files are
|
||||
|
||||
Copyright 2009-2010 John Florian
|
||||
Copyright 2009 John Florian
|
||||
|
||||
and are available under the GNU Public License version 2 or later.
|
||||
For the full text of this license, see COPYING.
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
" Vim support file to detect Task Warrior data and configuration files and
|
||||
" single task edits
|
||||
" Vim support file to detect task data files and single task edits
|
||||
"
|
||||
" Maintainer: John Florian <jflorian@doubledog.org>
|
||||
" Updated: Thu Dec 10 18:28:26 EST 2009
|
||||
" Updated: Wed Jul 8 19:45:55 EDT 2009
|
||||
"
|
||||
" Copyright 2009-2010 John Florian
|
||||
" Copyright 2009 John Florian
|
||||
"
|
||||
" This file is available under the GNU Public License version 2 or later.
|
||||
" For the full text of this license, see COPYING.
|
||||
|
||||
|
||||
" Task Warrior data files
|
||||
" for the raw data files
|
||||
au BufRead,BufNewFile {pending,completed,undo}.data set filetype=taskdata
|
||||
|
||||
" Task Warrior configuration file
|
||||
au BufRead,BufNewFile .taskrc set filetype=taskrc
|
||||
|
||||
" Task Warrior handling of 'task 42 edit'
|
||||
" for 'task 42 edit'
|
||||
au BufRead,BufNewFile *.task set filetype=taskedit
|
||||
|
||||
" vim:noexpandtab
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
" Maintainer: John Florian <jflorian@doubledog.org>
|
||||
" Updated: Wed Jul 8 19:46:20 EDT 2009
|
||||
"
|
||||
" Copyright 2009-2010 John Florian
|
||||
" Copyright 2009 John Florian
|
||||
"
|
||||
" This file is available under the GNU Public License version 2 or later.
|
||||
" For the full text of this license, see COPYING.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
" Maintainer: John Florian <jflorian@doubledog.org>
|
||||
" Updated: Wed Jul 8 19:46:32 EDT 2009
|
||||
"
|
||||
" Copyright 2009-2010 John Florian
|
||||
" Copyright 2009 John Florian
|
||||
"
|
||||
" This file is available under the GNU Public License version 2 or later.
|
||||
" For the full text of this license, see COPYING.
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
" Vim syntax file
|
||||
" Language: support for editing task configuration file
|
||||
" Maintainer: John Florian <jflorian@doubledog.org>
|
||||
" Updated: Sat Feb 20 14:14:44 EST 2010
|
||||
"
|
||||
" Copyright 2009-2010 John Florian
|
||||
"
|
||||
" This file is available under the GNU Public License version 2 or later.
|
||||
" For the full text of this license, see COPYING.
|
||||
|
||||
|
||||
" For version 5.x: Clear all syntax items.
|
||||
" For version 6.x: Quit when a syntax file was already loaded.
|
||||
if version < 600
|
||||
syntax clear
|
||||
elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
syn match taskrcVal ".\{-}$" contains=taskrcComment
|
||||
syn match taskrcEqual "="
|
||||
syn match taskrcKey "^\s*.\{-}="he=e-1 contains=taskrcEqual
|
||||
|
||||
syn keyword taskrcGoodKey locking curses confirmation next bulk nag weekstart displayweeknumber defaultwidth editor monthsperline annotations _forcecolor blanklines debug hooks fontunderline
|
||||
|
||||
syn match taskrcGoodKey "\(active\|tag\|recurrence\)\.indicator"
|
||||
syn match taskrcGoodKey "alias\.\S\{-}="he=e-1
|
||||
syn match taskrcGoodKey "calendar\.\(legend\|holidays\|details\(\.report\)\?\)"
|
||||
syn match taskrcGoodKey "color\(\.\(alternate\|overdue\|due\(\.today\)\?\|pri\.\([HML]\|none\)\|active\|tagged\|recurring\|header\|footnote\|\(\(tag\|project\|keyword\)\.\S\{-}\)\|debug\|\(calendar\.\(today\|due\(\.today\)\?\|overdue\|weekend\|holiday\|weeknumber\)\)\)\)\?="he=e-1
|
||||
syn match taskrcGoodKey "complete\.all\.\(projects\|tags\)"
|
||||
syn match taskrcGoodKey "data\.location"
|
||||
syn match taskrcGoodKey "dateformat\(\.\(holiday\|report\)\)\?"
|
||||
syn match taskrcGoodKey "default\.\(command\|project\|priority\)"
|
||||
syn match taskrcGoodKey "due="he=e-1
|
||||
syn match taskrcGoodKey "echo\.command"
|
||||
syn match taskrcGoodKey "import\.synonym\.\(bg\|description\|due\|end\|entry\|fg\|id\|priority\|project\|recur\|start\|status\|tags\|uuid\)"
|
||||
syn match taskrcGoodKey "report\.\S\{-}\.\(description\|columns\|labels\|sort\|filter\|dateformat\|annotations\)="he=e-1
|
||||
syn match taskrcGoodKey "search\.case\.sensitive"
|
||||
syn match taskrcGoodKey "shadow\.\(file\|command\|notify\)"
|
||||
syn match taskrcGoodKey "shell\.prompt"
|
||||
|
||||
syn match taskrcComment "#.*$"
|
||||
|
||||
" The default methods for highlighting. Can be overridden later.
|
||||
hi def link taskrcComment Comment
|
||||
hi def link taskrcKey Statement
|
||||
hi def link taskrcVal String
|
||||
hi def link taskrcGoodKey Function
|
||||
|
||||
let b:current_syntax = "taskrc"
|
||||
|
||||
" vim:noexpandtab
|
||||
@@ -1,11 +1,4 @@
|
||||
#compdef task
|
||||
#
|
||||
# This script is currently unmaintained and was released for an earlier version
|
||||
# of task. We welcome any zsh user that wants to contribute to task to take a
|
||||
# look at this script and either confirm its working status or improve it.
|
||||
# Please contact us at support@taskwarrior.org if you have further questions on
|
||||
# how to contribute to task.
|
||||
#
|
||||
# zsh completion for task
|
||||
#
|
||||
# Copyright 2009 P.C. Shyamshankar
|
||||
@@ -34,7 +27,10 @@
|
||||
#
|
||||
|
||||
typeset -g _task_cmds
|
||||
_task_cmds=($(task _commands))
|
||||
_task_cmds=($(task rubbish-command | sed -n -e 's/^\s\+task \(\w\+\) .*/\1/p' | grep -v ID))
|
||||
|
||||
# As of task 1.7.0,
|
||||
# _task_cmds=(add append annotate completed edit duplicate delete undelete info start stop done undo projects tags summary timesheet history ghistory next calendar active overdue stats import export color version help list long ls newest oldest)
|
||||
|
||||
_task() {
|
||||
_arguments -s -S \
|
||||
|
||||
1
src/.gitignore
vendored
1
src/.gitignore
vendored
@@ -1,3 +1,2 @@
|
||||
*.o
|
||||
Makefile.in
|
||||
*_test
|
||||
|
||||
792
src/API.cpp
792
src/API.cpp
@@ -1,792 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Task Lua API
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// -------------
|
||||
//
|
||||
// Copyright © 1994–2008 Lua.org, PUC-Rio.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <iostream> // TODO Remove
|
||||
#include <algorithm>
|
||||
#include "Context.h"
|
||||
#include "API.h"
|
||||
|
||||
extern Context context;
|
||||
Task* the_task = NULL;
|
||||
|
||||
#ifdef HAVE_LIBLUA
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Returns a string representing the task version number, such as '1.9.0'.
|
||||
static int api_task_version (lua_State* L)
|
||||
{
|
||||
lua_pushstring (L, PACKAGE_VERSION);
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Returns a string representing the Lua version number, such as '5.1.4'.
|
||||
// Lua 5.2.0 has a 'lua_version' call, but 5.1.4 is the target.
|
||||
static int api_task_lua_version (lua_State* L)
|
||||
{
|
||||
// Convert "Lua 5.1.4" -> "5.1.4"
|
||||
std::string ver = LUA_RELEASE;
|
||||
lua_pushstring (L, ver.substr (4, std::string::npos).c_str ());
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Returns the type of OS that task is running on.
|
||||
static int api_task_os (lua_State* L)
|
||||
{
|
||||
#if defined (DARWIN)
|
||||
lua_pushstring (L, "darwin");
|
||||
#elif defined (SOLARIS)
|
||||
lua_pushstring (L, "solaris");
|
||||
#elif defined (CYGWIN)
|
||||
lua_pushstring (L, "cygwin");
|
||||
#elif defined (OPENBSD)
|
||||
lua_pushstring (L, "openbsd");
|
||||
#elif defined (HAIKU)
|
||||
lua_pushstring (L, "haiku");
|
||||
#elif defined (FREEBSD)
|
||||
lua_pushstring (L, "freebsd");
|
||||
#elif defined (LINUX)
|
||||
lua_pushstring (L, "linux");
|
||||
#else
|
||||
lua_pushstring (L, "unknown");
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_feature (lua_State* L)
|
||||
{
|
||||
std::string name = luaL_checkstring (L, 1);
|
||||
bool value = false;
|
||||
|
||||
if (name == "readline")
|
||||
{
|
||||
#ifdef HAVE_READLINE
|
||||
value = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
else if (name == "ncurses")
|
||||
{
|
||||
#ifdef HAVE_NCURSES
|
||||
value = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
else if (name == "lua")
|
||||
value = true;
|
||||
|
||||
lua_pushboolean (L, value ? 1 : 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_aliases ()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Returns values from .taskrc, by name.
|
||||
static int api_task_get_config (lua_State* L)
|
||||
{
|
||||
std::string name = luaL_checkstring (L, 1);
|
||||
lua_pushstring (L, context.config.get (name).c_str ());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-- Temporarily sets .taskrc values, by name.
|
||||
static int api_task_set_config (name, value)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-- Returns an internationalized string, by string ID, from the appropriate
|
||||
-- locale-based strings file.
|
||||
static int api_task_i18n_string (id)
|
||||
{
|
||||
return "le foo"
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-- Returns a list of tips, from the appropriate locale-based tips file.
|
||||
static int api_task_i18n_tips ()
|
||||
{
|
||||
return {}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-- Returns the name of the current command.
|
||||
static int api_task_get_command ()
|
||||
{
|
||||
return "list"
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-- Returns a list of string messages generated so far.
|
||||
static int api_task_get_header_messages ()
|
||||
{
|
||||
return {}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_footnote_messages ()
|
||||
{
|
||||
return {}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_debug_messages (lua_State* L)
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_header_message (lua_State* L)
|
||||
{
|
||||
std::string message = luaL_checkstring (L, 1);
|
||||
context.header (message);
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_footnote_message (lua_State* L)
|
||||
{
|
||||
std::string message = luaL_checkstring (L, 1);
|
||||
context.footnote (message);
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_debug_message (lua_State* L)
|
||||
{
|
||||
std::string message = luaL_checkstring (L, 1);
|
||||
context.debug (message);
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Causes the shell or interactive mode task to exit. Ordinarily this does not
|
||||
// occur.
|
||||
static int api_task_exit (lua_State* L)
|
||||
{
|
||||
// TODO Is this the correct exception? How does the shell handle this?
|
||||
throw std::string ("Exiting.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-- Shuts off the hook system for any subsequent hook calls for this command.
|
||||
static int api_task_inhibit_further_hooks ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-- Returns a table that contains a complete copy of the task.
|
||||
static int api_task_get (lua_State* L)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-- Creates a new task from the data specified in the table t.
|
||||
static int api_task_add (t)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-- Modifies the task described in the table t.
|
||||
static int api_task_modify (t)
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// -- 'id' is the task id passed to the hook function. Date attributes are
|
||||
// -- returned as a numeric epoch offset. Tags and annotations are returned
|
||||
// -- as tables. A nil value indicates a missing value.
|
||||
static int api_task_get_uuid (lua_State* L)
|
||||
{
|
||||
if (the_task != NULL)
|
||||
lua_pushstring (L, the_task->get ("uuid").c_str ());
|
||||
else
|
||||
lua_pushnil (L);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_description (lua_State* L)
|
||||
{
|
||||
if (the_task != NULL)
|
||||
lua_pushstring (L, the_task->get ("description").c_str ());
|
||||
else
|
||||
lua_pushnil (L);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_annotations (id)
|
||||
{
|
||||
return task.annotations
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_project (lua_State* L)
|
||||
{
|
||||
if (the_task != NULL)
|
||||
lua_pushstring (L, the_task->get ("project").c_str ());
|
||||
else
|
||||
lua_pushnil (L);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_priority (lua_State* L)
|
||||
{
|
||||
if (the_task != NULL)
|
||||
lua_pushstring (L, the_task->get ("priority").c_str ());
|
||||
else
|
||||
lua_pushnil (L);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_tags (id)
|
||||
{
|
||||
return task.tags
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_status (lua_State* L)
|
||||
{
|
||||
if (the_task != NULL)
|
||||
lua_pushstring (L, Task::statusToText (the_task->getStatus ()).c_str ());
|
||||
else
|
||||
lua_pushnil (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_recur (id)
|
||||
{
|
||||
return task.recur
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_get_until (lua_State* L)
|
||||
{
|
||||
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 (lua_State* L)
|
||||
{
|
||||
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
|
||||
-- as tables. A nil value indicates a missing value.
|
||||
static int api_task_set_description (id, value)
|
||||
{
|
||||
task.description = value
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_set_annotations (id, value)
|
||||
{
|
||||
task.annotations = value
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_set_project (id, value)
|
||||
{
|
||||
task.project = value
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_set_priority (id, value)
|
||||
{
|
||||
task.priority = value
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_set_tags (id, value)
|
||||
{
|
||||
task.tags = value
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_set_status (id, value)
|
||||
{
|
||||
task.status = value
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_set_due (id, value)
|
||||
{
|
||||
task.due_date = value
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_set_start (id, value)
|
||||
{
|
||||
task.start_date = value
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_set_recur (id, value)
|
||||
{
|
||||
task.recur = value
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_set_until (id, value)
|
||||
{
|
||||
task.until_date = value
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int api_task_set_wait (id, value)
|
||||
{
|
||||
task.wait_date = value
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
API::API ()
|
||||
: L (NULL)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
API::~API ()
|
||||
{
|
||||
if (L)
|
||||
{
|
||||
lua_close (L);
|
||||
L = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void API::initialize ()
|
||||
{
|
||||
// Initialize Lua.
|
||||
L = lua_open ();
|
||||
luaL_openlibs (L); // TODO Error handling
|
||||
|
||||
// Register all the API functions in Lua global space.
|
||||
lua_pushcfunction (L, api_task_version); lua_setglobal (L, "task_version");
|
||||
lua_pushcfunction (L, api_task_lua_version); lua_setglobal (L, "task_lua_version");
|
||||
lua_pushcfunction (L, api_task_os); lua_setglobal (L, "task_os");
|
||||
lua_pushcfunction (L, api_task_feature); lua_setglobal (L, "task_feature");
|
||||
/*
|
||||
lua_pushcfunction (L, api_task_aliases); lua_setglobal (L, "task_aliases");
|
||||
*/
|
||||
lua_pushcfunction (L, api_task_get_config); lua_setglobal (L, "task_get_config");
|
||||
/*
|
||||
lua_pushcfunction (L, api_task_set_config); lua_setglobal (L, "task_set_config");
|
||||
lua_pushcfunction (L, api_task_i18n_string); lua_setglobal (L, "task_i18n_string");
|
||||
lua_pushcfunction (L, api_task_i18n_tips); lua_setglobal (L, "task_i18n_tips");
|
||||
lua_pushcfunction (L, api_task_get_command); lua_setglobal (L, "task_get_command");
|
||||
lua_pushcfunction (L, api_task_get_header_messages); lua_setglobal (L, "task_get_header_messages");
|
||||
lua_pushcfunction (L, api_task_get_footnote_messages); lua_setglobal (L, "task_get_footnote_messages");
|
||||
lua_pushcfunction (L, api_task_get_debug_messages); lua_setglobal (L, "task_get_debug_messages");
|
||||
*/
|
||||
lua_pushcfunction (L, api_task_header_message); lua_setglobal (L, "task_header_message");
|
||||
lua_pushcfunction (L, api_task_footnote_message); lua_setglobal (L, "task_footnote_message");
|
||||
lua_pushcfunction (L, api_task_debug_message); lua_setglobal (L, "task_debug_message");
|
||||
lua_pushcfunction (L, api_task_exit); lua_setglobal (L, "task_exit");
|
||||
/*
|
||||
lua_pushcfunction (L, api_task_inhibit_further_hooks); lua_setglobal (L, "task_inhibit_further_hooks");
|
||||
lua_pushcfunction (L, api_task_get); lua_setglobal (L, "task_get");
|
||||
lua_pushcfunction (L, api_task_add); lua_setglobal (L, "task_add");
|
||||
lua_pushcfunction (L, api_task_modify); lua_setglobal (L, "task_modify");
|
||||
*/
|
||||
lua_pushcfunction (L, api_task_get_uuid); lua_setglobal (L, "task_get_uuid");
|
||||
lua_pushcfunction (L, api_task_get_description); lua_setglobal (L, "task_get_description");
|
||||
/*
|
||||
lua_pushcfunction (L, api_task_get_annotations); lua_setglobal (L, "task_get_annotations");
|
||||
*/
|
||||
lua_pushcfunction (L, api_task_get_project); lua_setglobal (L, "task_get_project");
|
||||
lua_pushcfunction (L, api_task_get_priority); lua_setglobal (L, "task_get_priority");
|
||||
/*
|
||||
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");
|
||||
lua_pushcfunction (L, api_task_set_priority); lua_setglobal (L, "task_set_priority");
|
||||
lua_pushcfunction (L, api_task_set_tags); lua_setglobal (L, "task_set_tags");
|
||||
lua_pushcfunction (L, api_task_set_status); lua_setglobal (L, "task_set_status");
|
||||
lua_pushcfunction (L, api_task_set_due); lua_setglobal (L, "task_set_due");
|
||||
lua_pushcfunction (L, api_task_set_start); lua_setglobal (L, "task_set_start");
|
||||
lua_pushcfunction (L, api_task_set_recur); lua_setglobal (L, "task_set_recur");
|
||||
lua_pushcfunction (L, api_task_set_until); lua_setglobal (L, "task_set_until");
|
||||
lua_pushcfunction (L, api_task_set_wait); lua_setglobal (L, "task_set_wait");
|
||||
*/
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool API::callProgramHook (
|
||||
const std::string& file,
|
||||
const std::string& function)
|
||||
{
|
||||
loadFile (file);
|
||||
|
||||
// Get function.
|
||||
lua_getglobal (L, function.c_str ());
|
||||
if (!lua_isfunction (L, -1))
|
||||
{
|
||||
lua_pop (L, 1);
|
||||
throw std::string ("The Lua function '") + function + "' was not found.";
|
||||
}
|
||||
|
||||
// Make call.
|
||||
if (lua_pcall (L, 0, 2, 0) != 0)
|
||||
throw std::string ("Error calling '") + function + "' - " + lua_tostring (L, -1);
|
||||
|
||||
// Call successful - get return values.
|
||||
if (!lua_isnumber (L, -2))
|
||||
throw std::string ("Error: '") + function + "' did not return a success indicator";
|
||||
|
||||
if (!lua_isstring (L, -1) && !lua_isnil (L, -1))
|
||||
throw std::string ("Error: '") + function + "' did not return a message or nil";
|
||||
|
||||
int rc = lua_tointeger (L, -2);
|
||||
const char* message = lua_tostring (L, -1);
|
||||
|
||||
if (rc == 0)
|
||||
{
|
||||
if (message)
|
||||
context.footnote (std::string ("Warning: ") + message);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (message)
|
||||
throw std::string (message);
|
||||
}
|
||||
|
||||
lua_pop (L, 1);
|
||||
return rc == 0 ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO No intention of implementing this before task 2.0. Why? Because we
|
||||
// need to implement a Lua iterator, in C++, to iterate over a std::vector.
|
||||
bool API::callListHook (
|
||||
const std::string& file,
|
||||
const std::string& function,
|
||||
std::vector <Task>& all)
|
||||
{
|
||||
loadFile (file);
|
||||
|
||||
// TODO Get function.
|
||||
// TODO Prepare args.
|
||||
// TODO Make call.
|
||||
// TODO Get exit status.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool API::callTaskHook (
|
||||
const std::string& file,
|
||||
const std::string& function,
|
||||
Task& task)
|
||||
{
|
||||
loadFile (file);
|
||||
|
||||
// Save the task for reference via the API.
|
||||
current = task;
|
||||
|
||||
// Get function.
|
||||
lua_getglobal (L, function.c_str ());
|
||||
if (!lua_isfunction (L, -1))
|
||||
{
|
||||
lua_pop (L, 1);
|
||||
throw std::string ("The Lua function '") + function + "' was not found.";
|
||||
}
|
||||
|
||||
// Prepare args.
|
||||
lua_pushnumber (L, current.id);
|
||||
|
||||
// Expose the task.
|
||||
the_task = ¤t;
|
||||
|
||||
// Make call.
|
||||
if (lua_pcall (L, 1, 2, 0) != 0)
|
||||
throw std::string ("Error calling '") + function + "' - " + lua_tostring (L, -1);
|
||||
|
||||
// Hide the task.
|
||||
the_task = NULL;
|
||||
|
||||
// Call successful - get return values.
|
||||
if (!lua_isnumber (L, -2))
|
||||
throw std::string ("Error: '") + function + "' did not return a success indicator";
|
||||
|
||||
if (!lua_isstring (L, -1) && !lua_isnil (L, -1))
|
||||
throw std::string ("Error: '") + function + "' did not return a message or nil";
|
||||
|
||||
int rc = lua_tointeger (L, -2);
|
||||
const char* message = lua_tostring (L, -1);
|
||||
|
||||
if (rc == 0)
|
||||
{
|
||||
if (message)
|
||||
context.footnote (std::string ("Warning: ") + message);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (message)
|
||||
throw std::string (message);
|
||||
}
|
||||
|
||||
lua_pop (L, 1);
|
||||
return rc == 0 ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool API::callFieldHook (
|
||||
const std::string& file,
|
||||
const std::string& function,
|
||||
const std::string& name,
|
||||
std::string& value)
|
||||
{
|
||||
loadFile (file);
|
||||
|
||||
// Get function.
|
||||
lua_getglobal (L, function.c_str ());
|
||||
if (!lua_isfunction (L, -1))
|
||||
{
|
||||
lua_pop (L, 1);
|
||||
throw std::string ("The Lua function '") + function + "' was not found.";
|
||||
}
|
||||
|
||||
// Prepare args.
|
||||
lua_pushstring (L, name.c_str ());
|
||||
lua_pushstring (L, value.c_str ());
|
||||
|
||||
// Make call.
|
||||
if (lua_pcall (L, 2, 3, 0) != 0)
|
||||
throw std::string ("Error calling '") + function + "' - " + lua_tostring (L, -1);
|
||||
|
||||
// Call successful - get return values.
|
||||
if (!lua_isstring (L, -3))
|
||||
throw std::string ("Error: '") + function + "' did not return a modified value";
|
||||
|
||||
if (!lua_isnumber (L, -2))
|
||||
throw std::string ("Error: '") + function + "' did not return a success indicator";
|
||||
|
||||
if (!lua_isstring (L, -1) && !lua_isnil (L, -1))
|
||||
throw std::string ("Error: '") + function + "' did not return a message or nil";
|
||||
|
||||
const char* new_value = lua_tostring (L, -3);
|
||||
int rc = lua_tointeger (L, -2);
|
||||
const char* message = lua_tostring (L, -1);
|
||||
|
||||
if (rc == 0)
|
||||
{
|
||||
// Overwrite with the modified value.
|
||||
value = new_value;
|
||||
|
||||
if (message)
|
||||
context.footnote (std::string ("Warning: ") + message);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (message)
|
||||
throw std::string (message);
|
||||
}
|
||||
|
||||
lua_pop (L, 1);
|
||||
return rc == 0 ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void API::loadFile (const std::string& file)
|
||||
{
|
||||
// If the file is not loaded.
|
||||
if (std::find (loaded.begin (), loaded.end (), file) == loaded.end ())
|
||||
{
|
||||
// Load the file, if possible.
|
||||
if (luaL_loadfile (L, file.c_str ()) || lua_pcall (L, 0, 0, 0))
|
||||
throw std::string ("Error: ") + std::string (lua_tostring (L, -1));
|
||||
|
||||
// Mark this as loaded, so as to not bother again.
|
||||
loaded.push_back (file);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
|
||||
74
src/API.h
74
src/API.h
@@ -1,74 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef INCLUDED_API
|
||||
#define INCLUDED_API
|
||||
|
||||
#include "auto.h"
|
||||
#ifdef HAVE_LIBLUA
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "Task.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "lua.h"
|
||||
#include "lualib.h"
|
||||
#include "lauxlib.h"
|
||||
}
|
||||
|
||||
class API
|
||||
{
|
||||
public:
|
||||
API ();
|
||||
API (const API&);
|
||||
API& operator= (const API&);
|
||||
~API ();
|
||||
|
||||
void initialize ();
|
||||
bool callProgramHook (const std::string&, const std::string&);
|
||||
bool callListHook (const std::string&, const std::string&, std::vector <Task>&);
|
||||
bool callTaskHook (const std::string&, const std::string&, Task&);
|
||||
bool callFieldHook (const std::string&, const std::string&, const std::string&, std::string&);
|
||||
|
||||
private:
|
||||
void loadFile (const std::string&);
|
||||
|
||||
public:
|
||||
lua_State* L;
|
||||
std::vector <std::string> loaded;
|
||||
|
||||
// Context for the API.
|
||||
// std::vector <Task> all;
|
||||
Task current;
|
||||
// std::string& name;
|
||||
// std::string& value;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
205
src/Att.cpp
205
src/Att.cpp
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "text.h"
|
||||
#include "Color.h"
|
||||
#include "color.h"
|
||||
#include "util.h"
|
||||
#include "Date.h"
|
||||
#include "Duration.h"
|
||||
@@ -50,7 +50,6 @@ static const char* internalNames[] =
|
||||
"limit",
|
||||
"status",
|
||||
"description",
|
||||
// Note that annotations are not listed.
|
||||
};
|
||||
|
||||
static const char* modifiableNames[] =
|
||||
@@ -78,8 +77,6 @@ static const char* modifierNames[] =
|
||||
"hasnt",
|
||||
"startswith", "left",
|
||||
"endswith", "right",
|
||||
"word",
|
||||
"noword"
|
||||
};
|
||||
|
||||
#define NUM_INTERNAL_NAMES (sizeof (internalNames) / sizeof (internalNames[0]))
|
||||
@@ -105,7 +102,7 @@ Att::Att (const std::string& name, const std::string& mod, const std::string& va
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Att::Att (const std::string& name, const std::string& mod, int value)
|
||||
{
|
||||
mName = name;
|
||||
mName = name;
|
||||
|
||||
std::stringstream s;
|
||||
s << value;
|
||||
@@ -125,7 +122,7 @@ Att::Att (const std::string& name, const std::string& value)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Att::Att (const std::string& name, int value)
|
||||
{
|
||||
mName = name;
|
||||
mName = name;
|
||||
|
||||
std::stringstream s;
|
||||
s << value;
|
||||
@@ -155,14 +152,6 @@ Att& Att::operator= (const Att& other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Att::operator== (const Att& other) const
|
||||
{
|
||||
return mName == other.mName &&
|
||||
mMod == other.mMod &&
|
||||
mValue == other.mValue;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Att::~Att ()
|
||||
{
|
||||
@@ -330,8 +319,8 @@ bool Att::validNameValue (
|
||||
|
||||
else if (name == "fg" || name == "bg")
|
||||
{
|
||||
// TODO Determine whether color abbreviations are supported, and if so,
|
||||
// modify 'value' here accordingly.
|
||||
if (value != "")
|
||||
Text::guessColor (value);
|
||||
}
|
||||
|
||||
else if (name == "due" ||
|
||||
@@ -340,7 +329,7 @@ bool Att::validNameValue (
|
||||
{
|
||||
// Validate and convert to epoch.
|
||||
if (value != "")
|
||||
value = Date (value, context.config.get ("dateformat")).toEpochString ();
|
||||
value = Date (value, context.config.get ("dateformat", "m/d/Y")).toEpochString ();
|
||||
}
|
||||
|
||||
else if (name == "recur")
|
||||
@@ -353,8 +342,8 @@ bool Att::validNameValue (
|
||||
|
||||
else if (name == "limit")
|
||||
{
|
||||
if (value == "" || (value != "page" && !digitsOnly (value)))
|
||||
throw std::string ("The '") + name + "' attribute must be an integer, or the value 'page'.";
|
||||
if (value == "" || !digitsOnly (value))
|
||||
throw std::string ("The '") + name + "' attribute must be an integer.";
|
||||
}
|
||||
|
||||
else if (name == "status")
|
||||
@@ -386,7 +375,7 @@ bool Att::validNameValue (
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO Deprecated - remove.
|
||||
// TODO Obsolete
|
||||
bool Att::validMod (const std::string& mod)
|
||||
{
|
||||
for (unsigned int i = 0; i < NUM_MODIFIER_NAMES; ++i)
|
||||
@@ -414,26 +403,10 @@ std::string Att::type (const std::string& name) const
|
||||
else if (name == "limit")
|
||||
return "number";
|
||||
|
||||
else if (name == "priority")
|
||||
return "priority";
|
||||
|
||||
else
|
||||
return "text";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The type of an attribute is useful for modifier evaluation.
|
||||
std::string Att::modType (const std::string& name) const
|
||||
{
|
||||
if (name == "hasnt" ||
|
||||
name == "isnt" ||
|
||||
name == "not" || // TODO Verify this.
|
||||
name == "noword")
|
||||
return "negative";
|
||||
|
||||
return "positive";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// start --> name --> . --> mod --> : --> " --> value --> " --> end
|
||||
@@ -488,7 +461,7 @@ void Att::parse (Nibbler& n)
|
||||
else
|
||||
throw std::string ("Missing : after attribute name"); // TODO i18n
|
||||
|
||||
/* TODO This might be too slow to include. Test this assumption.
|
||||
/* TODO This might be too slow to include. Test.
|
||||
validNameValue (mName, mMod, mValue);
|
||||
*/
|
||||
}
|
||||
@@ -499,49 +472,32 @@ void Att::parse (Nibbler& n)
|
||||
bool Att::match (const Att& other) const
|
||||
{
|
||||
// All matches are assumed to pass, any short-circuit on non-match.
|
||||
bool case_sensitive = context.config.getBoolean ("search.case.sensitive");
|
||||
|
||||
// If there are no mods, just perform a straight compare on value.
|
||||
if (mMod == "")
|
||||
{
|
||||
// Exact matches on dates should only compare m/d/y, not h:m:s. This allows
|
||||
// Comapisons like "task list due:today" (bug #405).
|
||||
std::string which = type (mName);
|
||||
if (which == "date")
|
||||
{
|
||||
Date left (mValue);
|
||||
Date right (other.mValue);
|
||||
|
||||
if (left.year () != right.year () ||
|
||||
left.month () != right.month () ||
|
||||
left.day () != right.day ())
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!compare (mValue, other.mValue, (bool) case_sensitive))
|
||||
return false;
|
||||
}
|
||||
if (mValue != other.mValue)
|
||||
return false;
|
||||
}
|
||||
|
||||
// has = contains as a substring.
|
||||
else if (mMod == "has" || mMod == "contains") // TODO i18n
|
||||
{
|
||||
if (find (other.mValue, mValue, (bool) case_sensitive) == std::string::npos)
|
||||
if (other.mValue.find (mValue) == std::string::npos)
|
||||
return false;
|
||||
}
|
||||
|
||||
// is = equal. Nop.
|
||||
else if (mMod == "is" || mMod == "equals") // TODO i18n
|
||||
{
|
||||
if (!compare (mValue, other.mValue, (bool) case_sensitive))
|
||||
if (mValue != other.mValue)
|
||||
return false;
|
||||
}
|
||||
|
||||
// isnt = not equal.
|
||||
else if (mMod == "isnt" || mMod == "not") // TODO i18n
|
||||
{
|
||||
if (compare (mValue, other.mValue, (bool) case_sensitive))
|
||||
if (mValue == other.mValue)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -565,7 +521,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 ()), (bool) case_sensitive))
|
||||
if (mValue != other.mValue.substr (0, mValue.length ()))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -575,16 +531,16 @@ bool Att::match (const Att& other) const
|
||||
if (other.mValue.length () < mValue.length ())
|
||||
return false;
|
||||
|
||||
if (!compare (mValue, other.mValue.substr (
|
||||
if (mValue != other.mValue.substr (
|
||||
other.mValue.length () - mValue.length (),
|
||||
std::string::npos), (bool) case_sensitive))
|
||||
std::string::npos))
|
||||
return false;
|
||||
}
|
||||
|
||||
// hasnt = does not contain as a substring.
|
||||
else if (mMod == "hasnt") // TODO i18n
|
||||
{
|
||||
if (find (other.mValue, mValue, (bool) case_sensitive) != std::string::npos)
|
||||
if (other.mValue.find (mValue) != std::string::npos)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -595,20 +551,20 @@ bool Att::match (const Att& other) const
|
||||
if (which == "duration")
|
||||
{
|
||||
Duration literal (mValue);
|
||||
Duration variable ((time_t)atoi (other.mValue.c_str ()));
|
||||
Duration variable ((time_t)::atoi (other.mValue.c_str ()));
|
||||
if (!(variable < literal))
|
||||
return false;
|
||||
}
|
||||
else if (which == "date")
|
||||
{
|
||||
Date literal (mValue.c_str (), context.config.get ("dateformat"));
|
||||
Date variable ((time_t)atoi (other.mValue.c_str ()));
|
||||
Date literal (mValue.c_str (), context.config.get ("dateformat", "m/d/Y"));
|
||||
Date variable ((time_t)::atoi (other.mValue.c_str ()));
|
||||
if (other.mValue == "" || ! (variable < literal))
|
||||
return false;
|
||||
}
|
||||
else if (which == "number")
|
||||
{
|
||||
if (atoi (mValue.c_str ()) >= atoi (other.mValue.c_str ()))
|
||||
if (::atoi (mValue.c_str ()) >= ::atoi (other.mValue.c_str ()))
|
||||
return false;
|
||||
}
|
||||
else if (which == "text")
|
||||
@@ -616,14 +572,6 @@ bool Att::match (const Att& other) const
|
||||
if (mValue <= other.mValue)
|
||||
return false;
|
||||
}
|
||||
else if (which == "priority")
|
||||
{
|
||||
if (mValue == "" ||
|
||||
other.mValue == "H" ||
|
||||
mValue == other.mValue ||
|
||||
(mValue == "L" && other.mValue == "M"))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// after = over = above = >
|
||||
@@ -633,20 +581,20 @@ bool Att::match (const Att& other) const
|
||||
if (which == "duration")
|
||||
{
|
||||
Duration literal (mValue);
|
||||
Duration variable ((time_t)atoi (other.mValue.c_str ()));
|
||||
Duration variable ((time_t)::atoi (other.mValue.c_str ()));
|
||||
if (! (variable > literal))
|
||||
return false;
|
||||
}
|
||||
else if (which == "date")
|
||||
{
|
||||
Date literal (mValue.c_str (), context.config.get ("dateformat"));
|
||||
Date variable ((time_t)atoi (other.mValue.c_str ()));
|
||||
Date literal (mValue.c_str (), context.config.get ("dateformat", "m/d/Y"));
|
||||
Date variable ((time_t)::atoi (other.mValue.c_str ()));
|
||||
if (! (variable > literal))
|
||||
return false;
|
||||
}
|
||||
else if (which == "number")
|
||||
{
|
||||
if (atoi (mValue.c_str ()) <= atoi (other.mValue.c_str ()))
|
||||
if (::atoi (mValue.c_str ()) <= ::atoi (other.mValue.c_str ()))
|
||||
return false;
|
||||
}
|
||||
else if (which == "text")
|
||||
@@ -654,43 +602,6 @@ bool Att::match (const Att& other) const
|
||||
if (mValue >= other.mValue)
|
||||
return false;
|
||||
}
|
||||
else if (which == "priority")
|
||||
{
|
||||
if (mValue == "H" ||
|
||||
other.mValue == "" ||
|
||||
mValue == other.mValue ||
|
||||
(mValue == "M" && other.mValue == "L"))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// word = contains as a substring, with word boundaries.
|
||||
else if (mMod == "word") // TODO i18n
|
||||
{
|
||||
// Fail if the substring is not found.
|
||||
std::string::size_type sub = find (other.mValue, mValue, (bool) case_sensitive);
|
||||
if (sub == std::string::npos)
|
||||
return false;
|
||||
|
||||
// Also fail if there is no word boundary at beginning and end.
|
||||
if (!isWordStart (other.mValue, sub))
|
||||
return false;
|
||||
|
||||
if (!isWordEnd (other.mValue, sub + mValue.length () - 1))
|
||||
return false;
|
||||
}
|
||||
|
||||
// noword = does not contain as a substring, with word boundaries.
|
||||
else if (mMod == "noword") // TODO i18n
|
||||
{
|
||||
// Fail if the substring is not found.
|
||||
std::string::size_type sub = find (other.mValue, mValue);
|
||||
if (sub != std::string::npos &&
|
||||
isWordStart (other.mValue, sub) &&
|
||||
isWordEnd (other.mValue, sub + mValue.length () - 1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -756,20 +667,7 @@ void Att::value (const std::string& value)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Att::value_int () const
|
||||
{
|
||||
return atoi (mValue.c_str ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Att::allNames (std::vector <std::string>& all)
|
||||
{
|
||||
all.clear ();
|
||||
|
||||
unsigned int i;
|
||||
for (i = 0; i < NUM_INTERNAL_NAMES; ++i)
|
||||
all.push_back (internalNames[i]);
|
||||
|
||||
for (i = 0; i < NUM_MODIFIABLE_NAMES; ++i)
|
||||
all.push_back (modifiableNames[i]);
|
||||
return ::atoi (mValue.c_str ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -801,9 +699,11 @@ void Att::dequote (std::string& value) const
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Encode values prior to serialization.
|
||||
// \t -> &tab;
|
||||
// " -> &dquot;
|
||||
// " -> "
|
||||
// , -> ,
|
||||
// [ -> &open;
|
||||
// ] -> &close;
|
||||
// : -> :
|
||||
void Att::encode (std::string& value) const
|
||||
{
|
||||
std::string::size_type i;
|
||||
@@ -812,20 +712,25 @@ void Att::encode (std::string& value) const
|
||||
value.replace (i, 1, "&tab;"); // no i18n
|
||||
|
||||
while ((i = value.find ('"')) != std::string::npos)
|
||||
value.replace (i, 1, "&dquot;"); // no i18n
|
||||
value.replace (i, 1, """); // no i18n
|
||||
|
||||
while ((i = value.find (',')) != std::string::npos)
|
||||
value.replace (i, 1, ","); // no i18n
|
||||
|
||||
while ((i = value.find ('[')) != std::string::npos)
|
||||
value.replace (i, 1, "&open;"); // no i18n
|
||||
|
||||
while ((i = value.find (']')) != std::string::npos)
|
||||
value.replace (i, 1, "&close;"); // no i18n
|
||||
|
||||
while ((i = value.find (':')) != std::string::npos)
|
||||
value.replace (i, 1, ":"); // no i18n
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Decode values after parse.
|
||||
// \t <- &tab;
|
||||
// " <- " or &dquot;
|
||||
// ' <- &squot;
|
||||
// " <- "
|
||||
// , <- ,
|
||||
// [ <- &open;
|
||||
// ] <- &close;
|
||||
@@ -834,32 +739,22 @@ void Att::decode (std::string& value) const
|
||||
{
|
||||
std::string::size_type i;
|
||||
|
||||
// Supported encodings.
|
||||
while ((i = value.find ("&tab;")) != std::string::npos)
|
||||
while ((i = value.find ("&tab;")) != std::string::npos) // no i18n
|
||||
value.replace (i, 5, "\t");
|
||||
|
||||
while ((i = value.find ("&dquot;")) != std::string::npos)
|
||||
value.replace (i, 7, "\"");
|
||||
|
||||
while ((i = value.find (""")) != std::string::npos)
|
||||
while ((i = value.find (""")) != std::string::npos) // no i18n
|
||||
value.replace (i, 6, "\"");
|
||||
|
||||
while ((i = value.find ("&open;")) != std::string::npos)
|
||||
value.replace (i, 6, "[");
|
||||
|
||||
while ((i = value.find ("&close;")) != std::string::npos)
|
||||
value.replace (i, 7, "]");
|
||||
|
||||
// Support for deprecated encodings. These cannot be removed or old files
|
||||
// will not be parsable. Not just old files - completed.data can contain
|
||||
// tasks formatted/encoded using these.
|
||||
while ((i = value.find ("&squot;")) != std::string::npos)
|
||||
value.replace (i, 7, "'");
|
||||
|
||||
while ((i = value.find (",")) != std::string::npos)
|
||||
while ((i = value.find (",")) != std::string::npos) // no i18n
|
||||
value.replace (i, 7, ",");
|
||||
|
||||
while ((i = value.find (":")) != std::string::npos)
|
||||
while ((i = value.find ("&open;")) != std::string::npos) // no i18n
|
||||
value.replace (i, 6, "[");
|
||||
|
||||
while ((i = value.find ("&close;")) != std::string::npos) // no i18n
|
||||
value.replace (i, 7, "]");
|
||||
|
||||
while ((i = value.find (":")) != std::string::npos) // no i18n
|
||||
value.replace (i, 7, ":");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -41,7 +41,6 @@ public:
|
||||
Att (const std::string&, int);
|
||||
Att (const Att&);
|
||||
Att& operator= (const Att&);
|
||||
bool operator== (const Att&) const;
|
||||
~Att ();
|
||||
|
||||
bool valid (const std::string&) const;
|
||||
@@ -51,7 +50,6 @@ public:
|
||||
static bool validNameValue (std::string&, std::string&, std::string&);
|
||||
static bool validMod (const std::string&);
|
||||
std::string type (const std::string&) const;
|
||||
std::string modType (const std::string&) const;
|
||||
void parse (const std::string&);
|
||||
void parse (Nibbler&);
|
||||
bool match (const Att&) const;
|
||||
@@ -70,8 +68,6 @@ public:
|
||||
int value_int () const;
|
||||
void value_int (int);
|
||||
|
||||
static void allNames (std::vector <std::string>&);
|
||||
|
||||
private:
|
||||
void enquote (std::string&) const;
|
||||
void dequote (std::string&) const;
|
||||
|
||||
117
src/Cmd.cpp
117
src/Cmd.cpp
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -105,51 +105,38 @@ void Cmd::load ()
|
||||
{
|
||||
if (commands.size () == 0)
|
||||
{
|
||||
// Commands whose names are not localized.
|
||||
commands.push_back ("_projects");
|
||||
commands.push_back ("_tags");
|
||||
commands.push_back ("_commands");
|
||||
commands.push_back ("_ids");
|
||||
commands.push_back ("_config");
|
||||
commands.push_back ("_version");
|
||||
commands.push_back ("_merge");
|
||||
commands.push_back ("export.csv");
|
||||
commands.push_back ("export.ical");
|
||||
commands.push_back ("history.monthly");
|
||||
commands.push_back ("history.annual");
|
||||
commands.push_back ("ghistory.monthly");
|
||||
commands.push_back ("ghistory.annual");
|
||||
|
||||
// Commands whose names are localized.
|
||||
commands.push_back (context.stringtable.get (CMD_ADD, "add"));
|
||||
commands.push_back (context.stringtable.get (CMD_APPEND, "append"));
|
||||
commands.push_back (context.stringtable.get (CMD_ANNOTATE, "annotate"));
|
||||
commands.push_back (context.stringtable.get (CMD_DENOTATE, "denotate"));
|
||||
commands.push_back (context.stringtable.get (CMD_CALENDAR, "calendar"));
|
||||
commands.push_back (context.stringtable.get (CMD_COLORS, "colors"));
|
||||
commands.push_back (context.stringtable.get (CMD_CONFIG, "config"));
|
||||
commands.push_back (context.stringtable.get (CMD_SHOW, "show"));
|
||||
commands.push_back (context.stringtable.get (CMD_DELETE, "delete"));
|
||||
commands.push_back (context.stringtable.get (CMD_DONE, "done"));
|
||||
commands.push_back (context.stringtable.get (CMD_DUPLICATE, "duplicate"));
|
||||
commands.push_back (context.stringtable.get (CMD_EDIT, "edit"));
|
||||
commands.push_back (context.stringtable.get (CMD_HELP, "help"));
|
||||
commands.push_back (context.stringtable.get (CMD_IMPORT, "import"));
|
||||
commands.push_back (context.stringtable.get (CMD_INFO, "info"));
|
||||
commands.push_back (context.stringtable.get (CMD_LOG, "log"));
|
||||
commands.push_back (context.stringtable.get (CMD_PREPEND, "prepend"));
|
||||
commands.push_back (context.stringtable.get (CMD_PROJECTS, "projects"));
|
||||
commands.push_back (context.stringtable.get (CMD_ADD, "add"));
|
||||
commands.push_back (context.stringtable.get (CMD_APPEND, "append"));
|
||||
commands.push_back (context.stringtable.get (CMD_ANNOTATE, "annotate"));
|
||||
commands.push_back (context.stringtable.get (CMD_CALENDAR, "calendar"));
|
||||
commands.push_back (context.stringtable.get (CMD_COLORS, "colors"));
|
||||
commands.push_back (context.stringtable.get (CMD_DELETE, "delete"));
|
||||
commands.push_back (context.stringtable.get (CMD_DONE, "done"));
|
||||
commands.push_back (context.stringtable.get (CMD_DUPLICATE, "duplicate"));
|
||||
commands.push_back (context.stringtable.get (CMD_EDIT, "edit"));
|
||||
commands.push_back (context.stringtable.get (CMD_EXPORT, "export"));
|
||||
commands.push_back (context.stringtable.get (CMD_HELP, "help"));
|
||||
commands.push_back (context.stringtable.get (CMD_HISTORY, "history"));
|
||||
commands.push_back (context.stringtable.get (CMD_GHISTORY, "ghistory"));
|
||||
commands.push_back (context.stringtable.get (CMD_IMPORT, "import"));
|
||||
commands.push_back (context.stringtable.get (CMD_INFO, "info"));
|
||||
commands.push_back (context.stringtable.get (CMD_PROJECTS, "projects"));
|
||||
#ifdef FEATURE_SHELL
|
||||
commands.push_back (context.stringtable.get (CMD_SHELL, "shell"));
|
||||
commands.push_back (context.stringtable.get (CMD_SHELL, "shell"));
|
||||
#endif
|
||||
commands.push_back (context.stringtable.get (CMD_START, "start"));
|
||||
commands.push_back (context.stringtable.get (CMD_STATS, "stats"));
|
||||
commands.push_back (context.stringtable.get (CMD_STOP, "stop"));
|
||||
commands.push_back (context.stringtable.get (CMD_SUMMARY, "summary"));
|
||||
commands.push_back (context.stringtable.get (CMD_TAGS, "tags"));
|
||||
commands.push_back (context.stringtable.get (CMD_TIMESHEET, "timesheet"));
|
||||
commands.push_back (context.stringtable.get (CMD_UNDO, "undo"));
|
||||
commands.push_back (context.stringtable.get (CMD_VERSION, "version"));
|
||||
commands.push_back (context.stringtable.get (CMD_START, "start"));
|
||||
commands.push_back (context.stringtable.get (CMD_STATS, "stats"));
|
||||
commands.push_back (context.stringtable.get (CMD_STOP, "stop"));
|
||||
commands.push_back (context.stringtable.get (CMD_SUMMARY, "summary"));
|
||||
commands.push_back (context.stringtable.get (CMD_TAGS, "tags"));
|
||||
commands.push_back (context.stringtable.get (CMD_TIMESHEET, "timesheet"));
|
||||
commands.push_back (context.stringtable.get (CMD_UNDO, "undo"));
|
||||
commands.push_back (context.stringtable.get (CMD_VERSION, "version"));
|
||||
|
||||
// Now load the custom reports.
|
||||
std::vector <std::string> all;
|
||||
@@ -159,7 +146,7 @@ void Cmd::load ()
|
||||
{
|
||||
if (i->substr (0, 7) == "report.")
|
||||
{
|
||||
std::string report = i->substr (7);
|
||||
std::string report = i->substr (7, std::string::npos);
|
||||
std::string::size_type columns = report.find (".columns");
|
||||
if (columns != std::string::npos)
|
||||
{
|
||||
@@ -199,31 +186,25 @@ void Cmd::allCommands (std::vector <std::string>& all) const
|
||||
// Commands that do not directly modify the data files.
|
||||
bool Cmd::isReadOnlyCommand ()
|
||||
{
|
||||
if (command == "_projects" ||
|
||||
command == "_tags" ||
|
||||
command == "_commands" ||
|
||||
command == "_ids" ||
|
||||
command == "_config" ||
|
||||
command == "_version" ||
|
||||
command == "export.csv" ||
|
||||
command == "export.ical" ||
|
||||
command == "history.monthly" ||
|
||||
command == "history.annual" ||
|
||||
command == "ghistory.monthly" ||
|
||||
command == "ghistory.annual" ||
|
||||
command == context.stringtable.get (CMD_CALENDAR, "calendar") ||
|
||||
command == context.stringtable.get (CMD_COLORS, "colors") ||
|
||||
command == context.stringtable.get (CMD_CONFIG, "config") ||
|
||||
command == context.stringtable.get (CMD_SHOW, "show") ||
|
||||
command == context.stringtable.get (CMD_HELP, "help") ||
|
||||
command == context.stringtable.get (CMD_INFO, "info") ||
|
||||
command == context.stringtable.get (CMD_PROJECTS, "projects") ||
|
||||
command == context.stringtable.get (CMD_SHELL, "shell") ||
|
||||
command == context.stringtable.get (CMD_STATS, "stats") ||
|
||||
command == context.stringtable.get (CMD_SUMMARY, "summary") ||
|
||||
command == context.stringtable.get (CMD_TAGS, "tags") ||
|
||||
command == context.stringtable.get (CMD_TIMESHEET, "timesheet") ||
|
||||
command == context.stringtable.get (CMD_VERSION, "version") ||
|
||||
if (command == "_projects" ||
|
||||
command == "_tags" ||
|
||||
command == "_commands" ||
|
||||
command == "_ids" ||
|
||||
command == "_config" ||
|
||||
command == context.stringtable.get (CMD_CALENDAR, "calendar") ||
|
||||
command == context.stringtable.get (CMD_COLORS, "colors") ||
|
||||
command == context.stringtable.get (CMD_EXPORT, "export") ||
|
||||
command == context.stringtable.get (CMD_HELP, "help") ||
|
||||
command == context.stringtable.get (CMD_HISTORY, "history") ||
|
||||
command == context.stringtable.get (CMD_GHISTORY, "ghistory") ||
|
||||
command == context.stringtable.get (CMD_INFO, "info") ||
|
||||
command == context.stringtable.get (CMD_PROJECTS, "projects") ||
|
||||
command == context.stringtable.get (CMD_SHELL, "shell") ||
|
||||
command == context.stringtable.get (CMD_STATS, "stats") ||
|
||||
command == context.stringtable.get (CMD_SUMMARY, "summary") ||
|
||||
command == context.stringtable.get (CMD_TAGS, "tags") ||
|
||||
command == context.stringtable.get (CMD_TIMESHEET, "timesheet") ||
|
||||
command == context.stringtable.get (CMD_VERSION, "version") ||
|
||||
validCustom (command))
|
||||
return true;
|
||||
|
||||
@@ -234,18 +215,14 @@ bool Cmd::isReadOnlyCommand ()
|
||||
// Commands that directly modify the data files.
|
||||
bool Cmd::isWriteCommand ()
|
||||
{
|
||||
if (command == "_merge" ||
|
||||
command == context.stringtable.get (CMD_ADD, "add") ||
|
||||
if (command == context.stringtable.get (CMD_ADD, "add") ||
|
||||
command == context.stringtable.get (CMD_APPEND, "append") ||
|
||||
command == context.stringtable.get (CMD_ANNOTATE, "annotate") ||
|
||||
command == context.stringtable.get (CMD_DENOTATE, "denotate") ||
|
||||
command == context.stringtable.get (CMD_DELETE, "delete") ||
|
||||
command == context.stringtable.get (CMD_DONE, "done") ||
|
||||
command == context.stringtable.get (CMD_DUPLICATE, "duplicate") ||
|
||||
command == context.stringtable.get (CMD_EDIT, "edit") ||
|
||||
command == context.stringtable.get (CMD_IMPORT, "import") ||
|
||||
command == context.stringtable.get (CMD_LOG, "log") ||
|
||||
command == context.stringtable.get (CMD_PREPEND, "prepend") ||
|
||||
command == context.stringtable.get (CMD_START, "start") ||
|
||||
command == context.stringtable.get (CMD_STOP, "stop") ||
|
||||
command == context.stringtable.get (CMD_UNDO, "undo"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
|
||||
557
src/Color.cpp
557
src/Color.cpp
@@ -1,557 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include "Color.h"
|
||||
#include "text.h"
|
||||
#include "i18n.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static struct
|
||||
{
|
||||
Color::color_id id;
|
||||
int string_id;
|
||||
std::string english_name;
|
||||
int index; // offset red=3 (therefore fg=33, bg=43)
|
||||
} allColors[] =
|
||||
{
|
||||
// Color.h enum i18n.h English Index
|
||||
{ Color::nocolor, 0, "none", 0},
|
||||
{ Color::black, CCOLOR_BLACK, "black", 1}, // fg 29+0 bg 39+0
|
||||
{ Color::red, CCOLOR_RED, "red", 2},
|
||||
{ Color::green, CCOLOR_GREEN, "green", 3},
|
||||
{ Color::yellow, CCOLOR_YELLOW, "yellow", 4},
|
||||
{ Color::blue, CCOLOR_BLUE, "blue", 5},
|
||||
{ Color::magenta, CCOLOR_MAGENTA, "magenta", 6},
|
||||
{ Color::cyan, CCOLOR_CYAN, "cyan", 7},
|
||||
{ Color::white, CCOLOR_WHITE, "white", 8},
|
||||
|
||||
};
|
||||
|
||||
#define NUM_COLORS (sizeof (allColors) / sizeof (allColors[0]))
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Color::Color ()
|
||||
: value (0)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Color::Color (const Color& other)
|
||||
{
|
||||
value = other.value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Color::Color (unsigned int c)
|
||||
: value (0)
|
||||
{
|
||||
if (!(c & _COLOR_HASFG)) value &= ~_COLOR_FG;
|
||||
if (!(c & _COLOR_HASBG)) value &= ~_COLOR_BG;
|
||||
|
||||
value = c & (_COLOR_256 | _COLOR_HASBG | _COLOR_HASFG |_COLOR_UNDERLINE |
|
||||
_COLOR_BOLD | _COLOR_BRIGHT | _COLOR_BG | _COLOR_FG);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Supports the following constructs:
|
||||
// [bright] [color] [on color] [bright] [underline]
|
||||
//
|
||||
// Where [color] is one of:
|
||||
// black
|
||||
// red
|
||||
// ...
|
||||
// grayN 0 <= N <= 23 fg 38;5;232 + N bg 48;5;232 + N
|
||||
// greyN 0 <= N <= 23 fg 38;5;232 + N bg 48;5;232 + N
|
||||
// colorN 0 <= N <= 255 fg 38;5;N bg 48;5;N
|
||||
// rgbRGB 0 <= R,G,B <= 5 fg 38;5;16 + R*36 + G*6 + B bg 48;5;16 + R*36 + G*6 + B
|
||||
Color::Color (const std::string& spec)
|
||||
: value (0)
|
||||
{
|
||||
// By converting underscores to spaces, we inherently support the old "on_red"
|
||||
// style of specifying background colors. We consider underscores to be
|
||||
// deprecated.
|
||||
std::string modifiable_spec = spec;
|
||||
std::replace (modifiable_spec.begin (), modifiable_spec.end (), '_', ' ');
|
||||
|
||||
// Split spec into words.
|
||||
std::vector <std::string> words;
|
||||
split (words, modifiable_spec, ' ');
|
||||
|
||||
// Construct the color as two separate colors, then blend them later. This
|
||||
// make it possible to declare a color such as "color1 on black", and have
|
||||
// the upgrade work properly.
|
||||
unsigned int fg_value = 0;
|
||||
unsigned int bg_value = 0;
|
||||
|
||||
bool bg = false;
|
||||
int index;
|
||||
std::string word;
|
||||
std::vector <std::string>::iterator it;
|
||||
for (it = words.begin (); it != words.end (); ++it)
|
||||
{
|
||||
word = lowerCase (trim (*it));
|
||||
|
||||
if (word == "bold") fg_value |= _COLOR_BOLD;
|
||||
else if (word == "bright") bg_value |= _COLOR_BRIGHT;
|
||||
else if (word == "underline") fg_value |= _COLOR_UNDERLINE;
|
||||
else if (word == "on") bg = true;
|
||||
|
||||
// X where X is one of black, red, blue ...
|
||||
else if ((index = find (word)) != -1)
|
||||
{
|
||||
if (bg)
|
||||
{
|
||||
bg_value |= _COLOR_HASBG;
|
||||
bg_value |= index << 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
fg_value |= _COLOR_HASFG;
|
||||
fg_value |= index;
|
||||
}
|
||||
}
|
||||
|
||||
// greyN/grayN, where 0 <= N <= 23.
|
||||
else if (word.substr (0, 4) == "grey" ||
|
||||
word.substr (0, 4) == "gray")
|
||||
{
|
||||
index = atoi (word.substr (4).c_str ());
|
||||
if (index < 0 || index > 23)
|
||||
throw std::string ("The color '") + *it + "' is not recognized.";
|
||||
|
||||
if (bg)
|
||||
{
|
||||
bg_value |= _COLOR_HASBG;
|
||||
bg_value |= (index + 232) << 8;
|
||||
bg_value |= _COLOR_256;
|
||||
}
|
||||
else
|
||||
{
|
||||
fg_value |= _COLOR_HASFG;
|
||||
fg_value |= index + 232;
|
||||
fg_value |= _COLOR_256;
|
||||
}
|
||||
}
|
||||
|
||||
// rgbRGB, where 0 <= R,G,B <= 5.
|
||||
else if (word.substr (0, 3) == "rgb")
|
||||
{
|
||||
index = atoi (word.substr (3).c_str ());
|
||||
if (word.length () != 6 ||
|
||||
index < 0 || index > 555)
|
||||
throw std::string ("The color '") + *it + "' is not recognized.";
|
||||
|
||||
int r = atoi (word.substr (3, 1).c_str ());
|
||||
int g = atoi (word.substr (4, 1).c_str ());
|
||||
int b = atoi (word.substr (5, 1).c_str ());
|
||||
if (r < 0 || r > 5 ||
|
||||
g < 0 || g > 5 ||
|
||||
b < 0 || b > 5)
|
||||
throw std::string ("The color '") + *it + "' is not recognized.";
|
||||
|
||||
index = 16 + r*36 + g*6 + b;
|
||||
|
||||
if (bg)
|
||||
{
|
||||
bg_value |= _COLOR_HASBG;
|
||||
bg_value |= index << 8;
|
||||
bg_value |= _COLOR_256;
|
||||
}
|
||||
else
|
||||
{
|
||||
fg_value |= _COLOR_HASFG;
|
||||
fg_value |= index;
|
||||
fg_value |= _COLOR_256;
|
||||
}
|
||||
}
|
||||
|
||||
// colorN, where 0 <= N <= 255.
|
||||
else if (word.substr (0, 5) == "color")
|
||||
{
|
||||
index = atoi (word.substr (5).c_str ());
|
||||
if (index < 0 || index > 255)
|
||||
throw std::string ("The color '") + *it + "' is not recognized.";
|
||||
|
||||
upgrade ();
|
||||
|
||||
if (bg)
|
||||
{
|
||||
bg_value |= _COLOR_HASBG;
|
||||
bg_value |= index << 8;
|
||||
bg_value |= _COLOR_256;
|
||||
}
|
||||
else
|
||||
{
|
||||
fg_value |= _COLOR_HASFG;
|
||||
fg_value |= index;
|
||||
fg_value |= _COLOR_256;
|
||||
}
|
||||
}
|
||||
else if (word != "")
|
||||
throw std::string ("The color '") + *it + "' is not recognized.";
|
||||
}
|
||||
|
||||
// Now combine the fg and bg into a single color.
|
||||
value = fg_value;
|
||||
blend (Color (bg_value));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Color::Color (color_id fg)
|
||||
: value (0)
|
||||
{
|
||||
if (fg != Color::nocolor)
|
||||
{
|
||||
value |= _COLOR_HASFG;
|
||||
value |= fg;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Color::Color (color_id fg, color_id bg)
|
||||
: value (0)
|
||||
{
|
||||
if (bg != Color::nocolor)
|
||||
{
|
||||
value |= _COLOR_HASBG;
|
||||
value |= (bg << 8);
|
||||
}
|
||||
|
||||
if (fg != Color::nocolor)
|
||||
{
|
||||
value |= _COLOR_HASFG;
|
||||
value |= fg;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Color::Color (color_id fg, color_id bg, bool underline, bool bold, bool bright)
|
||||
: value (0)
|
||||
{
|
||||
value |= ((underline ? 1 : 0) << 18)
|
||||
| ((bold ? 1 : 0) << 17)
|
||||
| ((bright ? 1 : 0) << 16);
|
||||
|
||||
if (bg != Color::nocolor)
|
||||
{
|
||||
value |= _COLOR_HASBG;
|
||||
value |= (bg << 8);
|
||||
}
|
||||
|
||||
if (fg != Color::nocolor)
|
||||
{
|
||||
value |= _COLOR_HASFG;
|
||||
value |= fg;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Color::~Color ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Color& Color::operator= (const Color& other)
|
||||
{
|
||||
if (this != &other)
|
||||
value = other.value;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Color::operator std::string () const
|
||||
{
|
||||
std::string description;
|
||||
if (value & _COLOR_BOLD) description += "bold";
|
||||
|
||||
if (value & _COLOR_UNDERLINE)
|
||||
description += std::string (description.length () ? " " : "") + "underline";
|
||||
|
||||
if (value & _COLOR_HASFG)
|
||||
description += std::string (description.length () ? " " : "") + fg ();
|
||||
|
||||
if (value & _COLOR_HASBG)
|
||||
{
|
||||
description += std::string (description.length () ? " " : "") + "on";
|
||||
|
||||
if (value & _COLOR_BRIGHT)
|
||||
description += std::string (description.length () ? " " : "") + "bright";
|
||||
|
||||
description += " " + bg ();
|
||||
}
|
||||
|
||||
return description;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Color::operator int () const
|
||||
{
|
||||
return (int) value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// If 'other' has styles that are compatible, merge them into this. Colors in
|
||||
// other take precedence.
|
||||
void Color::blend (const Color& other)
|
||||
{
|
||||
Color c (other);
|
||||
value |= (c.value & _COLOR_UNDERLINE); // Always inherit underline.
|
||||
|
||||
// 16 <-- 16.
|
||||
if (!(value & _COLOR_256) &&
|
||||
!(c.value & _COLOR_256))
|
||||
{
|
||||
value |= (c.value & _COLOR_BOLD); // Inherit bold.
|
||||
value |= (c.value & _COLOR_BRIGHT); // Inherit bright.
|
||||
|
||||
if (c.value & _COLOR_HASFG)
|
||||
{
|
||||
value |= _COLOR_HASFG; // There is now a color.
|
||||
value &= ~_COLOR_FG; // Remove previous color.
|
||||
value |= (c.value & _COLOR_FG); // Apply other color.
|
||||
}
|
||||
|
||||
if (c.value & _COLOR_HASBG)
|
||||
{
|
||||
value |= _COLOR_HASBG; // There is now a color.
|
||||
value &= ~_COLOR_BG; // Remove previous color.
|
||||
value |= (c.value & _COLOR_BG); // Apply other color.
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Upgrade either color, if necessary.
|
||||
if (!(value & _COLOR_256)) upgrade ();
|
||||
if (!(c.value & _COLOR_256)) c.upgrade ();
|
||||
|
||||
// 256 <-- 256.
|
||||
if (c.value & _COLOR_HASFG)
|
||||
{
|
||||
value |= _COLOR_HASFG; // There is now a color.
|
||||
value &= ~_COLOR_FG; // Remove previous color.
|
||||
value |= (c.value & _COLOR_FG); // Apply other color.
|
||||
}
|
||||
|
||||
if (c.value & _COLOR_HASBG)
|
||||
{
|
||||
value |= _COLOR_HASBG; // There is now a color.
|
||||
value &= ~_COLOR_BG; // Remove previous color.
|
||||
value |= (c.value & _COLOR_BG); // Apply other color.
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Color::upgrade ()
|
||||
{
|
||||
if (!(value & _COLOR_256))
|
||||
{
|
||||
if (value & _COLOR_HASFG)
|
||||
{
|
||||
bool bold = value & _COLOR_BOLD;
|
||||
unsigned int fg = value & _COLOR_FG;
|
||||
value &= ~_COLOR_FG;
|
||||
value &= ~_COLOR_BOLD;
|
||||
value |= (bold ? fg + 7 : fg - 1);
|
||||
}
|
||||
|
||||
if (value & _COLOR_HASBG)
|
||||
{
|
||||
bool bright = value & _COLOR_BRIGHT;
|
||||
unsigned int bg = (value & _COLOR_BG) >> 8;
|
||||
value &= ~_COLOR_BG;
|
||||
value &= ~_COLOR_BRIGHT;
|
||||
value |= (bright ? bg + 7 : bg - 1) << 8;
|
||||
}
|
||||
|
||||
value |= _COLOR_256;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Sample color codes:
|
||||
// red \033[31m
|
||||
// bold red \033[91m
|
||||
// underline red \033[4;31m
|
||||
// bold underline red \033[1;4;31m
|
||||
//
|
||||
// on red \033[41m
|
||||
// on bright red \033[101m
|
||||
//
|
||||
// 256 fg \033[38;5;Nm
|
||||
// 256 bg \033[48;5;Nm
|
||||
std::string Color::colorize (const std::string& input)
|
||||
{
|
||||
if (value == 0)
|
||||
return input;
|
||||
|
||||
int count = 0;
|
||||
std::stringstream result;
|
||||
|
||||
// 256 color
|
||||
if (value & _COLOR_256)
|
||||
{
|
||||
bool needTerminator = false;
|
||||
|
||||
if (value & _COLOR_UNDERLINE)
|
||||
{
|
||||
result << "\033[4m";
|
||||
needTerminator = true;
|
||||
}
|
||||
|
||||
if (value & _COLOR_HASFG)
|
||||
{
|
||||
result << "\033[38;5;" << (value & _COLOR_FG) << "m";
|
||||
needTerminator = true;
|
||||
}
|
||||
|
||||
if (value & _COLOR_HASBG)
|
||||
{
|
||||
result << "\033[48;5;" << ((value & _COLOR_BG) >> 8) << "m";
|
||||
needTerminator = true;
|
||||
}
|
||||
|
||||
result << input;
|
||||
if (needTerminator)
|
||||
result << "\033[0m";
|
||||
|
||||
return result.str ();
|
||||
}
|
||||
|
||||
// 16 color
|
||||
if (value != 0)
|
||||
{
|
||||
result << "\033[";
|
||||
|
||||
if (value & _COLOR_BOLD)
|
||||
{
|
||||
if (count++) result << ";";
|
||||
result << "1";
|
||||
}
|
||||
|
||||
if (value & _COLOR_UNDERLINE)
|
||||
{
|
||||
if (count++) result << ";";
|
||||
result << "4";
|
||||
}
|
||||
|
||||
if (value & _COLOR_HASFG)
|
||||
{
|
||||
if (count++) result << ";";
|
||||
result << (29 + (value & _COLOR_FG));
|
||||
}
|
||||
|
||||
if (value & _COLOR_HASBG)
|
||||
{
|
||||
if (count++) result << ";";
|
||||
result << ((value & _COLOR_BRIGHT ? 99 : 39) + ((value & _COLOR_BG) >> 8));
|
||||
}
|
||||
|
||||
result << "m" << input << "\033[0m";
|
||||
return result.str ();
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Color::colorize (const std::string& input, const std::string& spec)
|
||||
{
|
||||
Color c (spec);
|
||||
return c.colorize (input);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Color::nontrivial ()
|
||||
{
|
||||
return value != 0 ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Color::find (const std::string& input)
|
||||
{
|
||||
for (unsigned int i = 0; i < NUM_COLORS; ++i)
|
||||
if (allColors[i].english_name == input)
|
||||
return (int) i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Color::fg () const
|
||||
{
|
||||
int index = value & _COLOR_FG;
|
||||
|
||||
if (value & _COLOR_256)
|
||||
{
|
||||
if (value & _COLOR_HASFG)
|
||||
{
|
||||
std::stringstream s;
|
||||
s << "color" << (value & _COLOR_FG);
|
||||
return s.str ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i = 0; i < NUM_COLORS; ++i)
|
||||
if (allColors[i].index == index)
|
||||
return allColors[i].english_name;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Color::bg () const
|
||||
{
|
||||
int index = (value & _COLOR_BG) >> 8;
|
||||
|
||||
if (value & _COLOR_256)
|
||||
{
|
||||
if (value & _COLOR_HASBG)
|
||||
{
|
||||
std::stringstream s;
|
||||
s << "color" << ((value & _COLOR_BG) >> 8);
|
||||
return s.str ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i = 0; i < NUM_COLORS; ++i)
|
||||
if (allColors[i].index == index)
|
||||
return allColors[i].english_name;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
78
src/Color.h
78
src/Color.h
@@ -1,78 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef INCLUDED_COLOR
|
||||
#define INCLUDED_COLOR
|
||||
|
||||
#include <string>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#define _COLOR_256 0x00200000 // 256-color mode.
|
||||
#define _COLOR_HASBG 0x00100000 // Has background color (all values taken).
|
||||
#define _COLOR_HASFG 0x00080000 // Has foreground color (all values taken).
|
||||
#define _COLOR_UNDERLINE 0x00040000 // General underline attribute.
|
||||
#define _COLOR_BOLD 0x00020000 // 16-color bold attribute.
|
||||
#define _COLOR_BRIGHT 0x00010000 // 16-color bright background attribute.
|
||||
#define _COLOR_BG 0x0000FF00 // 8-bit background color index.
|
||||
#define _COLOR_FG 0x000000FF // 8-bit foreground color index.
|
||||
|
||||
class Color
|
||||
{
|
||||
public:
|
||||
enum color_id {nocolor = 0, black, red, green, yellow, blue, magenta, cyan, white};
|
||||
|
||||
Color ();
|
||||
Color (const Color&);
|
||||
Color (unsigned int); // 256 | UNDERLINE | BOLD | BRIGHT | (BG << 8) | FG
|
||||
Color (const std::string&); // "red on bright black"
|
||||
Color (color_id); // fg.
|
||||
Color (color_id, color_id); // fg, bg.
|
||||
Color (color_id, color_id, bool, bool, bool); // fg, bg, underline, bold, bright
|
||||
~Color ();
|
||||
Color& operator= (const Color&);
|
||||
operator std::string () const;
|
||||
operator int () const;
|
||||
|
||||
void upgrade ();
|
||||
void blend (const Color&);
|
||||
|
||||
std::string colorize (const std::string&);
|
||||
static std::string colorize (const std::string&, const std::string&);
|
||||
|
||||
bool nontrivial ();
|
||||
|
||||
private:
|
||||
int find (const std::string&);
|
||||
std::string fg () const;
|
||||
std::string bg () const;
|
||||
|
||||
private:
|
||||
unsigned int value;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
755
src/Config.cpp
755
src/Config.cpp
@@ -1,7 +1,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -27,347 +27,30 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#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:
|
||||
// 1) It is used to create a new .taskrc file, by copying it directly to disk.
|
||||
// 2) It is parsed and used as default values for all Config.get calls.
|
||||
std::string Config::defaults =
|
||||
"# Task program configuration file.\n"
|
||||
"# For more documentation, see http://taskwarrior.org or try 'man task', 'man task-faq',\n"
|
||||
"# 'man task-tutorial', 'man task-color' or 'man taskrc'\n"
|
||||
"\n"
|
||||
"# Here is an example of entries that use the default, override and blank values\n"
|
||||
"# variable=foo -- By specifying a value, this overrides the default\n"
|
||||
"# variable= -- By specifying no value, this means no default\n"
|
||||
"# #variable=foo -- By commenting out the line, this uses the default\n"
|
||||
"\n"
|
||||
"# Files\n"
|
||||
"data.location=~/.task\n"
|
||||
"locking=on # Use file-level locking\n"
|
||||
"\n"
|
||||
"# Terminal\n"
|
||||
"curses=on # Use ncurses library to determine terminal width\n"
|
||||
"defaultwidth=80 # Without ncurses, assumed width\n"
|
||||
"#editor=vi # Preferred text editor\n"
|
||||
"\n"
|
||||
"# Miscellaneous\n"
|
||||
"confirmation=yes # Confirmation on delete, big changes\n"
|
||||
"echo.command=yes # Details on command just run\n"
|
||||
"annotations=full # Level of verbosity for annotations: full, sparse or none\n"
|
||||
"next=2 # How many tasks per project in next report\n"
|
||||
"bulk=2 # > 2 tasks considered 'a lot', for confirmation\n"
|
||||
"nag=You have higher priority tasks. # Nag message to keep you honest\n" // TODO
|
||||
"search.case.sensitive=yes # Setting to no allows case insensitive searches\n"
|
||||
"active.indicator=* # What to show as an active task indicator\n"
|
||||
"tag.indicator=+ # What to show as a tag indicator\n"
|
||||
"recurrence.indicator=R # What to show as a task recurrence indicator\n"
|
||||
"recurrence.limit=1 # Number of future recurring pending tasks\n"
|
||||
"undo.style=side # Undo style - can be 'side', or 'diff'\n"
|
||||
"\n"
|
||||
"# Dates\n"
|
||||
"dateformat=m/d/Y # Preferred input and display date format\n"
|
||||
"dateformat.holiday=YMD # Preferred input date format for holidays\n"
|
||||
"dateformat.report=m/d/Y # Preferred display date format for reports\n"
|
||||
"dateformat.annotation=m/d/Y # Preferred display date format for reports\n"
|
||||
"weekstart=Sunday # Sunday or Monday only\n"
|
||||
"displayweeknumber=yes # Show week numbers on calendar\n"
|
||||
"due=7 # Task is considered due in 7 days\n"
|
||||
"\n"
|
||||
"# Calendar controls\n"
|
||||
"calendar.legend=yes # Display the legend on calendar\n"
|
||||
"calendar.details=sparse # Calendar shows information for tasks w/due dates: full, sparse or none\n"
|
||||
"calendar.details.report=list # Report to use when showing task information in cal\n"
|
||||
"calendar.holidays=none # Show public holidays on calendar:full, sparse or none\n"
|
||||
"#monthsperline=3 # Number of calendar months on a line\n"
|
||||
"\n"
|
||||
"# Color controls.\n"
|
||||
"color=on # Enable color\n"
|
||||
#ifdef LINUX
|
||||
"color.header=color3 # Color of header messages\n"
|
||||
"color.footnote=color3 # Color of footnote messages\n"
|
||||
"color.debug=color3 # Color of diagnostic output\n"
|
||||
"\n"
|
||||
"color.summary.bar=on rgb141 # Color of summary report progress bar\n"
|
||||
"color.summary.background=on color0 # Color of summary report background\n"
|
||||
"\n"
|
||||
"color.history.add=color0 on rgb500 # Color of added tasks in ghistory report\n"
|
||||
"color.history.done=color0 on rgb050 # Color of completed tasks in ghistory report\n"
|
||||
"color.history.delete=color0 on rgb550 # Color of deleted tasks in ghistory report\n"
|
||||
"\n"
|
||||
"color.undo.before=color1 # Color of values before a change\n"
|
||||
"color.undo.after=color2 # Color of values after a change\n"
|
||||
"\n"
|
||||
"color.calendar.today=color15 on rgb013 # Color of today in calendar\n"
|
||||
"color.calendar.due=color0 on color1 # Color of days with due tasks in calendar\n"
|
||||
"color.calendar.due.today=color15 on color1 # Color of today with due tasks in calendar\n"
|
||||
"color.calendar.overdue=color0 on color9 # Color of days with overdue tasks in calendar\n"
|
||||
"color.calendar.weekend=color235 # Color of weekend days in calendar\n"
|
||||
"color.calendar.holiday=color0 on color11 # Color of public holidays in calendar\n"
|
||||
"color.calendar.weeknumber=rgb013 # Color of the weeknumbers in calendar\n"
|
||||
"\n"
|
||||
"# The following rules are presented in their order of precedence.\n"
|
||||
"# The higher the color rule is up this list, the higher precedence\n"
|
||||
"# it has in determining the color for the task. Precedence is shown\n"
|
||||
"# in brackets [1]\n"
|
||||
"color.recurring=rgb013 # [1] Color of recur.any: tasks\n"
|
||||
"color.overdue=color9 # [2] Color of overdue tasks\n"
|
||||
"color.due.today=rgb400 # [3] Color of tasks due today\n"
|
||||
"color.due=color1 # [4] Color of due tasks\n"
|
||||
"#color.keyword.car=on blue # [5] Color of description.contains:car tasks\n"
|
||||
"#color.project.garden=on green # [6] Color of project:garden tasks\n"
|
||||
"#color.tag.bug=yellow # [7] Color of +bug tasks\n"
|
||||
"color.active=rgb555 on rgb410 # [8] Color of active tasks\n"
|
||||
"color.pri.none= # [9] Color of priority: tasks\n"
|
||||
"color.pri.H=rgb255 # [9] Color of priority:H tasks\n"
|
||||
"color.pri.M=rgb250 # [9] Color of priority:M tasks\n"
|
||||
"color.pri.L=rgb245 # [9] Color of priority:L tasks\n"
|
||||
"color.tagged=rgb031 # [10] Color of tagged tasks\n"
|
||||
"color.alternate=on color233 # [11] Alternate color for line coloring\n"
|
||||
#else
|
||||
"color.header=yellow # Color of header messages\n"
|
||||
"color.footnote=yellow # Color of footnote messages\n"
|
||||
"color.debug=yellow # Color of diagnostic output\n"
|
||||
"\n"
|
||||
"color.summary.bar=on green # Color of summary report progress bar\n"
|
||||
"color.summary.background=on black # Color of summary report background\n"
|
||||
"\n"
|
||||
"color.history.add=black on red # Color of added tasks in ghistory report\n"
|
||||
"color.history.done=black on green # Color of completed tasks in ghistory report\n"
|
||||
"color.history.delete=black on yellow # Color of deleted tasks in ghistory report\n"
|
||||
"\n"
|
||||
"color.undo.before=red # Color of values before a change\n"
|
||||
"color.undo.after=green # Color of values after a change\n"
|
||||
"\n"
|
||||
"color.calendar.today=bold white on bright blue # Color of today in calendar\n"
|
||||
"color.calendar.due=white on red # Color of days with due tasks in calendar\n"
|
||||
"color.calendar.due.today=bold white on red # Color of today with due tasks in calendar\n"
|
||||
"color.calendar.overdue=black on bright red # Color of days with overdue tasks in calendar\n"
|
||||
"color.calendar.weekend=white on bright black # Color of weekend days in calendar\n"
|
||||
"color.calendar.holiday=black on bright yellow # Color of public holidays in calendar\n"
|
||||
"color.calendar.weeknumber=bold blue # Color of the weeknumbers in calendar\n"
|
||||
"\n"
|
||||
"# The following rules are presented in their order of precedence.\n"
|
||||
"# The higher the color rule is up this list, the higher precedence\n"
|
||||
"# it has in determining the color for the task. Precedence is shown\n"
|
||||
"# in brackets [1]\n"
|
||||
"color.recurring=magenta # [1] Color of recur.any: tasks\n"
|
||||
"color.overdue=bold red # [2] Color of overdue tasks\n"
|
||||
"color.due.today=red # [3] Color of tasks due today\n"
|
||||
"color.due=red # [4] Color of due tasks\n"
|
||||
"#color.keyword.car=on blue # [5] Color of description.contains:car tasks\n"
|
||||
"#color.project.garden=on green # [6] Color of project:garden tasks\n"
|
||||
"#color.tag.bug=yellow # [7] Color of +bug tasks\n"
|
||||
"color.active=black on bright green # [8] Color of active tasks\n"
|
||||
"color.pri.none= # [9] Color of priority: tasks\n"
|
||||
"color.pri.H=bold white # [9] Color of priority:H tasks\n"
|
||||
"color.pri.M=white # [9] Color of priority:M tasks\n"
|
||||
"color.pri.L= # [9] Color of priority:L tasks\n"
|
||||
"color.tagged=green # [10] Color of tagged tasks\n"
|
||||
"color.alternate= # [11] Alternate color for line coloring\n"
|
||||
#endif
|
||||
"\n"
|
||||
"# Shadow file support\n"
|
||||
"#shadow.file=/tmp/shadow.txt # Location of shadow file\n"
|
||||
"#shadow.command=list # Task command for shadow file\n"
|
||||
"#shadow.notify=on # Footnote when updated\n"
|
||||
"\n"
|
||||
"#default.project=foo # Default project for 'add' command\n"
|
||||
"#default.priority=M # Default priority for 'add' command\n"
|
||||
"default.command=list # When no arguments are specified\n"
|
||||
"\n"
|
||||
"_forcecolor=no # Forces color to be on, even for non TTY output\n"
|
||||
"blanklines=true # Use more whitespace in output\n"
|
||||
"complete.all.projects=no # Include old project names in '_projects' command\n"
|
||||
"complete.all.tags=no # Include old tag names in '_ags' command\n"
|
||||
"list.all.projects=no # Include old project names in 'projects' command\n"
|
||||
"list.all.tags=no # Include old tag names in 'tags' command\n"
|
||||
"debug=no # Display diagnostics\n"
|
||||
"hooks=off # Hook system master switch\n"
|
||||
"fontunderline=yes # Uses underlines rather than -------\n"
|
||||
"shell.prompt=task> # Prompt used by the shell command\n"
|
||||
"\n"
|
||||
"# Import heuristics - alternate names for fields (comma-separated list of names)\n"
|
||||
"#import.synonym.bg=?\n"
|
||||
"#import.synonym.description=?\n"
|
||||
"#import.synonym.due=?\n"
|
||||
"#import.synonym.end=?\n"
|
||||
"#import.synonym.entry=?\n"
|
||||
"#import.synonym.fg=?\n"
|
||||
"#import.synonym.id=?\n"
|
||||
"#import.synonym.priority=?\n"
|
||||
"#import.synonym.project=?\n"
|
||||
"#import.synonym.recur=?\n"
|
||||
"#import.synonym.start=?\n"
|
||||
"#import.synonym.status=?\n"
|
||||
"#import.synonym.tags=?\n"
|
||||
"#import.synonym.uuid=?\n"
|
||||
"\n"
|
||||
"# Export Controls\n"
|
||||
"export.ical.class=PRIVATE # Could be PUBLIC, PRIVATE or CONFIDENTIAL\n"
|
||||
"\n"
|
||||
"# Aliases - alternate names for commands\n"
|
||||
"alias.rm=delete # Alias for the delete command\n"
|
||||
"alias.history=history.monthly # Prefer monthly over annual history reports\n"
|
||||
"alias.ghistory=ghistory.monthly # Prefer monthly graphical over annual history reports\n"
|
||||
"alias.export=export.csv # Prefer CSV over iCal export\n"
|
||||
"alias.export.vcalendar=export.ical # They are the same\n"
|
||||
"\n"
|
||||
"# Fields: id,uuid,project,priority,priority_long,entry,entry_time,\n" // TODO
|
||||
"# start,entry_time,due,recur,recurrence_indicator,age,\n" // TODO
|
||||
"# age_compact,active,tags,tag_indicator,description,\n" // TODO
|
||||
"# description_only,end,end_time,countdown,countdown_compact\n" // TODO
|
||||
"# Description: This report is ...\n"
|
||||
"# Sort: due+,priority-,project+\n"
|
||||
"# Filter: pro:x pri:H +bug limit:10\n"
|
||||
"# Dateformat: due date format in reports\n"
|
||||
"\n"
|
||||
"# task long\n"
|
||||
"report.long.description=Lists all task, all data, matching the specified criteria\n"
|
||||
"report.long.columns=id,project,priority,entry,start,due,recur,countdown,age,tags,description\n"
|
||||
"report.long.labels=ID,Project,Pri,Added,Started,Due,Recur,Countdown,Age,Tags,Description\n"
|
||||
"report.long.sort=due+,priority-,project+\n"
|
||||
"report.long.filter=status:pending\n"
|
||||
"#report.long.dateformat=m/d/Y\n"
|
||||
"#report.long.annotations=full\n"
|
||||
"\n"
|
||||
"# task list\n"
|
||||
"report.list.description=Lists all tasks matching the specified criteria\n"
|
||||
"report.list.columns=id,project,priority,due,active,age,description\n"
|
||||
"report.list.labels=ID,Project,Pri,Due,Active,Age,Description\n"
|
||||
"report.list.sort=due+,priority-,active-,project+\n"
|
||||
"report.list.filter=status:pending\n"
|
||||
"#report.list.dateformat=m/d/Y\n"
|
||||
"#report.list.annotations=full\n"
|
||||
"\n"
|
||||
"# task ls\n"
|
||||
"report.ls.description=Minimal listing of all tasks matching the specified criteria\n"
|
||||
"report.ls.columns=id,project,priority,description\n"
|
||||
"report.ls.labels=ID,Project,Pri,Description\n"
|
||||
"report.ls.sort=priority-,project+\n"
|
||||
"report.ls.filter=status:pending\n"
|
||||
"#report.ls.dateformat=m/d/Y\n"
|
||||
"#report.ls.annotations=full\n"
|
||||
"\n"
|
||||
"# task minimal\n"
|
||||
"report.minimal.description=A really minimal listing\n"
|
||||
"report.minimal.columns=id,project,description\n"
|
||||
"report.minimal.labels=ID,Project,Description\n"
|
||||
"report.minimal.sort=project+,description+\n"
|
||||
"report.minimal.filter=status:pending\n"
|
||||
"#report.minimal.dateformat=m/d/Y\n"
|
||||
"#report.minimal.annotations=full\n"
|
||||
"\n"
|
||||
"# task newest\n"
|
||||
"report.newest.description=Shows the newest tasks\n"
|
||||
"report.newest.columns=id,project,priority,due,active,age,description\n"
|
||||
"report.newest.labels=ID,Project,Pri,Due,Active,Age,Description\n"
|
||||
"report.newest.sort=id-\n"
|
||||
"report.newest.filter=status:pending limit:10\n"
|
||||
"#report.newest.dateformat=m/d/Y\n"
|
||||
"#report.newest.annotations=full\n"
|
||||
"\n"
|
||||
"# task oldest\n"
|
||||
"report.oldest.description=Shows the oldest tasks\n"
|
||||
"report.oldest.columns=id,project,priority,due,active,age,description\n"
|
||||
"report.oldest.labels=ID,Project,Pri,Due,Active,Age,Description\n"
|
||||
"report.oldest.sort=id+\n"
|
||||
"report.oldest.filter=status:pending limit:10\n"
|
||||
"#report.oldest.dateformat=m/d/Y\n"
|
||||
"#report.oldest.annotations=full\n"
|
||||
"\n"
|
||||
"# task overdue\n"
|
||||
"report.overdue.description=Lists overdue tasks matching the specified criteria\n"
|
||||
"report.overdue.columns=id,project,priority,due,active,age,description\n"
|
||||
"report.overdue.labels=ID,Project,Pri,Due,Active,Age,Description\n"
|
||||
"report.overdue.sort=due+,priority-,active-,project+\n"
|
||||
"report.overdue.filter=status:pending due.before:today\n"
|
||||
"#report.overdue.dateformat=m/d/Y\n"
|
||||
"#report.overdue.annotations=full\n"
|
||||
"\n"
|
||||
"# task active\n"
|
||||
"report.active.description=Lists active tasks matching the specified criteria\n"
|
||||
"report.active.columns=id,project,priority,due,active,age,description\n"
|
||||
"report.active.labels=ID,Project,Pri,Due,Active,Age,Description\n"
|
||||
"report.active.sort=due+,priority-,project+\n"
|
||||
"report.active.filter=status:pending start.any:\n"
|
||||
"#report.active.dateformat=m/d/Y\n"
|
||||
"#report.active.annotations=full\n"
|
||||
"\n"
|
||||
"# task completed\n"
|
||||
"report.completed.description=Lists completed tasks matching the specified criteria\n"
|
||||
"report.completed.columns=end,project,priority,age,description\n"
|
||||
"report.completed.labels=Complete,Project,Pri,Age,Description\n"
|
||||
"report.completed.sort=end+,priority-,project+\n"
|
||||
"report.completed.filter=status:completed\n"
|
||||
"#report.completed.dateformat=m/d/Y\n"
|
||||
"#report.completed.annotations=full\n"
|
||||
"\n"
|
||||
"# task recurring\n"
|
||||
"report.recurring.description=Lists recurring tasks matching the specified criteria\n"
|
||||
"report.recurring.columns=id,project,priority,due,recur,active,age,description\n"
|
||||
"report.recurring.labels=ID,Project,Pri,Due,Recur,Active,Age,Description\n"
|
||||
"report.recurring.sort=due+,priority-,active-,project+\n"
|
||||
"report.recurring.filter=status:pending parent.any:\n"
|
||||
"#report.recurring.dateformat=m/d/Y\n"
|
||||
"#report.recurring.annotations=full\n"
|
||||
"\n"
|
||||
"# task waiting\n"
|
||||
"report.waiting.description=Lists all waiting tasks matching the specified criteria\n"
|
||||
"report.waiting.columns=id,project,priority,wait,age,description\n"
|
||||
"report.waiting.labels=ID,Project,Pri,Wait,Age,Description\n"
|
||||
"report.waiting.sort=wait+,priority-,project+\n"
|
||||
"report.waiting.filter=status:waiting\n"
|
||||
"#report.waiting.dateformat=m/d/Y\n"
|
||||
"#report.waiting.annotations=full\n"
|
||||
"\n"
|
||||
"# task all\n"
|
||||
"report.all.description=Lists all tasks matching the specified criteria\n"
|
||||
"report.all.columns=id,project,priority,due,active,age,description\n"
|
||||
"report.all.labels=ID,Project,Pri,Due,Active,Age,Description\n"
|
||||
"report.all.sort=due+,priority-,active-,project+\n"
|
||||
"#report.all.dateformat=m/d/Y\n"
|
||||
"#report.all.annotations=full\n"
|
||||
"\n"
|
||||
"# task next\n"
|
||||
"report.next.description=Lists the most urgent tasks\n"
|
||||
"report.next.columns=id,project,priority,due,active,age,description\n"
|
||||
"report.next.labels=ID,Project,Pri,Due,Active,Age,Description\n"
|
||||
"report.next.sort=due+,priority-,active-,project+\n"
|
||||
"report.next.filter=status:pending limit:page\n"
|
||||
"#report.next.dateformat=m/d/Y\n"
|
||||
"#report.next.annotations=full\n"
|
||||
"\n";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// DO NOT CALL Config::setDefaults.
|
||||
//
|
||||
// This is a default constructor, and as such is only used to:
|
||||
// a) initialize a default Context constructor
|
||||
// b) run unit tests
|
||||
//
|
||||
// In all real use cases, Config::load is called.
|
||||
// These are default (but overridable) reports. These entries are necessary
|
||||
// because these three reports were converted from hard-coded reports to custom
|
||||
// reports, and therefore need these config file entries. However, users are
|
||||
// already used to seeing these five reports, but do not have these entries.
|
||||
// The choice was a) make users edit their .taskrc files, b) write a .taskrc
|
||||
// upgrade program to make the change, or c) this.
|
||||
Config::Config ()
|
||||
{
|
||||
setDefaults ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Config::Config (const std::string& file)
|
||||
{
|
||||
setDefaults ();
|
||||
load (file);
|
||||
}
|
||||
|
||||
@@ -375,128 +58,288 @@ Config::Config (const std::string& file)
|
||||
// Read the Configuration file and populate the *this map. The file format is
|
||||
// simply lines with name=value pairs. Whitespace between name, = and value is
|
||||
// not tolerated, but blank lines and comments starting with # are allowed.
|
||||
//
|
||||
// Nested files are now supported, with the following construct:
|
||||
// include /absolute/path/to/file
|
||||
//
|
||||
void Config::load (const std::string& file, int nest /* = 1 */)
|
||||
bool Config::load (const std::string& file)
|
||||
{
|
||||
if (nest > 10)
|
||||
throw std::string ("Configuration file nested to more than 10 levels deep"
|
||||
" - this has to be a mistake.");
|
||||
|
||||
// First time in, load the default values.
|
||||
if (nest == 1)
|
||||
std::ifstream in;
|
||||
in.open (file.c_str (), std::ifstream::in);
|
||||
if (in.good ())
|
||||
{
|
||||
setDefaults ();
|
||||
original_file = File (file);
|
||||
}
|
||||
|
||||
// Read the file, then parse the contents.
|
||||
std::string contents;
|
||||
if (File::read (file, contents) && contents.length ())
|
||||
parse (contents, nest);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Config::parse (const std::string& input, int nest /* = 1 */)
|
||||
{
|
||||
// Shortcut case for default constructor.
|
||||
if (input.length () == 0)
|
||||
return;
|
||||
|
||||
// Split the input into lines.
|
||||
std::vector <std::string> lines;
|
||||
split (lines, input, "\n");
|
||||
|
||||
// Parse each line.
|
||||
std::vector <std::string>::iterator it;
|
||||
for (it = lines.begin (); it != lines.end (); ++it)
|
||||
{
|
||||
std::string line = *it;
|
||||
|
||||
// Remove comments.
|
||||
std::string::size_type pound = line.find ("#"); // no i18n
|
||||
if (pound != std::string::npos)
|
||||
line = line.substr (0, pound);
|
||||
|
||||
line = trim (line, " \t"); // no i18n
|
||||
|
||||
// Skip empty lines.
|
||||
if (line.length () > 0)
|
||||
std::string line;
|
||||
while (getline (in, line))
|
||||
{
|
||||
std::string::size_type equal = line.find ("="); // no i18n
|
||||
if (equal != std::string::npos)
|
||||
{
|
||||
std::string key = trim (line.substr (0, equal), " \t"); // no i18n
|
||||
std::string value = trim (line.substr (equal+1, line.length () - equal), " \t"); // no i18n
|
||||
// Remove comments.
|
||||
std::string::size_type pound = line.find ("#"); // no i18n
|
||||
if (pound != std::string::npos)
|
||||
line = line.substr (0, pound);
|
||||
|
||||
(*this)[key] = value;
|
||||
}
|
||||
else
|
||||
line = trim (line, " \t"); // no i18n
|
||||
|
||||
// Skip empty lines.
|
||||
if (line.length () > 0)
|
||||
{
|
||||
std::string::size_type include = line.find ("include"); // no i18n.
|
||||
if (include != std::string::npos)
|
||||
std::string::size_type equal = line.find ("="); // no i18n
|
||||
if (equal != std::string::npos)
|
||||
{
|
||||
Path included (trim (line.substr (include + 7), " \t"));
|
||||
if (included.is_absolute ())
|
||||
{
|
||||
if (included.readable ())
|
||||
this->load (included, nest + 1);
|
||||
else
|
||||
throw std::string ("Could not read include file '") + included.data + "'";
|
||||
}
|
||||
else
|
||||
throw std::string ("Can only include files with absolute paths, not '") + included.data + "'";
|
||||
std::string key = trim (line.substr (0, equal), " \t"); // no i18n
|
||||
std::string value = trim (line.substr (equal+1, line.length () - equal), " \t"); // no i18n
|
||||
(*this)[key] = value;
|
||||
}
|
||||
else
|
||||
throw std::string ("Malformed entry '") + line + "'";
|
||||
}
|
||||
}
|
||||
|
||||
in.close ();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Config::createDefaultRC (const std::string& rc, const std::string& data)
|
||||
{
|
||||
// Override data.location in the defaults.
|
||||
std::string::size_type loc = defaults.find ("data.location=~/.task");
|
||||
// loc+0^ +14^ +21^
|
||||
|
||||
Date now;
|
||||
// Create a sample .taskrc file.
|
||||
std::stringstream contents;
|
||||
contents << "# [Created by "
|
||||
<< PACKAGE_STRING
|
||||
<< " "
|
||||
<< now.toStringWithTime ()
|
||||
<< "]\n"
|
||||
<< defaults.substr (0, loc + 14)
|
||||
<< data
|
||||
<< defaults.substr (loc + 21);
|
||||
contents << "# Task program configuration file.\n"
|
||||
<< "# For more documentation, see http://taskwarrior.org\n"
|
||||
<< "\n"
|
||||
<< "# Files\n"
|
||||
<< "data.location=" << data << "\n"
|
||||
<< "locking=on # Use file-level locking\n"
|
||||
<< "\n"
|
||||
<< "# Terminal\n"
|
||||
<< "curses=on # Use ncurses library to determine terminal width\n"
|
||||
<< "#defaultwidth=80 # Without ncurses, assumed width\n"
|
||||
<< "#editor=vi # Preferred text editor\n"
|
||||
<< "\n"
|
||||
<< "# Miscellaneous\n"
|
||||
<< "confirmation=yes # Confirmation on delete, big changes\n"
|
||||
<< "echo.command=yes # Details on command just run\n"
|
||||
<< "next=2 # How many tasks per project in next report\n"
|
||||
<< "bulk=2 # > 2 tasks considered 'a lot', for confirmation\n"
|
||||
<< "nag=You have higher priority tasks. # Nag message to keep you honest\n"
|
||||
<< "\n"
|
||||
<< "# Dates\n"
|
||||
<< "dateformat=m/d/Y # Preferred input and display date format\n"
|
||||
<< "weekstart=Sunday # Sunday or Monday only\n"
|
||||
<< "displayweeknumber=yes # Show week numbers on calendar\n"
|
||||
<< "due=7 # Task is considered due in 7 days\n"
|
||||
<< "#monthsperline=2 # Number of calendar months on a line\n"
|
||||
<< "\n"
|
||||
<< "# Color controls.\n"
|
||||
<< "color=on # Use color\n"
|
||||
<< "color.overdue=bold_red # Color of overdue tasks\n"
|
||||
<< "color.due=bold_yellow # Color of due tasks\n"
|
||||
<< "color.pri.H=bold # Color of priority:H tasks\n"
|
||||
<< "#color.pri.M=on_yellow # Color of priority:M tasks\n"
|
||||
<< "#color.pri.L=on_green # Color of priority:L tasks\n"
|
||||
<< "#color.pri.none=white on_blue # Color of priority: tasks\n"
|
||||
<< "color.active=bold_cyan # Color of active tasks\n"
|
||||
<< "color.tagged=yellow # Color of tagged tasks\n"
|
||||
<< "#color.tag.bug=yellow # Color of +bug tasks\n"
|
||||
<< "#color.project.garden=on_green # Color of project:garden tasks\n"
|
||||
<< "#color.keyword.car=on_blue # Color of description.contains:car tasks\n"
|
||||
<< "#color.recurring=on_red # Color of recur.any: tasks\n"
|
||||
<< "#color.header=bold_green # Color of header messages\n"
|
||||
<< "#color.footnote=bold_green # Color of footnote messages\n"
|
||||
<< "\n"
|
||||
<< "#shadow.file=/tmp/shadow.txt # Location of shadow file\n"
|
||||
<< "#shadow.command=list # Task command for shadow file\n"
|
||||
<< "#shadow.notify=on # Footnote when updated\n"
|
||||
<< "\n"
|
||||
<< "#default.project=foo # Unless otherwise specified\n"
|
||||
<< "#default.priority=M # Unless otherwise specified\n"
|
||||
<< "default.command=list # Unless otherwise specified\n"
|
||||
<< "\n"
|
||||
<< "# Fields: id,uuid,project,priority,entry,start,due,recur,recur_ind,age,\n"
|
||||
<< "# age_compact,active,tags,description,description_only\n"
|
||||
<< "# Description: This report is ...\n"
|
||||
<< "# Sort: due+,priority-,project+\n"
|
||||
<< "# Filter: pro:x pri:H +bug limit:10\n"
|
||||
<< "\n"
|
||||
<< "# task long\n"
|
||||
<< "report.long.description=Lists all task, all data, matching the specified criteria\n"
|
||||
<< "report.long.columns=id,project,priority,entry,start,due,recur,age,tags,description\n"
|
||||
<< "report.long.labels=ID,Project,Pri,Added,Started,Due,Recur,Age,Tags,Description\n"
|
||||
<< "report.long.sort=due+,priority-,project+\n"
|
||||
<< "report.long.filter=status:pending\n"
|
||||
<< "\n"
|
||||
<< "# task list\n"
|
||||
<< "report.list.description=Lists all tasks matching the specified criteria\n"
|
||||
<< "report.list.columns=id,project,priority,due,active,age,description\n"
|
||||
<< "report.list.labels=ID,Project,Pri,Due,Active,Age,Description\n"
|
||||
<< "report.list.sort=due+,priority-,project+\n"
|
||||
<< "report.list.filter=status:pending\n"
|
||||
<< "\n"
|
||||
<< "# task ls\n"
|
||||
<< "report.ls.description=Minimal listing of all tasks matching the specified criteria\n"
|
||||
<< "report.ls.columns=id,project,priority,description\n"
|
||||
<< "report.ls.labels=ID,Project,Pri,Description\n"
|
||||
<< "report.ls.sort=priority-,project+\n"
|
||||
<< "report.ls.filter=status:pending\n"
|
||||
<< "\n"
|
||||
<< "# task newest\n"
|
||||
<< "report.newest.description=Shows the newest tasks\n"
|
||||
<< "report.newest.columns=id,project,priority,due,active,age,description\n"
|
||||
<< "report.newest.labels=ID,Project,Pri,Due,Active,Age,Description\n"
|
||||
<< "report.newest.sort=id-\n"
|
||||
<< "report.newest.filter=status:pending limit:10\n"
|
||||
<< "\n"
|
||||
<< "# task oldest\n"
|
||||
<< "report.oldest.description=Shows the oldest tasks\n"
|
||||
<< "report.oldest.columns=id,project,priority,due,active,age,description\n"
|
||||
<< "report.oldest.labels=ID,Project,Pri,Due,Active,Age,Description\n"
|
||||
<< "report.oldest.sort=id+\n"
|
||||
<< "report.oldest.filter=status:pending limit:10\n"
|
||||
<< "\n"
|
||||
<< "# task overdue\n"
|
||||
<< "report.overdue.description=Lists overdue tasks matching the specified criteria\n"
|
||||
<< "report.overdue.columns=id,project,priority,due,active,age,description\n"
|
||||
<< "report.overdue.labels=ID,Project,Pri,Due,Active,Age,Description\n"
|
||||
<< "report.overdue.sort=due+,priority-,project+\n"
|
||||
<< "report.overdue.filter=status:pending due.before:today\n"
|
||||
<< "\n"
|
||||
<< "# task active\n"
|
||||
<< "report.active.description=Lists active tasks matching the specified criteria\n"
|
||||
<< "report.active.columns=id,project,priority,due,active,age,description\n"
|
||||
<< "report.active.labels=ID,Project,Pri,Due,Active,Age,Description\n"
|
||||
<< "report.active.sort=due+,priority-,project+\n"
|
||||
<< "report.active.filter=status:pending start.any:\n"
|
||||
<< "\n"
|
||||
<< "# task completed\n"
|
||||
<< "report.completed.description=Lists completed tasks matching the specified criteria\n"
|
||||
<< "report.completed.columns=end,project,priority,age,description\n"
|
||||
<< "report.completed.labels=Complete,Project,Pri,Age,Description\n"
|
||||
<< "report.completed.sort=end+,priority-,project+\n"
|
||||
<< "report.completed.filter=status:completed\n"
|
||||
<< "\n"
|
||||
<< "# task recurring\n"
|
||||
<< "report.recurring.description=Lists recurring tasks matching the specified criteria\n"
|
||||
<< "report.recurring.columns=id,project,priority,due,recur,active,age,description\n"
|
||||
<< "report.recurring.labels=ID,Project,Pri,Due,Recur,Active,Age,Description\n"
|
||||
<< "report.recurring.sort=due+,priority-,project+\n"
|
||||
<< "report.recurring.filter=status:pending parent.any:\n"
|
||||
<< "\n"
|
||||
<< "# task waiting\n"
|
||||
<< "report.waiting.description=Lists all waiting tasks matching the specified criteria\n"
|
||||
<< "report.waiting.columns=id,project,priority,wait,age,description\n"
|
||||
<< "report.waiting.labels=ID,Project,Pri,Wait,Age,Description\n"
|
||||
<< "report.waiting.sort=wait+,priority-,project+\n"
|
||||
<< "report.waiting.filter=status:waiting\n"
|
||||
<< "\n"
|
||||
<< "# task all\n"
|
||||
<< "report.all.description=Lists all tasks matching the specified criteria\n"
|
||||
<< "report.all.columns=id,project,priority,due,active,age,description\n"
|
||||
<< "report.all.labels=ID,Project,Pri,Due,Active,Age,Description\n"
|
||||
<< "report.all.sort=due+,priority-,project+\n"
|
||||
<< "\n"
|
||||
<< "# task next\n"
|
||||
<< "report.next.description=Lists the most urgent tasks\n"
|
||||
<< "report.next.columns=id,project,priority,due,active,age,description\n"
|
||||
<< "report.next.labels=ID,Project,Pri,Due,Active,Age,Description\n"
|
||||
<< "report.next.sort=due+,priority-,project+\n"
|
||||
<< "report.next.filter=status:pending\n"
|
||||
<< "\n";
|
||||
|
||||
// Write out the new file.
|
||||
if (! File::write (rc, contents.str ()))
|
||||
throw std::string ("Could not write to '") + rc + "'";
|
||||
spit (rc, contents.str ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Config::createDefaultData (const std::string& data)
|
||||
{
|
||||
Directory d (data);
|
||||
if (! d.exists ())
|
||||
d.create ();
|
||||
if (access (data.c_str (), F_OK))
|
||||
mkdir (data.c_str (), S_IRWXU);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Config::setDefaults ()
|
||||
{
|
||||
parse (defaults);
|
||||
set ("report.long.description", "Lists all task, all data, matching the specified criteria"); // TODO i18n
|
||||
set ("report.long.columns", "id,project,priority,entry,start,due,recur,age,tags,description"); // TODO i18n
|
||||
set ("report.long.labels", "ID,Project,Pri,Added,Started,Due,Recur,Age,Tags,Description"); // TODO i18n
|
||||
set ("report.long.sort", "due+,priority-,project+"); // TODO i18n
|
||||
set ("report.long.filter", "status:pending"); // TODO i18n
|
||||
|
||||
set ("report.list.description", "Lists all tasks matching the specified criteria"); // TODO i18n
|
||||
set ("report.list.columns", "id,project,priority,due,active,age,description"); // TODO i18n
|
||||
set ("report.list.labels", "ID,Project,Pri,Due,Active,Age,Description"); // TODO i18n
|
||||
set ("report.list.sort", "due+,priority-,project+"); // TODO i18n
|
||||
set ("report.list.filter", "status:pending"); // TODO i18n
|
||||
|
||||
set ("report.ls.description", "Minimal listing of all tasks matching the specified criteria"); // TODO i18n
|
||||
set ("report.ls.columns", "id,project,priority,description"); // TODO i18n
|
||||
set ("report.ls.labels", "ID,Project,Pri,Description"); // TODO i18n
|
||||
set ("report.ls.sort", "priority-,project+"); // TODO i18n
|
||||
set ("report.ls.filter", "status:pending"); // TODO i18n
|
||||
|
||||
set ("report.newest.description", "Shows the newest tasks"); // TODO i18n
|
||||
set ("report.newest.columns", "id,project,priority,due,active,age,description"); // TODO i18n
|
||||
set ("report.newest.labels", "ID,Project,Pri,Due,Active,Age,Description"); // TODO i18n
|
||||
set ("report.newest.sort", "id-"); // TODO i18n
|
||||
set ("report.newest.filter", "status:pending limit:10"); // TODO i18n
|
||||
|
||||
set ("report.oldest.description", "Shows the oldest tasks"); // TODO i18n
|
||||
set ("report.oldest.columns", "id,project,priority,due,active,age,description"); // TODO i18n
|
||||
set ("report.oldest.labels", "ID,Project,Pri,Due,Active,Age,Description"); // TODO i18n
|
||||
set ("report.oldest.sort", "id+"); // TODO i18n
|
||||
set ("report.oldest.filter", "status:pending limit:10"); // TODO i18n
|
||||
|
||||
set ("report.overdue.description", "Lists overdue tasks matching the specified criteria"); // TODO i18n
|
||||
set ("report.overdue.columns", "id,project,priority,due,active,age,description"); // TODO i18n
|
||||
set ("report.overdue.labels", "ID,Project,Pri,Due,Active,Age,Description"); // TODO i18n
|
||||
set ("report.overdue.sort", "due+,priority-,project+"); // TODO i18n
|
||||
set ("report.overdue.filter", "status:pending due.before:today"); // TODO i18n
|
||||
|
||||
set ("report.active.description", "Lists active tasks matching the specified criteria"); // TODO i18n
|
||||
set ("report.active.columns", "id,project,priority,due,active,age,description"); // TODO i18n
|
||||
set ("report.active.labels", "ID,Project,Pri,Due,Active,Age,Description"); // TODO i18n
|
||||
set ("report.active.sort", "due+,priority-,project+"); // TODO i18n
|
||||
set ("report.active.filter", "status:pending start.any:"); // TODO i18n
|
||||
|
||||
set ("report.completed.description", "Lists completed tasks matching the specified criteria"); // TODO i18n
|
||||
set ("report.completed.columns", "end,project,priority,age,description"); // TODO i18n
|
||||
set ("report.completed.labels", "Complete,Project,Pri,Age,Description"); // TODO i18n
|
||||
set ("report.completed.sort", "end+,priority-,project+"); // TODO i18n
|
||||
set ("report.completed.filter", "status:completed"); // TODO i18n
|
||||
|
||||
set ("report.recurring.description", "Lists recurring tasks matching the specified criteria"); // TODO i18n
|
||||
set ("report.recurring.columns", "id,project,priority,due,recur,active,age,description"); // TODO i18n
|
||||
set ("report.recurring.labels", "ID,Project,Pri,Due,Recur,Active,Age,Description"); // TODO i18n
|
||||
set ("report.recurring.sort", "due+,priority-,project+"); // TODO i18n
|
||||
set ("report.recurring.filter", "status:pending parent.any:"); // TODO i18n
|
||||
|
||||
set ("report.waiting.description", "Lists all waiting tasks matching the specified criteria"); // TODO i18n
|
||||
set ("report.waiting.columns", "id,project,priority,wait,age,description"); // TODO i18n
|
||||
set ("report.waiting.labels", "ID,Project,Pri,Wait,Age,Description"); // TODO i18n
|
||||
set ("report.waiting.sort", "wait+,priority-,project+"); // TODO i18n
|
||||
set ("report.waiting.filter", "status:waiting"); // TODO i18n
|
||||
|
||||
set ("report.all.description", "Lists all tasks matching the specified criteria"); // TODO i18n
|
||||
set ("report.all.columns", "id,project,priority,due,active,age,description"); // TODO i18n
|
||||
set ("report.all.labels", "ID,Project,Pri,Due,Active,Age,Description"); // TODO i18n
|
||||
set ("report.all.sort", "due+,priority-,project+"); // TODO i18n
|
||||
|
||||
set ("report.next.description", "Lists the most urgent tasks"); // TODO i18n
|
||||
set ("report.next.columns", "id,project,priority,due,active,age,description"); // TODO i18n
|
||||
set ("report.next.labels", "ID,Project,Pri,Due,Active,Age,Description"); // TODO i18n
|
||||
set ("report.next.sort", "due+,priority-,project+"); // TODO i18n
|
||||
set ("report.next.filter", "status:pending"); // TODO i18n
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Config::clear ()
|
||||
// Return the configuration value given the specified key.
|
||||
const std::string Config::get (const char* key)
|
||||
{
|
||||
std::map <std::string, std::string>::clear ();
|
||||
return this->get (std::string (key));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Return the configuration value given the specified key. If a default_value
|
||||
// is present, it will be the returned value in the event of a missing key.
|
||||
const std::string Config::get (
|
||||
const char* key,
|
||||
const char* default_value)
|
||||
{
|
||||
return this->get (std::string (key), std::string (default_value));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -507,42 +350,56 @@ const std::string Config::get (const std::string& key)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const int Config::getInteger (const std::string& key)
|
||||
// Return the configuration value given the specified key. If a default_value
|
||||
// is present, it will be the returned value in the event of a missing key.
|
||||
const std::string Config::get (
|
||||
const std::string& key,
|
||||
const std::string& default_value)
|
||||
{
|
||||
if ((*this).find (key) != (*this).end ())
|
||||
return atoi ((*this)[key].c_str ());
|
||||
return (*this)[key];
|
||||
|
||||
return 0;
|
||||
return default_value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const double Config::getReal (const std::string& key)
|
||||
{
|
||||
if ((*this).find (key) != (*this).end ())
|
||||
return atof ((*this)[key].c_str ());
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const bool Config::getBoolean (const std::string& key)
|
||||
bool Config::get (const std::string& key, const bool default_value)
|
||||
{
|
||||
if ((*this).find (key) != (*this).end ())
|
||||
{
|
||||
std::string value = lowerCase ((*this)[key]);
|
||||
|
||||
if (value == "t" || // TODO i18n
|
||||
value == "true" || // TODO i18n
|
||||
value == "1" || // no i18n
|
||||
value == "+" || // no i18n
|
||||
value == "y" || // TODO i18n
|
||||
value == "yes" || // TODO i18n
|
||||
value == "on" || // TODO i18n
|
||||
value == "enable" || // TODO i18n
|
||||
value == "enabled") // TODO i18n
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return default_value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Config::get (const std::string& key, const int default_value)
|
||||
{
|
||||
if ((*this).find (key) != (*this).end ())
|
||||
return ::atoi ((*this)[key].c_str ());
|
||||
|
||||
return default_value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
double Config::get (const std::string& key, const double default_value)
|
||||
{
|
||||
if ((*this).find (key) != (*this).end ())
|
||||
return ::atof ((*this)[key].c_str ());
|
||||
|
||||
return default_value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -576,37 +433,3 @@ void Config::all (std::vector<std::string>& items)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Config::checkForDeprecatedColor ()
|
||||
{
|
||||
int count = 0;
|
||||
std::vector <std::string> deprecated;
|
||||
foreach (i, *this)
|
||||
{
|
||||
if (i->first.find ("color.") != std::string::npos)
|
||||
{
|
||||
std::string value = get (i->first);
|
||||
if (value.find ("_") != std::string::npos)
|
||||
{
|
||||
++count;
|
||||
deprecated.push_back (i->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream out;
|
||||
if (count)
|
||||
{
|
||||
out << "Your .taskrc file contains color settings that use deprecated "
|
||||
<< "underscores. Please check:"
|
||||
<< std::endl;
|
||||
|
||||
foreach (i, deprecated)
|
||||
out << " " << *i << "=" << get (*i) << std::endl;
|
||||
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
28
src/Config.h
28
src/Config.h
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "File.h"
|
||||
|
||||
class Config : public std::map <std::string, std::string>
|
||||
{
|
||||
@@ -41,31 +40,22 @@ public:
|
||||
Config (const Config&);
|
||||
Config& operator= (const Config&);
|
||||
|
||||
void load (const std::string&, int nest = 1);
|
||||
void parse (const std::string&, int nest = 1);
|
||||
|
||||
bool load (const std::string&);
|
||||
void createDefaultRC (const std::string&, const std::string&);
|
||||
void createDefaultData (const std::string&);
|
||||
void setDefaults ();
|
||||
void clear ();
|
||||
|
||||
const std::string get (const std::string&);
|
||||
const int getInteger (const std::string&);
|
||||
const double getReal (const std::string&);
|
||||
const bool getBoolean (const std::string&);
|
||||
|
||||
const std::string get (const char*);
|
||||
const std::string get (const char*, const char*);
|
||||
const std::string get (const std::string&);
|
||||
const std::string get (const std::string&, const std::string&);
|
||||
bool get (const std::string&, const bool);
|
||||
int get (const std::string&, const int);
|
||||
double get (const std::string&, const double);
|
||||
void set (const std::string&, const int);
|
||||
void set (const std::string&, const double);
|
||||
void set (const std::string&, const std::string&);
|
||||
void all (std::vector <std::string>&);
|
||||
|
||||
std::string checkForDeprecatedColor ();
|
||||
|
||||
public:
|
||||
File original_file;
|
||||
|
||||
private:
|
||||
static std::string defaults;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
484
src/Context.cpp
484
src/Context.cpp
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -30,10 +30,7 @@
|
||||
#include <pwd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "Context.h"
|
||||
#include "Directory.h"
|
||||
#include "File.h"
|
||||
#include "Timer.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
@@ -52,8 +49,6 @@ Context::Context ()
|
||||
, tdb ()
|
||||
, stringtable ()
|
||||
, program ("")
|
||||
, file_override ("")
|
||||
, var_overrides ("")
|
||||
, cmd ()
|
||||
, inShadow (false)
|
||||
{
|
||||
@@ -69,7 +64,6 @@ void Context::initialize (int argc, char** argv)
|
||||
{
|
||||
// Capture the args.
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
program = argv[i];
|
||||
@@ -80,14 +74,8 @@ void Context::initialize (int argc, char** argv)
|
||||
}
|
||||
else
|
||||
args.push_back (argv[i]);
|
||||
}
|
||||
|
||||
initialize ();
|
||||
|
||||
// Hook system init, plus post-start event occurring at the first possible
|
||||
// moment after hook initialization.
|
||||
hooks.initialize ();
|
||||
hooks.trigger ("post-start");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -105,16 +93,16 @@ void Context::initialize ()
|
||||
{
|
||||
config.set ("curses", "off");
|
||||
|
||||
if (! config.getBoolean ("_forcecolor"))
|
||||
if (! config.get (std::string ("_forcecolor"), false))
|
||||
config.set ("color", "off");
|
||||
}
|
||||
|
||||
if (config.getBoolean ("color"))
|
||||
if (config.get ("color", true))
|
||||
initializeColorRules ();
|
||||
|
||||
// Load appropriate stringtable as soon after the config file as possible, to
|
||||
// allow all subsequent messages to be localizable.
|
||||
Directory location (config.get ("data.location"));
|
||||
std::string location = expandPath (config.get ("data.location"));
|
||||
std::string locale = config.get ("locale");
|
||||
|
||||
// If there is a locale variant (en-US.<variant>), then strip it.
|
||||
@@ -123,7 +111,7 @@ void Context::initialize ()
|
||||
locale = locale.substr (0, period);
|
||||
|
||||
if (locale != "")
|
||||
stringtable.load (location.data + "/strings." + locale);
|
||||
stringtable.load (location + "/strings." + locale);
|
||||
|
||||
// TODO Handle "--version, -v" right here?
|
||||
|
||||
@@ -132,195 +120,158 @@ void Context::initialize ()
|
||||
std::vector <std::string> all;
|
||||
split (all, location, ',');
|
||||
foreach (path, all)
|
||||
tdb.location (*path);
|
||||
tdb.location (expandPath (*path));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Context::run ()
|
||||
{
|
||||
int rc;
|
||||
Timer t ("Context::run");
|
||||
|
||||
std::string output;
|
||||
try
|
||||
{
|
||||
parse (); // Parse command line.
|
||||
rc = dispatch (output); // Dispatch to command handlers.
|
||||
parse (); // Parse command line.
|
||||
output = dispatch (); // Dispatch to command handlers.
|
||||
}
|
||||
|
||||
catch (const std::string& error)
|
||||
{
|
||||
footnote (error);
|
||||
rc = 2;
|
||||
}
|
||||
|
||||
catch (...)
|
||||
{
|
||||
footnote (stringtable.get (100, "Unknown error."));
|
||||
rc = 3;
|
||||
}
|
||||
|
||||
// Dump all debug messages.
|
||||
hooks.trigger ("pre-debug");
|
||||
if (config.getBoolean ("debug"))
|
||||
if (config.get (std::string ("debug"), false))
|
||||
foreach (d, debugMessages)
|
||||
if (config.getBoolean ("color") || config.getBoolean ("_forcecolor"))
|
||||
std::cout << colorizeDebug (*d) << std::endl;
|
||||
else
|
||||
std::cout << *d << std::endl;
|
||||
hooks.trigger ("post-debug");
|
||||
std::cout << colorizeDebug (*d) << std::endl;
|
||||
|
||||
// Dump all headers.
|
||||
hooks.trigger ("pre-header");
|
||||
foreach (h, headers)
|
||||
if (config.getBoolean ("color") || config.getBoolean ("_forcecolor"))
|
||||
std::cout << colorizeHeader (*h) << std::endl;
|
||||
else
|
||||
std::cout << *h << std::endl;
|
||||
hooks.trigger ("post-header");
|
||||
std::cout << colorizeHeader (*h) << std::endl;
|
||||
|
||||
// Dump the report output.
|
||||
hooks.trigger ("pre-output");
|
||||
std::cout << output;
|
||||
hooks.trigger ("post-output");
|
||||
|
||||
// Dump all footnotes.
|
||||
hooks.trigger ("pre-footnote");
|
||||
foreach (f, footnotes)
|
||||
if (config.getBoolean ("color") || config.getBoolean ("_forcecolor"))
|
||||
std::cout << colorizeFootnote (*f) << std::endl;
|
||||
else
|
||||
std::cout << *f << std::endl;
|
||||
hooks.trigger ("post-footnote");
|
||||
std::cout << colorizeFootnote (*f) << std::endl;
|
||||
|
||||
hooks.trigger ("pre-exit");
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Context::dispatch (std::string &out)
|
||||
std::string Context::dispatch ()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
Timer t ("Context::dispatch");
|
||||
|
||||
hooks.trigger ("pre-dispatch");
|
||||
|
||||
// TODO Just look at this thing. It cries out for a dispatch table.
|
||||
if (cmd.command == "projects") { rc = handleProjects (out); }
|
||||
else if (cmd.command == "tags") { rc = handleTags (out); }
|
||||
else if (cmd.command == "colors") { rc = handleColor (out); }
|
||||
else if (cmd.command == "version") { rc = handleVersion (out); }
|
||||
else if (cmd.command == "config") { rc = handleConfig (out); }
|
||||
else if (cmd.command == "show") { rc = handleShow (out); }
|
||||
else if (cmd.command == "help") { rc = longUsage (out); }
|
||||
else if (cmd.command == "stats") { rc = handleReportStats (out); }
|
||||
else if (cmd.command == "info") { rc = handleInfo (out); }
|
||||
else if (cmd.command == "history.monthly") { rc = handleReportHistoryMonthly (out); }
|
||||
else if (cmd.command == "history.annual") { rc = handleReportHistoryAnnual (out); }
|
||||
else if (cmd.command == "ghistory.monthly") { rc = handleReportGHistoryMonthly (out); }
|
||||
else if (cmd.command == "ghistory.annual") { rc = handleReportGHistoryAnnual (out); }
|
||||
else if (cmd.command == "summary") { rc = handleReportSummary (out); }
|
||||
else if (cmd.command == "calendar") { rc = handleReportCalendar (out); }
|
||||
else if (cmd.command == "timesheet") { rc = handleReportTimesheet (out); }
|
||||
else if (cmd.command == "add") { rc = handleAdd (out); }
|
||||
else if (cmd.command == "log") { rc = handleLog (out); }
|
||||
else if (cmd.command == "append") { rc = handleAppend (out); }
|
||||
else if (cmd.command == "prepend") { rc = handlePrepend (out); }
|
||||
else if (cmd.command == "annotate") { rc = handleAnnotate (out); }
|
||||
else if (cmd.command == "denotate") { rc = handleDenotate (out); }
|
||||
else if (cmd.command == "done") { rc = handleDone (out); }
|
||||
else if (cmd.command == "delete") { rc = handleDelete (out); }
|
||||
else if (cmd.command == "start") { rc = handleStart (out); }
|
||||
else if (cmd.command == "stop") { rc = handleStop (out); }
|
||||
else if (cmd.command == "export.csv") { rc = handleExportCSV (out); }
|
||||
else if (cmd.command == "export.ical") { rc = handleExportiCal (out); }
|
||||
else if (cmd.command == "import") { rc = handleImport (out); }
|
||||
else if (cmd.command == "duplicate") { rc = handleDuplicate (out); }
|
||||
else if (cmd.command == "edit") { rc = handleEdit (out); }
|
||||
std::string out;
|
||||
if (cmd.command == "projects") { out = handleProjects (); }
|
||||
else if (cmd.command == "tags") { out = handleTags (); }
|
||||
else if (cmd.command == "colors") { out = handleColor (); }
|
||||
else if (cmd.command == "version") { out = handleVersion (); }
|
||||
else if (cmd.command == "help") { out = longUsage (); }
|
||||
else if (cmd.command == "stats") { out = handleReportStats (); }
|
||||
else if (cmd.command == "info") { out = handleInfo (); }
|
||||
else if (cmd.command == "history") { out = handleReportHistory (); }
|
||||
else if (cmd.command == "ghistory") { out = handleReportGHistory (); }
|
||||
else if (cmd.command == "summary") { out = handleReportSummary (); }
|
||||
else if (cmd.command == "calendar") { out = handleReportCalendar (); }
|
||||
else if (cmd.command == "timesheet") { out = handleReportTimesheet (); }
|
||||
else if (cmd.command == "add") { out = handleAdd (); }
|
||||
else if (cmd.command == "append") { out = handleAppend (); }
|
||||
else if (cmd.command == "annotate") { out = handleAnnotate (); }
|
||||
else if (cmd.command == "done") { out = handleDone (); }
|
||||
else if (cmd.command == "delete") { out = handleDelete (); }
|
||||
else if (cmd.command == "start") { out = handleStart (); }
|
||||
else if (cmd.command == "stop") { out = handleStop (); }
|
||||
else if (cmd.command == "export") { out = handleExport (); }
|
||||
else if (cmd.command == "import") { out = handleImport (); }
|
||||
else if (cmd.command == "duplicate") { out = handleDuplicate (); }
|
||||
else if (cmd.command == "edit") { out = handleEdit (); }
|
||||
#ifdef FEATURE_SHELL
|
||||
else if (cmd.command == "shell") { handleShell ( ); }
|
||||
else if (cmd.command == "shell") { handleShell (); }
|
||||
#endif
|
||||
else if (cmd.command == "undo") { handleUndo ( ); }
|
||||
else if (cmd.command == "_merge") { handleMerge (out); }
|
||||
else if (cmd.command == "_projects") { rc = handleCompletionProjects (out); }
|
||||
else if (cmd.command == "_tags") { rc = handleCompletionTags (out); }
|
||||
else if (cmd.command == "_commands") { rc = handleCompletionCommands (out); }
|
||||
else if (cmd.command == "_ids") { rc = handleCompletionIDs (out); }
|
||||
else if (cmd.command == "_config") { rc = handleCompletionConfig (out); }
|
||||
else if (cmd.command == "_version") { rc = handleCompletionVersion (out); }
|
||||
else if (cmd.command == "undo") { handleUndo (); }
|
||||
else if (cmd.command == "_projects") { out = handleCompletionProjects (); }
|
||||
else if (cmd.command == "_tags") { out = handleCompletionTags (); }
|
||||
else if (cmd.command == "_commands") { out = handleCompletionCommands (); }
|
||||
else if (cmd.command == "_ids") { out = handleCompletionIDs (); }
|
||||
else if (cmd.command == "_config") { out = handleCompletionConfig (); }
|
||||
else if (cmd.command == "" &&
|
||||
sequence.size ()) { rc = handleModify (out); }
|
||||
sequence.size ()) { out = handleModify (); }
|
||||
|
||||
// Command that display IDs and therefore need TDB::gc first.
|
||||
else if (cmd.command == "next") { if (!inShadow) tdb.gc (); rc = handleReportNext (out); }
|
||||
else if (cmd.validCustom (cmd.command)) { if (!inShadow) tdb.gc (); rc = handleCustomReport (cmd.command, out); }
|
||||
else if (cmd.command == "next") { if (!inShadow) tdb.gc (); out = handleReportNext (); }
|
||||
else if (cmd.validCustom (cmd.command)) { if (!inShadow) tdb.gc (); out = handleCustomReport (cmd.command); }
|
||||
|
||||
// If the command is not recognized, display usage.
|
||||
else { hooks.trigger ("pre-usage-command");
|
||||
rc = shortUsage (out);
|
||||
hooks.trigger ("post-usage-command"); }
|
||||
else { out = shortUsage (); }
|
||||
|
||||
// Only update the shadow file if such an update was not suppressed (shadow),
|
||||
if (cmd.isWriteCommand () && !inShadow)
|
||||
shadow ();
|
||||
|
||||
hooks.trigger ("post-dispatch");
|
||||
return rc;
|
||||
return out;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Context::shadow ()
|
||||
{
|
||||
// Determine if shadow file is enabled.
|
||||
File shadowFile (config.get ("shadow.file"));
|
||||
if (shadowFile.data != "")
|
||||
std::string shadowFile = expandPath (config.get ("shadow.file"));
|
||||
if (shadowFile != "")
|
||||
{
|
||||
inShadow = true; // Prevents recursion in case shadow command writes.
|
||||
|
||||
// TODO Reinstate these checks.
|
||||
/*
|
||||
// Check for silly shadow file settings.
|
||||
std::string dataLocation = config.get ("data.location");
|
||||
if (shadowFile.data == dataLocation + "/pending.data")
|
||||
if (shadowFile == dataLocation + "/pending.data")
|
||||
throw std::string ("Configuration variable 'shadow.file' is set to "
|
||||
"overwrite your pending tasks. Please change it.");
|
||||
|
||||
if (shadowFile.data == dataLocation + "/completed.data")
|
||||
if (shadowFile == dataLocation + "/completed.data")
|
||||
throw std::string ("Configuration variable 'shadow.file' is set to "
|
||||
"overwrite your completed tasks. Please change it.");
|
||||
*/
|
||||
|
||||
std::string oldCurses = config.get ("curses");
|
||||
std::string oldColor = config.get ("color");
|
||||
config.set ("curses", "off");
|
||||
config.set ("color", "off");
|
||||
|
||||
clear ();
|
||||
|
||||
// Run report. Use shadow.command, using default.command as a fallback
|
||||
// with "list" as a default.
|
||||
std::string command = config.get ("shadow.command");
|
||||
if (command == "")
|
||||
command = config.get ("default.command");
|
||||
|
||||
std::string command = config.get ("shadow.command",
|
||||
config.get ("default.command", "list"));
|
||||
split (args, command, ' ');
|
||||
|
||||
initialize ();
|
||||
config.set ("curses", "off");
|
||||
config.set ("color", "off");
|
||||
|
||||
parse ();
|
||||
std::string result;
|
||||
(void)dispatch (result);
|
||||
std::ofstream out (shadowFile.data.c_str ());
|
||||
std::string result = dispatch ();
|
||||
std::ofstream out (shadowFile.c_str ());
|
||||
if (out.good ())
|
||||
{
|
||||
out << result;
|
||||
out.close ();
|
||||
}
|
||||
else
|
||||
throw std::string ("Could not write file '") + shadowFile.data + "'";
|
||||
throw std::string ("Could not write file '") + shadowFile + "'";
|
||||
|
||||
config.set ("curses", oldCurses);
|
||||
config.set ("color", oldColor);
|
||||
|
||||
// Optionally display a notification that the shadow file was updated.
|
||||
if (config.getBoolean ("shadow.notify"))
|
||||
footnote (std::string ("[Shadow file '") + shadowFile.data + "' updated]");
|
||||
if (config.get (std::string ("shadow.notify"), false))
|
||||
footnote (std::string ("[Shadow file '") + shadowFile + "' updated]");
|
||||
|
||||
inShadow = false;
|
||||
}
|
||||
@@ -356,18 +307,6 @@ std::string Context::canonicalize (const std::string& input) const
|
||||
return canonical;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Context::disallowModification () const
|
||||
{
|
||||
if (task.size () ||
|
||||
subst.mFrom != "" ||
|
||||
tagAdditions.size () ||
|
||||
tagRemovals.size ())
|
||||
throw std::string ("The '")
|
||||
+ cmd.command
|
||||
+ "' command does not allow further modification of a task.";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Context::loadCorrectConfigFile ()
|
||||
{
|
||||
@@ -380,79 +319,63 @@ void Context::loadCorrectConfigFile ()
|
||||
"Could not read home directory from the passwd file."));
|
||||
|
||||
std::string home = pw->pw_dir;
|
||||
File rc (home + "/.taskrc");
|
||||
Directory data (home + "./task");
|
||||
std::string rc = home + "/.taskrc";
|
||||
std::string data = home + "/.task";
|
||||
|
||||
// Is there an file_override for rc:?
|
||||
// Is there an override for rc?
|
||||
foreach (arg, args)
|
||||
{
|
||||
if (*arg == "--")
|
||||
break;
|
||||
else if (arg->substr (0, 3) == "rc:")
|
||||
{
|
||||
file_override = *arg;
|
||||
rc = File (arg->substr (3));
|
||||
|
||||
home = rc;
|
||||
std::string::size_type last_slash = rc.data.rfind ("/");
|
||||
if (last_slash != std::string::npos)
|
||||
home = rc.data.substr (0, last_slash);
|
||||
else
|
||||
home = ".";
|
||||
|
||||
rc = arg->substr (3, std::string::npos);
|
||||
args.erase (arg);
|
||||
header ("Using alternate .taskrc file " + rc.data); // TODO i18n
|
||||
header ("Using alternate .taskrc file " + rc); // TODO i18n
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Load rc file.
|
||||
config.clear (); // Dump current values.
|
||||
config.load (rc); // Load new file.
|
||||
config.setDefaults (); // Add in the custom reports.
|
||||
config.load (rc); // Load new file.
|
||||
|
||||
if (config.get ("data.location") != "")
|
||||
data = Directory (config.get ("data.location"));
|
||||
data = config.get ("data.location");
|
||||
|
||||
// Are there any var_overrides for data.location?
|
||||
// Is there an override for data?
|
||||
foreach (arg, args)
|
||||
{
|
||||
if (*arg == "--")
|
||||
break;
|
||||
else if (arg->substr (0, 17) == "rc.data.location:" ||
|
||||
arg->substr (0, 17) == "rc.data.location=")
|
||||
else if (arg->substr (0, 17) == "rc.data.location:")
|
||||
{
|
||||
data = Directory (arg->substr (17));
|
||||
header ("Using alternate data.location " + data.data); // TODO i18n
|
||||
data = arg->substr (17, std::string::npos);
|
||||
header ("Using alternate data.location " + data); // TODO i18n
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Do we need to create a default rc?
|
||||
if (! rc.exists ())
|
||||
if (access (rc.c_str (), F_OK) &&
|
||||
confirm ("A configuration file could not be found in " // TODO i18n
|
||||
+ home
|
||||
+ "\n\n"
|
||||
+ "Would you like a sample .taskrc created, so task can proceed?"))
|
||||
{
|
||||
if (confirm ("A configuration file could not be found in " // TODO i18n
|
||||
+ home
|
||||
+ "\n\n"
|
||||
+ "Would you like a sample "
|
||||
+ rc.data
|
||||
+ " created, so task can proceed?"))
|
||||
{
|
||||
config.createDefaultRC (rc, data);
|
||||
}
|
||||
else
|
||||
throw std::string ("Cannot proceed without rc file.");
|
||||
config.createDefaultRC (rc, data);
|
||||
}
|
||||
|
||||
// Create data location, if necessary.
|
||||
config.createDefaultData (data);
|
||||
|
||||
// TODO find out why this was done twice - see tw #355
|
||||
// Load rc file.
|
||||
//config.clear (); // Dump current values.
|
||||
//config.setDefaults (); // Add in the custom reports.
|
||||
//config.load (rc); // Load new file.
|
||||
config.clear (); // Dump current values.
|
||||
config.setDefaults (); // Add in the custom reports.
|
||||
config.load (rc); // Load new file.
|
||||
|
||||
// Apply overrides of type: "rc.name:value", or "rc.name=value".
|
||||
// Apply overrides of type: "rc.name:value"
|
||||
std::vector <std::string> filtered;
|
||||
bool foundTerminator = false;
|
||||
foreach (arg, args)
|
||||
@@ -468,16 +391,15 @@ void Context::loadCorrectConfigFile ()
|
||||
std::string name;
|
||||
std::string value;
|
||||
Nibbler n (*arg);
|
||||
if (n.getUntil ('.', name) &&
|
||||
n.skip ('.') &&
|
||||
n.getUntilOneOf (":=", name) &&
|
||||
n.skipN (1) &&
|
||||
if (n.getUntil ('.', name) &&
|
||||
n.skip ('.') &&
|
||||
n.getUntil (':', name) &&
|
||||
n.skip (':') &&
|
||||
n.getUntilEOS (value))
|
||||
{
|
||||
config.set (name, value);
|
||||
var_overrides += " " + *arg;
|
||||
footnote (std::string ("Configuration override ") + // TODO i18n
|
||||
arg->substr (3));
|
||||
arg->substr (3, std::string::npos));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -498,7 +420,7 @@ void Context::loadAliases ()
|
||||
{
|
||||
if (var->substr (0, 6) == "alias.")
|
||||
{
|
||||
std::string alias = var->substr (6);
|
||||
std::string alias = var->substr (6, std::string::npos);
|
||||
std::string canonical = config.get (*var);
|
||||
|
||||
aliases[alias] = canonical;
|
||||
@@ -531,7 +453,6 @@ void Context::parse (
|
||||
bool terminated = false;
|
||||
bool foundSequence = false;
|
||||
bool foundSomethingAfterSequence = false;
|
||||
bool foundNonSequence = false;
|
||||
|
||||
foreach (arg, parseArgs)
|
||||
{
|
||||
@@ -546,7 +467,7 @@ void Context::parse (
|
||||
|
||||
// Sequence
|
||||
// Note: "add" doesn't require an ID
|
||||
else if (parseCmd.command != "add" &&
|
||||
else if (parseCmd.command != "add" &&
|
||||
! foundSomethingAfterSequence &&
|
||||
parseSequence.valid (*arg))
|
||||
{
|
||||
@@ -564,14 +485,12 @@ void Context::parse (
|
||||
if (foundSequence)
|
||||
foundSomethingAfterSequence = true;
|
||||
|
||||
foundNonSequence = true;
|
||||
|
||||
if (arg->find (',') != std::string::npos)
|
||||
throw stringtable.get (TAGS_NO_COMMA,
|
||||
"Tags are not permitted to contain commas.");
|
||||
|
||||
tagAdditions.push_back (arg->substr (1));
|
||||
parseTask.addTag (arg->substr (1));
|
||||
tagAdditions.push_back (arg->substr (1, std::string::npos));
|
||||
parseTask.addTag (arg->substr (1, std::string::npos));
|
||||
}
|
||||
|
||||
// Tags to remove begin with '-'.
|
||||
@@ -583,13 +502,11 @@ void Context::parse (
|
||||
if (foundSequence)
|
||||
foundSomethingAfterSequence = true;
|
||||
|
||||
foundNonSequence = true;
|
||||
|
||||
if (arg->find (',') != std::string::npos)
|
||||
throw stringtable.get (TAGS_NO_COMMA,
|
||||
"Tags are not permitted to contain commas.");
|
||||
|
||||
tagRemovals.push_back (arg->substr (1));
|
||||
tagRemovals.push_back (arg->substr (1, std::string::npos));
|
||||
}
|
||||
|
||||
// Atributes - name[.mod]:[value]
|
||||
@@ -599,8 +516,6 @@ void Context::parse (
|
||||
if (foundSequence)
|
||||
foundSomethingAfterSequence = true;
|
||||
|
||||
foundNonSequence = true;
|
||||
|
||||
attribute.parse (*arg);
|
||||
|
||||
// There has to be a better way. And it starts with a fresh coffee.
|
||||
@@ -613,14 +528,7 @@ void Context::parse (
|
||||
attribute.mod (mod);
|
||||
attribute.value (value);
|
||||
|
||||
// Preserve modifier in the key, to allow multiple modifiers on the
|
||||
// same attribute. Bug #252.
|
||||
if (name != "" && mod != "")
|
||||
parseTask[name + "." + mod] = attribute;
|
||||
else
|
||||
parseTask[name] = attribute;
|
||||
|
||||
autoFilter (attribute, parseFilter);
|
||||
parseTask[attribute.name ()] = attribute;
|
||||
}
|
||||
|
||||
// *arg has the appearance of an attribute (foo:bar), but isn't
|
||||
@@ -630,8 +538,6 @@ void Context::parse (
|
||||
if (foundSequence)
|
||||
foundSomethingAfterSequence = true;
|
||||
|
||||
foundNonSequence = true;
|
||||
|
||||
if (descCandidate.length ())
|
||||
descCandidate += " ";
|
||||
descCandidate += *arg;
|
||||
@@ -644,8 +550,6 @@ void Context::parse (
|
||||
if (foundSequence)
|
||||
foundSomethingAfterSequence = true;
|
||||
|
||||
foundNonSequence = true;
|
||||
|
||||
debug ("parse subst '" + *arg + "'");
|
||||
parseSubst.parse (*arg);
|
||||
}
|
||||
@@ -659,8 +563,6 @@ void Context::parse (
|
||||
|
||||
if (foundSequence)
|
||||
foundSomethingAfterSequence = true;
|
||||
|
||||
foundNonSequence = true;
|
||||
}
|
||||
|
||||
// Anything else is just considered description.
|
||||
@@ -669,8 +571,6 @@ void Context::parse (
|
||||
if (foundSequence)
|
||||
foundSomethingAfterSequence = true;
|
||||
|
||||
foundNonSequence = true;
|
||||
|
||||
if (descCandidate.length ())
|
||||
descCandidate += " ";
|
||||
descCandidate += *arg;
|
||||
@@ -694,21 +594,6 @@ void Context::parse (
|
||||
{
|
||||
debug ("parse description '" + descCandidate + "'");
|
||||
parseTask.set ("description", descCandidate);
|
||||
|
||||
foundNonSequence = true;
|
||||
|
||||
// Now convert the description to a filter on each word, if necessary.
|
||||
if (parseCmd.isReadOnlyCommand ())
|
||||
{
|
||||
std::vector <std::string> words;
|
||||
split (words, descCandidate, ' ');
|
||||
std::vector <std::string>::iterator it;
|
||||
for (it = words.begin (); it != words.end (); ++it)
|
||||
{
|
||||
Att a ("description", "contains", *it);
|
||||
autoFilter (a, parseFilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// At this point, either a sequence or a command should have been found.
|
||||
@@ -716,57 +601,34 @@ void Context::parse (
|
||||
parseCmd.parse (descCandidate);
|
||||
|
||||
// Read-only command (reports, status, info ...) use filters. Write commands
|
||||
// (add, done ...) do not. The filter was constructed iteratively above, but
|
||||
// tags were omitted, so they are added now.
|
||||
// (add, done ...) do not.
|
||||
if (parseCmd.isReadOnlyCommand ())
|
||||
autoFilter (parseFilter);
|
||||
autoFilter (parseTask, parseFilter);
|
||||
|
||||
// If no command was specified, and there were no command line arguments
|
||||
// then invoke the default command.
|
||||
if (parseCmd.command == "")
|
||||
if (parseCmd.command == "" && parseArgs.size () == 0)
|
||||
{
|
||||
if (parseArgs.size () == 0)
|
||||
std::string defaultCommand = config.get ("default.command");
|
||||
if (defaultCommand != "")
|
||||
{
|
||||
// Apply overrides, if any.
|
||||
std::string defaultCommand = config.get ("default.command");
|
||||
if (defaultCommand != "")
|
||||
{
|
||||
// Add on the overrides.
|
||||
defaultCommand += " " + file_override + " " + var_overrides;
|
||||
// Stuff the command line.
|
||||
parseArgs.clear ();
|
||||
split (parseArgs, defaultCommand, ' ');
|
||||
header ("[task " + defaultCommand + "]");
|
||||
|
||||
// Stuff the command line.
|
||||
args.clear ();
|
||||
split (args, defaultCommand, ' ');
|
||||
header ("[task " + trim (defaultCommand) + "]");
|
||||
|
||||
// Reinitialize the context and recurse.
|
||||
file_override = "";
|
||||
var_overrides = "";
|
||||
footnotes.clear ();
|
||||
initialize ();
|
||||
parse (args, cmd, task, sequence, subst, filter);
|
||||
}
|
||||
else
|
||||
throw stringtable.get (
|
||||
CMD_MISSING,
|
||||
"You must specify a command, or a task ID to modify");
|
||||
}
|
||||
|
||||
// If the command "task 123" is entered, but with no modifier arguments,
|
||||
// then the actual command is assumed to be "info".
|
||||
else if (!foundNonSequence &&
|
||||
(parseTask.id != 0 || parseSequence.size () != 0))
|
||||
{
|
||||
std::cout << "No command - assuming 'info'." << std::endl;
|
||||
parseCmd.command = "info";
|
||||
// Reinitialize the context and recurse.
|
||||
initialize ();
|
||||
parse (args, cmd, task, sequence, subst, filter);
|
||||
}
|
||||
else
|
||||
throw stringtable.get (
|
||||
CMD_MISSING,
|
||||
"You must specify a command, or a task ID to modify");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Note: The reason some of these are commented out is because the ::clear
|
||||
// method is not really "clear" but "clear_some". Some members do not need to
|
||||
// be initialized. That makes this method something of a misnomer. So be it.
|
||||
void Context::clear ()
|
||||
{
|
||||
// Config config;
|
||||
@@ -780,8 +642,6 @@ void Context::clear ()
|
||||
// stringtable.clear ();
|
||||
program = "";
|
||||
args.clear ();
|
||||
file_override = "";
|
||||
var_overrides = "";
|
||||
cmd.command = "";
|
||||
tagAdditions.clear ();
|
||||
tagRemovals.clear ();
|
||||
@@ -792,86 +652,78 @@ void Context::clear ()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Add all the attributes in the task to the filter. All except uuid.
|
||||
void Context::autoFilter (Att& a, Filter& f)
|
||||
void Context::autoFilter (Task& t, Filter& f)
|
||||
{
|
||||
// Words are found in the description using the .has modifier.
|
||||
if (a.name () == "description" && a.mod () == "")
|
||||
foreach (att, t)
|
||||
{
|
||||
std::vector <std::string> words;
|
||||
split (words, a.value (), ' ');
|
||||
foreach (word, words)
|
||||
// Words are found in the description using the .has modifier.
|
||||
if (att->first == "description" && att->second.mod () == "")
|
||||
{
|
||||
f.push_back (Att ("description", "has", *word));
|
||||
debug ("auto filter: " + a.name () + ".has:" + *word);
|
||||
std::vector <std::string> words;
|
||||
split (words, att->second.value (), ' ');
|
||||
foreach (word, words)
|
||||
{
|
||||
f.push_back (Att ("description", "has", *word));
|
||||
debug ("auto filter: " + att->first + ".has:" + *word);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Projects are matched left-most.
|
||||
else if (a.name () == "project" && a.mod () == "")
|
||||
{
|
||||
if (a.value () != "")
|
||||
// Projects are matched left-most.
|
||||
else if (att->first == "project" && att->second.mod () == "")
|
||||
{
|
||||
f.push_back (Att ("project", "startswith", a.value ()));
|
||||
debug ("auto filter: " + a.name () + ".startswith:" + a.value ());
|
||||
if (att->second.value () != "")
|
||||
{
|
||||
f.push_back (Att ("project", "startswith", att->second.value ()));
|
||||
debug ("auto filter: " + att->first + ".startswith:" + att->second.value ());
|
||||
}
|
||||
else
|
||||
{
|
||||
f.push_back (Att ("project", "is", att->second.value ()));
|
||||
debug ("auto filter: " + att->first + ".is:" + att->second.value ());
|
||||
}
|
||||
}
|
||||
|
||||
// The limit attribute does not participate in filtering, and needs to be
|
||||
// specifically handled in handleCustomReport.
|
||||
else if (att->first == "limit")
|
||||
{
|
||||
}
|
||||
|
||||
// Every task has a unique uuid by default, and it shouldn't be included,
|
||||
// because it is guaranteed to not match.
|
||||
else if (att->first == "uuid")
|
||||
{
|
||||
}
|
||||
|
||||
// The mechanism for filtering on tags is +/-<tag>.
|
||||
else if (att->first == "tags")
|
||||
{
|
||||
}
|
||||
|
||||
// Generic attribute matching.
|
||||
else
|
||||
{
|
||||
f.push_back (Att ("project", "is", a.value ()));
|
||||
debug ("auto filter: " + a.name () + ".is:" + a.value ());
|
||||
f.push_back (att->second);
|
||||
debug ("auto filter: " +
|
||||
att->first +
|
||||
(att->second.mod () != "" ?
|
||||
("." + att->second.mod () + ":") :
|
||||
":") +
|
||||
att->second.value ());
|
||||
}
|
||||
}
|
||||
|
||||
// The limit attribute does not participate in filtering, and needs to be
|
||||
// specifically handled in handleCustomReport.
|
||||
else if (a.name () == "limit")
|
||||
{
|
||||
}
|
||||
|
||||
// Every task has a unique uuid by default, and it shouldn't be included,
|
||||
// because it is guaranteed to not match.
|
||||
else if (a.name () == "uuid")
|
||||
{
|
||||
}
|
||||
|
||||
// The mechanism for filtering on tags is +/-<tag>.
|
||||
// Do not handle here - see below.
|
||||
else if (a.name () == "tags")
|
||||
{
|
||||
}
|
||||
|
||||
// Generic attribute matching.
|
||||
else
|
||||
{
|
||||
f.push_back (a);
|
||||
debug ("auto filter: " +
|
||||
a.name () +
|
||||
(a.mod () != "" ?
|
||||
("." + a.mod () + ":") :
|
||||
":") +
|
||||
a.value ());
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Add all the tags in the task to the filter.
|
||||
void Context::autoFilter (Filter& f)
|
||||
{
|
||||
// This is now a correct implementation of a filter on the presence or absence
|
||||
// of a tag. The prior code provided the illusion of leftmost partial tag
|
||||
// matches, but was really using the 'contains' and 'nocontains' attribute
|
||||
// modifiers. See bug #293.
|
||||
|
||||
// Include tagAdditions.
|
||||
foreach (tag, tagAdditions)
|
||||
{
|
||||
f.push_back (Att ("tags", "word", *tag));
|
||||
f.push_back (Att ("tags", "has", *tag));
|
||||
debug ("auto filter: +" + *tag);
|
||||
}
|
||||
|
||||
// Include tagRemovals.
|
||||
foreach (tag, tagRemovals)
|
||||
{
|
||||
f.push_back (Att ("tags", "noword", *tag));
|
||||
f.push_back (Att ("tags", "hasnt", *tag));
|
||||
debug ("auto filter: -" + *tag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "Task.h"
|
||||
#include "TDB.h"
|
||||
#include "StringTable.h"
|
||||
#include "Hooks.h"
|
||||
|
||||
class Context
|
||||
{
|
||||
@@ -51,11 +50,10 @@ public:
|
||||
void initialize (); // for reinitializing
|
||||
int run (); // task classic
|
||||
int interactive (); // task interactive (not implemented)
|
||||
int dispatch (std::string&); // command handler dispatch
|
||||
std::string dispatch (); // command handler dispatch
|
||||
void shadow (); // shadow file update
|
||||
|
||||
int getWidth (); // determine terminal width
|
||||
int getHeight (); // determine terminal height
|
||||
|
||||
void header (const std::string&); // Header message sink
|
||||
void footnote (const std::string&); // Footnote message sink
|
||||
@@ -67,13 +65,11 @@ public:
|
||||
void clear ();
|
||||
|
||||
std::string canonicalize (const std::string&) const;
|
||||
void disallowModification () const;
|
||||
|
||||
private:
|
||||
void loadCorrectConfigFile ();
|
||||
void loadAliases ();
|
||||
void autoFilter (Att&, Filter&);
|
||||
void autoFilter (Filter&);
|
||||
void autoFilter (Task&, Filter&);
|
||||
|
||||
public:
|
||||
Config config;
|
||||
@@ -86,14 +82,12 @@ public:
|
||||
StringTable stringtable;
|
||||
std::string program;
|
||||
std::vector <std::string> args;
|
||||
std::string file_override;
|
||||
std::string var_overrides;
|
||||
Cmd cmd;
|
||||
std::map <std::string, std::string> aliases;
|
||||
std::vector <std::string> tagAdditions;
|
||||
std::vector <std::string> tagRemovals;
|
||||
Hooks hooks;
|
||||
|
||||
private:
|
||||
std::vector <std::string> headers;
|
||||
std::vector <std::string> footnotes;
|
||||
std::vector <std::string> debugMessages;
|
||||
|
||||
483
src/Date.cpp
483
src/Date.cpp
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -25,18 +25,13 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "Date.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "Context.h"
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Defaults to "now".
|
||||
@@ -56,27 +51,9 @@ Date::Date (const int m, const int d, const int y)
|
||||
{
|
||||
// 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;
|
||||
|
||||
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;
|
||||
t.tm_mday = d;
|
||||
t.tm_mon = m - 1;
|
||||
t.tm_year = y - 1900;
|
||||
|
||||
mT = mktime (&t);
|
||||
}
|
||||
@@ -84,12 +61,9 @@ 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 = -1; // So we can check later.
|
||||
int hour = 0;
|
||||
int minute = 0;
|
||||
int second = 0;
|
||||
int month = 0;
|
||||
int day = 0;
|
||||
int year = 0;
|
||||
|
||||
// Perhaps it is an epoch date, in string form?
|
||||
if (isEpoch (mdy))
|
||||
@@ -108,253 +82,120 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
|
||||
// Single or double digit.
|
||||
case 'm':
|
||||
if (i >= mdy.length () ||
|
||||
! isdigit (mdy[i]))
|
||||
! ::isdigit (mdy[i]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (m).";
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
|
||||
if (i + 1 < mdy.length () &&
|
||||
(mdy[i + 0] == '0' || mdy[i + 0] == '1') &&
|
||||
isdigit (mdy[i + 1]))
|
||||
::isdigit (mdy[i + 1]))
|
||||
{
|
||||
month = atoi (mdy.substr (i, 2).c_str ());
|
||||
month = ::atoi (mdy.substr (i, 2).c_str ());
|
||||
i += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
month = atoi (mdy.substr (i, 1).c_str ());
|
||||
month = ::atoi (mdy.substr (i, 1).c_str ());
|
||||
++i;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
if (i >= mdy.length () ||
|
||||
! isdigit (mdy[i]))
|
||||
! ::isdigit (mdy[i]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (d).";
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
|
||||
if (i + 1 < mdy.length () &&
|
||||
(mdy[i + 0] == '0' || mdy[i + 0] == '1' || mdy[i + 0] == '2' || mdy[i + 0] == '3') &&
|
||||
isdigit (mdy[i + 1]))
|
||||
::isdigit (mdy[i + 1]))
|
||||
{
|
||||
day = atoi (mdy.substr (i, 2).c_str ());
|
||||
day = ::atoi (mdy.substr (i, 2).c_str ());
|
||||
i += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
day = atoi (mdy.substr (i, 1).c_str ());
|
||||
day = ::atoi (mdy.substr (i, 1).c_str ());
|
||||
++i;
|
||||
}
|
||||
break;
|
||||
|
||||
// Double digit.
|
||||
case 'y':
|
||||
if (i + 1 >= mdy.length () ||
|
||||
! isdigit (mdy[i + 0]) ||
|
||||
! isdigit (mdy[i + 1]))
|
||||
if (i + 1 >= mdy.length () ||
|
||||
! ::isdigit (mdy[i + 0]) ||
|
||||
! ::isdigit (mdy[i + 1]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (y).";
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
|
||||
year = atoi (mdy.substr (i, 2).c_str ()) + 2000;
|
||||
year = ::atoi (mdy.substr (i, 2).c_str ()) + 2000;
|
||||
i += 2;
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
if (i + 1 >= mdy.length () ||
|
||||
! isdigit (mdy[i + 0]) ||
|
||||
! isdigit (mdy[i + 1]))
|
||||
! ::isdigit (mdy[i + 0]) ||
|
||||
! ::isdigit (mdy[i + 1]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (M).";
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
|
||||
month = atoi (mdy.substr (i, 2).c_str ());
|
||||
month = ::atoi (mdy.substr (i, 2).c_str ());
|
||||
i += 2;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
if (i + 1 >= mdy.length () ||
|
||||
! isdigit (mdy[i + 0]) ||
|
||||
! isdigit (mdy[i + 1]))
|
||||
! ::isdigit (mdy[i + 0]) ||
|
||||
! ::isdigit (mdy[i + 1]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (D).";
|
||||
}
|
||||
|
||||
day = atoi (mdy.substr (i, 2).c_str ());
|
||||
i += 2;
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
if (i + 1 >= mdy.length () ||
|
||||
! isdigit (mdy[i + 0]) ||
|
||||
! isdigit (mdy[i + 1]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (V).";
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
|
||||
day = ::atoi (mdy.substr (i, 2).c_str ());
|
||||
i += 2;
|
||||
break;
|
||||
|
||||
// Quadruple digit.
|
||||
case 'Y':
|
||||
if (i + 3 >= mdy.length () ||
|
||||
! isdigit (mdy[i + 0]) ||
|
||||
! isdigit (mdy[i + 1]) ||
|
||||
! isdigit (mdy[i + 2]) ||
|
||||
! isdigit (mdy[i + 3]))
|
||||
! ::isdigit (mdy[i + 0]) ||
|
||||
! ::isdigit (mdy[i + 1]) ||
|
||||
! ::isdigit (mdy[i + 2]) ||
|
||||
! ::isdigit (mdy[i + 3]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (Y).";
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
|
||||
year = atoi (mdy.substr (i, 4).c_str ());
|
||||
year = ::atoi (mdy.substr (i, 4).c_str ());
|
||||
i += 4;
|
||||
break;
|
||||
|
||||
// Short names with 3 characters
|
||||
case 'a':
|
||||
if (i + 2 >= mdy.length () ||
|
||||
isdigit (mdy[i + 0]) ||
|
||||
isdigit (mdy[i + 1]) ||
|
||||
isdigit (mdy[i + 2]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (a).";
|
||||
}
|
||||
|
||||
i += 3;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
if (i + 2 >= mdy.length () ||
|
||||
isdigit (mdy[i + 0]) ||
|
||||
isdigit (mdy[i + 1]) ||
|
||||
isdigit (mdy[i + 2]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (b).";
|
||||
}
|
||||
|
||||
month = Date::monthOfYear (mdy.substr (i, 3).c_str());
|
||||
i += 3;
|
||||
break;
|
||||
|
||||
// Long names
|
||||
case 'A':
|
||||
if (i + 2 >= mdy.length () ||
|
||||
isdigit (mdy[i + 0]) ||
|
||||
isdigit (mdy[i + 1]) ||
|
||||
isdigit (mdy[i + 2]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (A).";
|
||||
}
|
||||
|
||||
i += Date::dayName( Date::dayOfWeek (mdy.substr (i, 3).c_str()) ).size();
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
if (i + 2 >= mdy.length () ||
|
||||
isdigit (mdy[i + 0]) ||
|
||||
isdigit (mdy[i + 1]) ||
|
||||
isdigit (mdy[i + 2]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (B).";
|
||||
}
|
||||
|
||||
month = Date::monthOfYear (mdy.substr (i, 3).c_str());
|
||||
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])
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (DEFAULT).";
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
++i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Default the year to the current year, for formats that lack Y/y.
|
||||
if (year == -1)
|
||||
{
|
||||
time_t now = time (NULL);
|
||||
struct tm* default_year = localtime (&now);
|
||||
year = default_year->tm_year + 1900;
|
||||
}
|
||||
|
||||
if (i < mdy.length ())
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date in " + format + " format.";
|
||||
|
||||
if (!valid (month, day, year))
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date (VALID).";
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
|
||||
// Convert to epoch.
|
||||
// Duplicate Date::Date (const int, const int, const int);
|
||||
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;
|
||||
t.tm_hour = hour;
|
||||
t.tm_min = minute;
|
||||
t.tm_sec = second;
|
||||
t.tm_mday = day;
|
||||
t.tm_mon = month - 1;
|
||||
t.tm_year = year - 1900;
|
||||
|
||||
mT = mktime (&t);
|
||||
}
|
||||
@@ -384,25 +225,6 @@ std::string Date::toEpochString ()
|
||||
return epoch.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 19980119T070000Z = YYYYMMDDThhmmssZ
|
||||
std::string Date::toISO ()
|
||||
{
|
||||
struct tm* t = gmtime (&mT);
|
||||
|
||||
std::stringstream iso;
|
||||
iso << std::setw (4) << std::setfill ('0') << t->tm_year + 1900
|
||||
<< std::setw (2) << std::setfill ('0') << t->tm_mon + 1
|
||||
<< std::setw (2) << std::setfill ('0') << t->tm_mday
|
||||
<< "T"
|
||||
<< std::setw (2) << std::setfill ('0') << t->tm_hour
|
||||
<< std::setw (2) << std::setfill ('0') << t->tm_min
|
||||
<< std::setw (2) << std::setfill ('0') << t->tm_sec
|
||||
<< "Z";
|
||||
|
||||
return iso.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Date::toEpoch (time_t& epoch)
|
||||
{
|
||||
@@ -433,22 +255,13 @@ const std::string Date::toString (const std::string& format /*= "m/d/Y" */) cons
|
||||
char c = localFormat[i];
|
||||
switch (c)
|
||||
{
|
||||
case 'm': sprintf (buffer, "%d", this->month ()); break;
|
||||
case 'M': sprintf (buffer, "%02d", this->month ()); break;
|
||||
case 'd': sprintf (buffer, "%d", this->day ()); break;
|
||||
case 'D': sprintf (buffer, "%02d", this->day ()); break;
|
||||
case 'y': sprintf (buffer, "%02d", this->year () % 100); break;
|
||||
case 'Y': sprintf (buffer, "%d", this->year ()); break;
|
||||
case 'a': sprintf (buffer, "%.3s", Date::dayName (dayOfWeek ()).c_str ()); break;
|
||||
case 'A': sprintf (buffer, "%s", Date::dayName (dayOfWeek ()).c_str ()); break;
|
||||
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;
|
||||
case 'm': sprintf (buffer, "%d", this->month ()); break;
|
||||
case 'M': sprintf (buffer, "%02d", this->month ()); break;
|
||||
case 'd': sprintf (buffer, "%d", this->day ()); break;
|
||||
case 'D': sprintf (buffer, "%02d", this->day ()); break;
|
||||
case 'y': sprintf (buffer, "%02d", this->year () % 100); break;
|
||||
case 'Y': sprintf (buffer, "%d", this->year ()); break;
|
||||
default: sprintf (buffer, "%c", c); break;
|
||||
}
|
||||
|
||||
formatted += buffer;
|
||||
@@ -457,19 +270,6 @@ const std::string Date::toString (const std::string& format /*= "m/d/Y" */) cons
|
||||
return formatted;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string Date::toStringWithTime (const std::string& format /*= "m/d/Y" */) const
|
||||
{
|
||||
// Format as above.
|
||||
std::string formatted = toString (format);
|
||||
|
||||
char buffer[12];
|
||||
sprintf (buffer, " %d:%02d:%02d", hour (), minute (), second ());
|
||||
formatted += buffer;
|
||||
|
||||
return formatted;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Date::valid (const std::string& input, const std::string& format)
|
||||
{
|
||||
@@ -486,22 +286,6 @@ 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)
|
||||
{
|
||||
@@ -619,7 +403,7 @@ int Date::weekOfYear (int weekStart) const
|
||||
throw std::string ("The 'weekstart' configuration variable may "
|
||||
"only contain 'Sunday' or 'Monday'.");
|
||||
|
||||
int weekNumber = atoi (weekStr);
|
||||
int weekNumber = ::atoi (weekStr);
|
||||
|
||||
if (weekStart == 0)
|
||||
weekNumber += 1;
|
||||
@@ -639,64 +423,17 @@ int Date::dayOfWeek (const std::string& input)
|
||||
{
|
||||
std::string in = lowerCase (input);
|
||||
|
||||
if (in == "sunday" || in == "sun") return 0;
|
||||
if (in == "monday" || in == "mon") return 1;
|
||||
if (in == "tuesday" || in == "tue") return 2;
|
||||
if (in == "wednesday" || in == "wed") return 3;
|
||||
if (in == "thursday" || in == "thu") return 4;
|
||||
if (in == "friday" || in == "fri") return 5;
|
||||
if (in == "saturday" || in == "sat") return 6;
|
||||
if (in == "sunday") return 0;
|
||||
if (in == "monday") return 1;
|
||||
if (in == "tuesday") return 2;
|
||||
if (in == "wednesday") return 3;
|
||||
if (in == "thursday") return 4;
|
||||
if (in == "friday") return 5;
|
||||
if (in == "saturday") return 6;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Date::monthOfYear (const std::string& input)
|
||||
{
|
||||
std::string in = lowerCase (input);
|
||||
|
||||
if (in == "january" || in == "jan") return 1;
|
||||
if (in == "february" || in == "feb") return 2;
|
||||
if (in == "march" || in == "mar") return 3;
|
||||
if (in == "april" || in == "apr") return 4;
|
||||
if (in == "may" || in == "may") return 5;
|
||||
if (in == "june" || in == "jun") return 6;
|
||||
if (in == "july" || in == "jul") return 7;
|
||||
if (in == "august" || in == "aug") return 8;
|
||||
if (in == "september" || in == "sep") return 9;
|
||||
if (in == "october" || in == "oct") return 10;
|
||||
if (in == "november" || in == "nov") return 11;
|
||||
if (in == "december" || in == "dec") return 12;
|
||||
|
||||
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
|
||||
{
|
||||
@@ -718,27 +455,6 @@ int Date::year () const
|
||||
return t->tm_year + 1900;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Date::hour () const
|
||||
{
|
||||
struct tm* t = localtime (&mT);
|
||||
return t->tm_hour;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Date::minute () const
|
||||
{
|
||||
struct tm* t = localtime (&mT);
|
||||
return t->tm_min;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Date::second () const
|
||||
{
|
||||
struct tm* t = localtime (&mT);
|
||||
return t->tm_sec;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Date::operator== (const Date& rhs)
|
||||
{
|
||||
@@ -775,18 +491,6 @@ 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)
|
||||
{
|
||||
@@ -820,7 +524,7 @@ bool Date::sameYear (const Date& rhs)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Date Date::operator+ (const int delta)
|
||||
{
|
||||
return Date (mT + delta);
|
||||
return Date::Date (mT + delta);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -849,7 +553,7 @@ bool Date::isEpoch (const std::string& input)
|
||||
if (digitsOnly (input) &&
|
||||
input.length () > 8)
|
||||
{
|
||||
mT = (time_t) atoi (input.c_str ());
|
||||
mT = (time_t) ::atoi (input.c_str ());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -890,13 +594,6 @@ 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)
|
||||
@@ -961,60 +658,6 @@ 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.
|
||||
@@ -1026,13 +669,13 @@ bool Date::isRelativeDate (const std::string& input)
|
||||
|
||||
if (isdigit (input[1]))
|
||||
{
|
||||
number = atoi (input.substr (0, 2).c_str ());
|
||||
ordinal = lowerCase (input.substr (2));
|
||||
number = ::atoi (input.substr (0, 2).c_str ());
|
||||
ordinal = lowerCase (input.substr (2, std::string::npos));
|
||||
}
|
||||
else
|
||||
{
|
||||
number = atoi (input.substr (0, 2).c_str ());
|
||||
ordinal = lowerCase (input.substr (1));
|
||||
number = ::atoi (input.substr (0, 2).c_str ());
|
||||
ordinal = lowerCase (input.substr (1, std::string::npos));
|
||||
}
|
||||
|
||||
// Sanity check.
|
||||
|
||||
13
src/Date.h
13
src/Date.h
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
class Date;
|
||||
|
||||
class Date
|
||||
@@ -39,7 +38,6 @@ 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 ();
|
||||
@@ -47,15 +45,11 @@ public:
|
||||
void toEpoch (time_t&);
|
||||
time_t toEpoch ();
|
||||
std::string toEpochString ();
|
||||
std::string toISO ();
|
||||
void toMDY (int&, int&, int&);
|
||||
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);
|
||||
@@ -63,16 +57,12 @@ public:
|
||||
static std::string dayName (int);
|
||||
static int weekOfYear (const std::string&);
|
||||
static int dayOfWeek (const std::string&);
|
||||
static int monthOfYear (const std::string&);
|
||||
|
||||
int month () const;
|
||||
int day () const;
|
||||
int year () const;
|
||||
int weekOfYear (int) const;
|
||||
int dayOfWeek () const;
|
||||
int hour () const;
|
||||
int minute () const;
|
||||
int second () const;
|
||||
|
||||
bool operator== (const Date&);
|
||||
bool operator!= (const Date&);
|
||||
@@ -80,7 +70,6 @@ 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&);
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation; either version 2 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program; if not, write to the
|
||||
//
|
||||
// Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor,
|
||||
// Boston, MA
|
||||
// 02110-1301
|
||||
// USA
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include "Directory.h"
|
||||
#include "../auto.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Directory::Directory ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Directory::Directory (const Directory& other)
|
||||
: File::File (other)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Directory::Directory (const File& other)
|
||||
: File::File (other)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Directory::Directory (const Path& other)
|
||||
: File::File (other)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Directory::Directory (const std::string& in)
|
||||
: File::File (in)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Directory::~Directory ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Directory& Directory::operator= (const Directory& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
File::operator= (other);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Directory::create ()
|
||||
{
|
||||
return mkdir (data.c_str (), 0755) == 0 ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Directory::remove ()
|
||||
{
|
||||
return rmdir (data.c_str ()) == 0 ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::vector <std::string> Directory::list ()
|
||||
{
|
||||
std::vector <std::string> files;
|
||||
list (data, files, false);
|
||||
return files;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::vector <std::string> Directory::listRecursive ()
|
||||
{
|
||||
std::vector <std::string> files;
|
||||
list (data, files, true);
|
||||
return files;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Directory::list (
|
||||
const std::string& base,
|
||||
std::vector <std::string>& results,
|
||||
bool recursive)
|
||||
{
|
||||
DIR* dp = opendir (base.c_str ());
|
||||
if (dp != NULL)
|
||||
{
|
||||
struct dirent* de;
|
||||
while ((de = readdir (dp)) != NULL)
|
||||
{
|
||||
if (!strcmp (de->d_name, ".") ||
|
||||
!strcmp (de->d_name, ".."))
|
||||
continue;
|
||||
|
||||
#if defined (SOLARIS) || defined (HAIKU)
|
||||
struct stat s;
|
||||
stat (de->d_name, &s);
|
||||
if (recursive && s.st_mode & S_IFDIR)
|
||||
list (base + "/" + de->d_name, results, recursive);
|
||||
else
|
||||
results.push_back (base + "/" + de->d_name);
|
||||
#else
|
||||
if (recursive && de->d_type == DT_DIR)
|
||||
list (base + "/" + de->d_name, results, recursive);
|
||||
else
|
||||
results.push_back (base + "/" + de->d_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
closedir (dp);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1,55 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation; either version 2 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program; if not, write to the
|
||||
//
|
||||
// Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor,
|
||||
// Boston, MA
|
||||
// 02110-1301
|
||||
// USA
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef INCLUDED_DIRECTORY
|
||||
#define INCLUDED_DIRECTORY
|
||||
|
||||
#include "File.h"
|
||||
|
||||
class Directory : public File
|
||||
{
|
||||
public:
|
||||
Directory ();
|
||||
Directory (const Directory&);
|
||||
Directory (const File&);
|
||||
Directory (const Path&);
|
||||
Directory (const std::string&);
|
||||
virtual ~Directory ();
|
||||
|
||||
Directory& operator= (const Directory&);
|
||||
|
||||
virtual bool create ();
|
||||
virtual bool remove ();
|
||||
|
||||
std::vector <std::string> list ();
|
||||
std::vector <std::string> listRecursive ();
|
||||
|
||||
private:
|
||||
void list (const std::string&, std::vector <std::string>&, bool);
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
251
src/Duration.cpp
251
src/Duration.cpp
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -29,32 +29,20 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "Duration.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::Duration ()
|
||||
: mSecs (0)
|
||||
, mNegative (false)
|
||||
: mDays (0)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::Duration (time_t input)
|
||||
{
|
||||
if (input < 0)
|
||||
{
|
||||
mSecs = -input;
|
||||
mNegative = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
mSecs = input;
|
||||
mNegative = false;
|
||||
}
|
||||
mDays = input;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -63,104 +51,36 @@ Duration::Duration (const std::string& input)
|
||||
parse (input);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::operator int ()
|
||||
{
|
||||
return (int) mDays;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::operator time_t ()
|
||||
{
|
||||
return mSecs;
|
||||
return mDays;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::operator std::string ()
|
||||
{
|
||||
std::stringstream s;
|
||||
s << (mNegative ? -mSecs : mSecs);
|
||||
s << mDays;
|
||||
return s.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration& Duration::operator= (const Duration& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
mSecs = other.mSecs;
|
||||
mNegative = other.mNegative;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Duration::format () const
|
||||
{
|
||||
char formatted[24];
|
||||
float days = (float) mSecs / 86400.0;
|
||||
|
||||
if (mSecs >= 86400 * 365)
|
||||
sprintf (formatted, "%s%.1f yrs", (mNegative ? "-" : ""), (days / 365));
|
||||
else if (mSecs > 86400 * 84)
|
||||
sprintf (formatted, "%s%1d mth%s",
|
||||
(mNegative ? "-" : ""), (int) (float) (days / 30.6),
|
||||
((int) (float) (days / 30.6) == 1 ? "" : "s"));
|
||||
else if (mSecs > 86400 * 13)
|
||||
sprintf (formatted, "%s%d wk%s",
|
||||
(mNegative ? "-" : ""), (int) (float) (days / 7.0),
|
||||
((int) (float) (days / 7.0) == 1 ? "" : "s"));
|
||||
else if (mSecs >= 86400)
|
||||
sprintf (formatted, "%s%d day%s",
|
||||
(mNegative ? "-" : ""), (int) days,
|
||||
((int) days == 1 ? "" : "s"));
|
||||
else if (mSecs >= 3600)
|
||||
sprintf (formatted, "%s%d hr%s",
|
||||
(mNegative ? "-" : ""), (int) (float) (mSecs / 3600),
|
||||
((int) (float) (mSecs / 3600) == 1 ? "" : "s"));
|
||||
else if (mSecs >= 60)
|
||||
sprintf (formatted, "%s%d min%s",
|
||||
(mNegative ? "-" : ""), (int) (float) (mSecs / 60),
|
||||
((int) (float) (mSecs / 60) == 1 ? "" : "s"));
|
||||
else if (mSecs >= 1)
|
||||
sprintf (formatted, "%s%d sec%s",
|
||||
(mNegative ? "-" : ""), (int) mSecs,
|
||||
((int) mSecs == 1 ? "" : "s"));
|
||||
else
|
||||
strcpy (formatted, "-"); // no i18n
|
||||
|
||||
return std::string (formatted);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Duration::formatCompact () const
|
||||
{
|
||||
char formatted[24];
|
||||
float days = (float) mSecs / 86400.0;
|
||||
|
||||
if (mSecs >= 86400 * 365) sprintf (formatted, "%s%.1fy", (mNegative ? "-" : ""), (days / 365));
|
||||
else if (mSecs >= 86400 * 84) sprintf (formatted, "%s%1dmo", (mNegative ? "-" : ""), (int) (float) (days / 30.6));
|
||||
else if (mSecs >= 86400 * 13) sprintf (formatted, "%s%dwk", (mNegative ? "-" : ""), (int) (float) (days / 7.0));
|
||||
else if (mSecs >= 86400) sprintf (formatted, "%s%dd", (mNegative ? "-" : ""), (int) days);
|
||||
else if (mSecs >= 3600) sprintf (formatted, "%s%dh", (mNegative ? "-" : ""), (int) (float) (mSecs / 3600));
|
||||
else if (mSecs >= 60) sprintf (formatted, "%s%dm", (mNegative ? "-" : ""), (int) (float) (mSecs / 60));
|
||||
else if (mSecs >= 1) sprintf (formatted, "%s%ds", (mNegative ? "-" : ""), (int) mSecs);
|
||||
else strcpy (formatted, "-");
|
||||
|
||||
return std::string (formatted);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Duration::operator< (const Duration& other)
|
||||
{
|
||||
long left = (long) ( mNegative ? -mSecs : mSecs);
|
||||
long right = (long) (other.mNegative ? -other.mSecs : other.mSecs);
|
||||
|
||||
return left < right;
|
||||
return mDays < other.mDays;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Duration::operator> (const Duration& other)
|
||||
{
|
||||
long left = (long) ( mNegative ? -mSecs : mSecs);
|
||||
long right = (long) (other.mNegative ? -other.mSecs : other.mSecs);
|
||||
|
||||
return left > right;
|
||||
return mDays > other.mDays;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -194,52 +114,22 @@ bool Duration::valid (const std::string& input) const
|
||||
if (autoComplete (lower_input, supported, matches) == 1)
|
||||
return true;
|
||||
|
||||
// Support \s+ -? \d+ \s? s|secs?|m|mins?|h|hrs?|d|days?|wks?|mo|mths?|y|yrs?|-
|
||||
// Note: Does not support a sign character. That must be external to
|
||||
// Duration.
|
||||
Nibbler n (lower_input);
|
||||
int value;
|
||||
|
||||
n.skipAll (' ');
|
||||
n.skip ('-');
|
||||
|
||||
if (n.getUnsignedInt (value))
|
||||
// Support \d+ d|w|m|q|y
|
||||
// Verify all digits followed by d, w, m, q, or y.
|
||||
unsigned int length = lower_input.length ();
|
||||
for (unsigned int i = 0; i < length; ++i)
|
||||
{
|
||||
n.skipAll (' ');
|
||||
|
||||
if (n.getLiteral ("yrs") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("yr") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("y") && n.depleted ()) return true;
|
||||
|
||||
else if (n.getLiteral ("qtrs") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("qtr") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("q") && n.depleted ()) return true;
|
||||
|
||||
else if (n.getLiteral ("mths") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("mth") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("mo") && n.depleted ()) return true;
|
||||
|
||||
else if (n.getLiteral ("wks") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("wk") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("w") && n.depleted ()) return true;
|
||||
|
||||
else if (n.getLiteral ("days") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("day") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("d") && n.depleted ()) return true;
|
||||
|
||||
else if (n.getLiteral ("hrs") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("hr") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("h") && n.depleted ()) return true;
|
||||
|
||||
else if (n.getLiteral ("mins") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("min") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("m") && n.depleted ()) return true;
|
||||
|
||||
else if (n.getLiteral ("secs") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("sec") && n.depleted ()) return true;
|
||||
else if (n.getLiteral ("s") && n.depleted ()) return true;
|
||||
|
||||
else if (n.getLiteral ("-") && n.depleted ()) return true;
|
||||
if (! isdigit (lower_input[i]) &&
|
||||
i == length - 1)
|
||||
{
|
||||
std::string type = lower_input.substr (length - 1, std::string::npos);
|
||||
if (type == "d" || // TODO i18n
|
||||
type == "w" || // TODO i18n
|
||||
type == "m" || // TODO i18n
|
||||
type == "q" || // TODO i18n
|
||||
type == "y") // TODO i18n
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -272,72 +162,43 @@ void Duration::parse (const std::string& input)
|
||||
{
|
||||
std::string found = matches[0];
|
||||
|
||||
if (found == "daily" || found == "day") mSecs = 86400 * 1; // TODO i18n
|
||||
else if (found == "weekdays") mSecs = 86400 * 1; // TODO i18n
|
||||
else if (found == "weekly" || found == "sennight") mSecs = 86400 * 7; // TODO i18n
|
||||
else if (found == "biweekly" || found == "fortnight") mSecs = 86400 * 14; // TODO i18n
|
||||
else if (found == "monthly") mSecs = 86400 * 30; // TODO i18n
|
||||
else if (found == "bimonthly") mSecs = 86400 * 61; // TODO i18n
|
||||
else if (found == "quarterly") mSecs = 86400 * 91; // TODO i18n
|
||||
else if (found == "semiannual") mSecs = 86400 * 183; // TODO i18n
|
||||
else if (found == "yearly" || found == "annual") mSecs = 86400 * 365; // TODO i18n
|
||||
else if (found == "biannual" || found == "biyearly") mSecs = 86400 * 730; // TODO i18n
|
||||
if (found == "daily" || found == "day") mDays = 1; // TODO i18n
|
||||
else if (found == "weekdays") mDays = 1; // TODO i18n
|
||||
else if (found == "weekly" || found == "sennight") mDays = 7; // TODO i18n
|
||||
else if (found == "biweekly" || found == "fortnight") mDays = 14; // TODO i18n
|
||||
else if (found == "monthly") mDays = 30; // TODO i18n
|
||||
else if (found == "bimonthly") mDays = 61; // TODO i18n
|
||||
else if (found == "quarterly") mDays = 91; // TODO i18n
|
||||
else if (found == "semiannual") mDays = 183; // TODO i18n
|
||||
else if (found == "yearly" || found == "annual") mDays = 365; // TODO i18n
|
||||
else if (found == "biannual" || found == "biyearly") mDays = 730; // TODO i18n
|
||||
}
|
||||
|
||||
// Support -? \d+ \s? s|secs?|m|mins?|h|hrs?|d|days?|wks?|mo|mths?|y|yrs?|-
|
||||
// Note: Does not support a sign character. That must be external to
|
||||
// Duration.
|
||||
// Support \d+ d|w|m|q|y
|
||||
else
|
||||
{
|
||||
Nibbler n (lower_input);
|
||||
|
||||
n.skipAll (' ');
|
||||
mNegative = false;
|
||||
if (n.skip ('-'))
|
||||
mNegative = true;
|
||||
|
||||
int value;
|
||||
if (n.getUnsignedInt (value))
|
||||
// Verify all digits followed by d, w, m, q, or y.
|
||||
unsigned int length = lower_input.length ();
|
||||
for (unsigned int i = 0; i < length; ++i)
|
||||
{
|
||||
n.skipAll (' ');
|
||||
if (! isdigit (lower_input[i]) &&
|
||||
i == length - 1)
|
||||
{
|
||||
int number = ::atoi (lower_input.substr (0, i).c_str ());
|
||||
|
||||
if (n.getLiteral ("yrs") && n.depleted ()) mSecs = value * 86400 * 365;
|
||||
else if (n.getLiteral ("yr") && n.depleted ()) mSecs = value * 86400 * 365;
|
||||
else if (n.getLiteral ("y") && n.depleted ()) mSecs = value * 86400 * 365;
|
||||
|
||||
else if (n.getLiteral ("qtrs") && n.depleted ()) mSecs = value * 86400 * 91;
|
||||
else if (n.getLiteral ("qtr") && n.depleted ()) mSecs = value * 86400 * 91;
|
||||
else if (n.getLiteral ("q") && n.depleted ()) mSecs = value * 86400 * 91;
|
||||
|
||||
else if (n.getLiteral ("mths") && n.depleted ()) mSecs = value * 86400 * 30;
|
||||
else if (n.getLiteral ("mth") && n.depleted ()) mSecs = value * 86400 * 30;
|
||||
else if (n.getLiteral ("mo") && n.depleted ()) mSecs = value * 86400 * 30;
|
||||
|
||||
else if (n.getLiteral ("wks") && n.depleted ()) mSecs = value * 86400 * 7;
|
||||
else if (n.getLiteral ("wk") && n.depleted ()) mSecs = value * 86400 * 7;
|
||||
else if (n.getLiteral ("w") && n.depleted ()) mSecs = value * 86400 * 7;
|
||||
|
||||
else if (n.getLiteral ("days") && n.depleted ()) mSecs = value * 86400;
|
||||
else if (n.getLiteral ("day") && n.depleted ()) mSecs = value * 86400;
|
||||
else if (n.getLiteral ("d") && n.depleted ()) mSecs = value * 86400;
|
||||
|
||||
else if (n.getLiteral ("hrs") && n.depleted ()) mSecs = value * 3600;
|
||||
else if (n.getLiteral ("hr") && n.depleted ()) mSecs = value * 3600;
|
||||
else if (n.getLiteral ("h") && n.depleted ()) mSecs = value * 3600;
|
||||
|
||||
else if (n.getLiteral ("mins") && n.depleted ()) mSecs = value * 60;
|
||||
else if (n.getLiteral ("min") && n.depleted ()) mSecs = value * 60;
|
||||
else if (n.getLiteral ("m") && n.depleted ()) mSecs = value * 60;
|
||||
|
||||
else if (n.getLiteral ("secs") && n.depleted ()) mSecs = value;
|
||||
else if (n.getLiteral ("sec") && n.depleted ()) mSecs = value;
|
||||
else if (n.getLiteral ("s") && n.depleted ()) mSecs = value;
|
||||
|
||||
else if (n.getLiteral ("-") && n.depleted ()) mSecs = 0;
|
||||
switch (lower_input[length - 1])
|
||||
{
|
||||
case 'd': mDays = number * 1; break; // TODO i18n
|
||||
case 'w': mDays = number * 7; break; // TODO i18n
|
||||
case 'm': mDays = number * 30; break; // TODO i18n
|
||||
case 'q': mDays = number * 91; break; // TODO i18n
|
||||
case 'y': mDays = number * 365; break; // TODO i18n
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mSecs == 0)
|
||||
if (mDays == 0)
|
||||
throw std::string ("The duration '") + input + "' was not recognized."; // TODO i18n
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -38,21 +38,17 @@ public:
|
||||
Duration (const std::string&); // Parse
|
||||
bool operator< (const Duration&);
|
||||
bool operator> (const Duration&);
|
||||
Duration& operator= (const Duration&);
|
||||
~Duration (); // Destructor
|
||||
|
||||
operator int ();
|
||||
operator time_t ();
|
||||
operator std::string ();
|
||||
|
||||
std::string format () const;
|
||||
std::string formatCompact () const;
|
||||
|
||||
bool valid (const std::string&) const;
|
||||
void parse (const std::string&);
|
||||
|
||||
private:
|
||||
time_t mSecs;
|
||||
bool mNegative;
|
||||
time_t mDays;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
286
src/File.cpp
286
src/File.cpp
@@ -1,286 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation; either version 2 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program; if not, write to the
|
||||
//
|
||||
// Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor,
|
||||
// Boston, MA
|
||||
// 02110-1301
|
||||
// USA
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <fstream>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
#include "File.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
File::File ()
|
||||
: Path::Path ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
File::File (const Path& other)
|
||||
: Path::Path (other)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
File::File (const File& other)
|
||||
: Path::Path (other)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
File::File (const std::string& in)
|
||||
: Path::Path (in)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
File::~File ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
File& File::operator= (const File& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
Path::operator= (other);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool File::create ()
|
||||
{
|
||||
std::ofstream out (data.c_str ());
|
||||
if (out.good ())
|
||||
{
|
||||
out.close ();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool File::remove ()
|
||||
{
|
||||
return unlink (data.c_str ()) == 0 ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// S_IFMT 0170000 type of file
|
||||
// S_IFIFO 0010000 named pipe (fifo)
|
||||
// S_IFCHR 0020000 character special
|
||||
// S_IFDIR 0040000 directory
|
||||
// S_IFBLK 0060000 block special
|
||||
// S_IFREG 0100000 regular
|
||||
// S_IFLNK 0120000 symbolic link
|
||||
// S_IFSOCK 0140000 socket
|
||||
// S_IFWHT 0160000 whiteout
|
||||
// S_ISUID 0004000 set user id on execution
|
||||
// S_ISGID 0002000 set group id on execution
|
||||
// S_ISVTX 0001000 save swapped text even after use
|
||||
// S_IRUSR 0000400 read permission, owner
|
||||
// S_IWUSR 0000200 write permission, owner
|
||||
// S_IXUSR 0000100 execute/search permission, owner
|
||||
mode_t File::mode ()
|
||||
{
|
||||
struct stat s;
|
||||
if (!stat (data.c_str (), &s))
|
||||
return s.st_mode;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
size_t File::size () const
|
||||
{
|
||||
struct stat s;
|
||||
if (!stat (data.c_str (), &s))
|
||||
return s.st_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool File::create (const std::string& name)
|
||||
{
|
||||
std::ofstream out (expand (name).c_str ());
|
||||
if (out.good ())
|
||||
{
|
||||
out.close ();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string File::read (const std::string& name)
|
||||
{
|
||||
std::string contents = "";
|
||||
|
||||
std::ifstream in (name.c_str ());
|
||||
if (in.good ())
|
||||
{
|
||||
std::string line;
|
||||
while (getline (in, line))
|
||||
contents += line + "\n";
|
||||
|
||||
in.close ();
|
||||
}
|
||||
|
||||
return contents;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool File::read (const std::string& name, std::string& contents)
|
||||
{
|
||||
contents = "";
|
||||
|
||||
std::ifstream in (name.c_str ());
|
||||
if (in.good ())
|
||||
{
|
||||
std::string line;
|
||||
while (getline (in, line))
|
||||
contents += line + "\n";
|
||||
|
||||
in.close ();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool File::read (const std::string& name, std::vector <std::string>& contents)
|
||||
{
|
||||
contents.clear ();
|
||||
|
||||
std::ifstream in (name.c_str ());
|
||||
if (in.good ())
|
||||
{
|
||||
std::string line;
|
||||
while (getline (in, line))
|
||||
contents.push_back (line);
|
||||
|
||||
in.close ();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool File::write (const std::string& name, const std::string& contents)
|
||||
{
|
||||
std::ofstream out (expand (name).c_str (),
|
||||
std::ios_base::out | std::ios_base::trunc);
|
||||
if (out.good ())
|
||||
{
|
||||
out << contents;
|
||||
out.close ();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool File::write (
|
||||
const std::string& name,
|
||||
const std::vector <std::string>& lines,
|
||||
bool addNewlines /* = true */)
|
||||
{
|
||||
std::ofstream out (expand (name).c_str (),
|
||||
std::ios_base::out | std::ios_base::trunc);
|
||||
if (out.good ())
|
||||
{
|
||||
std::vector <std::string>::const_iterator it;
|
||||
for (it = lines.begin (); it != lines.end (); ++it)
|
||||
{
|
||||
out << *it;
|
||||
|
||||
if (addNewlines)
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
out.close ();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool File::append (const std::string& name, const std::string& contents)
|
||||
{
|
||||
std::ofstream out (expand (name).c_str (),
|
||||
std::ios_base::out | std::ios_base::app);
|
||||
if (out.good ())
|
||||
{
|
||||
out << contents;
|
||||
out.close ();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool File::append (
|
||||
const std::string& name,
|
||||
const std::vector <std::string>& lines,
|
||||
bool addNewlines /* = true */)
|
||||
{
|
||||
std::ofstream out (expand (name).c_str (),
|
||||
std::ios_base::out | std::ios_base::app);
|
||||
if (out.good ())
|
||||
{
|
||||
std::vector <std::string>::const_iterator it;
|
||||
for (it = lines.begin (); it != lines.end (); ++it)
|
||||
{
|
||||
out << *it;
|
||||
|
||||
if (addNewlines)
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
out.close ();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool File::remove (const std::string& name)
|
||||
{
|
||||
return unlink (expand (name).c_str ()) == 0 ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
81
src/File.h
81
src/File.h
@@ -1,81 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation; either version 2 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program; if not, write to the
|
||||
//
|
||||
// Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor,
|
||||
// Boston, MA
|
||||
// 02110-1301
|
||||
// USA
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef INCLUDED_FILE
|
||||
#define INCLUDED_FILE
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sys/stat.h>
|
||||
#include "Path.h"
|
||||
|
||||
class File : public Path
|
||||
{
|
||||
public:
|
||||
File ();
|
||||
File (const Path&);
|
||||
File (const File&);
|
||||
File (const std::string&);
|
||||
virtual ~File ();
|
||||
|
||||
File& operator= (const File&);
|
||||
|
||||
virtual bool create ();
|
||||
virtual bool remove ();
|
||||
|
||||
// bool open ();
|
||||
// bool openAndLock ();
|
||||
// void close ();
|
||||
|
||||
// bool lock ();
|
||||
// bool lockNoWait ();
|
||||
// void unlock ();
|
||||
|
||||
// void read (std::string&);
|
||||
// void read (std::vector <std::string>&);
|
||||
|
||||
// void write (const std::string&);
|
||||
// void write (const std::vector <std::string>&);
|
||||
|
||||
virtual mode_t mode ();
|
||||
virtual size_t size () const;
|
||||
|
||||
static bool create (const std::string&);
|
||||
static std::string read (const std::string&);
|
||||
static bool read (const std::string&, std::string&);
|
||||
static bool read (const std::string&, std::vector <std::string>&);
|
||||
static bool write (const std::string&, const std::string&);
|
||||
static bool write (const std::string&, const std::vector <std::string>&, bool addNewlines = true);
|
||||
static bool append (const std::string&, const std::string&);
|
||||
static bool append (const std::string&, const std::vector <std::string>&, bool addNewlines = true);
|
||||
static bool remove (const std::string&);
|
||||
|
||||
private:
|
||||
// int handle;
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -40,58 +40,37 @@ bool Filter::pass (const Record& record) const
|
||||
// First do description/annotation matches.
|
||||
foreach (att, (*this))
|
||||
{
|
||||
// Descriptions have special handling such that they are linked to
|
||||
// annotations, and filtering on description implies identical filtering
|
||||
// on annotations.
|
||||
//
|
||||
// For positive modifiers (has, is ...) either the description or the
|
||||
// annotation filter must succeed.
|
||||
//
|
||||
// For negative modifiers (hasnt, isnt ...) both the description and the
|
||||
// annotation filter must succeed.
|
||||
// Descriptions have special handling.
|
||||
if (att->name () == "description")
|
||||
{
|
||||
bool pass = true;
|
||||
int annotation_pass_count = 0;
|
||||
int annotation_fail_count = 0;
|
||||
|
||||
if ((r = record.find (att->name ())) != record.end ())
|
||||
{
|
||||
pass = att->match (r->second);
|
||||
|
||||
foreach (ra, record)
|
||||
// A description match failure can be salvaged by an annotation match.
|
||||
if (! att->match (r->second))
|
||||
{
|
||||
if (ra->first.length () > 11 &&
|
||||
ra->first.substr (0, 11) == "annotation_")
|
||||
bool annoMatch = false;
|
||||
foreach (ra, record)
|
||||
{
|
||||
if (att->match (ra->second))
|
||||
++annotation_pass_count;
|
||||
else
|
||||
++annotation_fail_count;
|
||||
if (ra->first.length () > 11 &&
|
||||
ra->first.substr (0, 11) == "annotation_")
|
||||
{
|
||||
if (att->match (ra->second))
|
||||
{
|
||||
annoMatch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!annoMatch)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Missing attribute implies failure.
|
||||
else if (! att->match (Att ()))
|
||||
return false;
|
||||
|
||||
// This innocuous little if-else took significantly more thinking and
|
||||
// debugging than anything else in task. Only change this code if you
|
||||
// are willing to invest a week understanding and testing it.
|
||||
if (att->modType (att->mod ()) == "positive")
|
||||
{
|
||||
if (! (pass || annotation_pass_count))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! (pass && annotation_fail_count == 0))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Annotations are skipped, because they are handled above.
|
||||
// Annotations are skipped.
|
||||
else if (att->name ().length () > 11 &&
|
||||
att->name ().substr (0, 11) == "annotation_")
|
||||
{
|
||||
@@ -132,7 +111,7 @@ void Filter::applySequence (std::vector<Task>& all, Sequence& sequence)
|
||||
std::vector <int> right;
|
||||
listDiff (filteredSequence, (std::vector <int>&)sequence, left, right);
|
||||
if (left.size ())
|
||||
throw std::string ("Sequence filtering error - please report this error to support@taskwarrior.org");
|
||||
throw std::string ("Sequence filtering error - please report this error");
|
||||
|
||||
if (right.size ())
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -326,7 +326,7 @@ Grid::Cell::operator int () const
|
||||
case CELL_INT: return mInt;
|
||||
case CELL_FLOAT: return (int) mFloat;
|
||||
case CELL_DOUBLE: return (int) mDouble;
|
||||
case CELL_STRING: return atoi (mString.c_str ());
|
||||
case CELL_STRING: return ::atoi (mString.c_str ());
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -341,7 +341,7 @@ Grid::Cell::operator float () const
|
||||
case CELL_INT: return (float) mInt;
|
||||
case CELL_FLOAT: return mFloat;
|
||||
case CELL_DOUBLE: return (float) mDouble;
|
||||
case CELL_STRING: return (float) atof (mString.c_str ());
|
||||
case CELL_STRING: return (float) ::atof (mString.c_str ());
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
@@ -356,7 +356,7 @@ Grid::Cell::operator double () const
|
||||
case CELL_INT: return (double) mInt;
|
||||
case CELL_FLOAT: return (double) mFloat;
|
||||
case CELL_DOUBLE: return mDouble;
|
||||
case CELL_STRING: return (double) atof (mString.c_str ());
|
||||
case CELL_STRING: return (double) ::atof (mString.c_str ());
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
|
||||
383
src/Hooks.cpp
383
src/Hooks.cpp
@@ -1,383 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <iostream>
|
||||
#include "Context.h"
|
||||
#include "Hooks.h"
|
||||
#include "Timer.h"
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Hook::Hook ()
|
||||
: event ("")
|
||||
, file ("")
|
||||
, function ("")
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Hook::Hook (const std::string& e, const std::string& f, const std::string& fn)
|
||||
: event (e)
|
||||
, file (f)
|
||||
, function (fn)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Hook::Hook (const Hook& other)
|
||||
{
|
||||
event = other.event;
|
||||
file = other.file;
|
||||
function = other.function;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Hook& Hook::operator= (const Hook& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
event = other.event;
|
||||
file = other.file;
|
||||
function = other.function;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Hooks::Hooks ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Hooks::~Hooks ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Enumerate all hooks, and tell API about the script files it must load in
|
||||
// order to call them. Note that API will perform a deferred read, which means
|
||||
// that if it isn't called, a script will not be loaded.
|
||||
void Hooks::initialize ()
|
||||
{
|
||||
#ifdef HAVE_LIBLUA
|
||||
api.initialize ();
|
||||
#endif
|
||||
|
||||
// Allow a master switch to turn the whole thing off.
|
||||
bool big_red_switch = context.config.getBoolean ("hooks");
|
||||
if (big_red_switch)
|
||||
{
|
||||
std::vector <std::string> vars;
|
||||
context.config.all (vars);
|
||||
|
||||
std::vector <std::string>::iterator it;
|
||||
for (it = vars.begin (); it != vars.end (); ++it)
|
||||
{
|
||||
std::string type;
|
||||
std::string name;
|
||||
std::string value;
|
||||
|
||||
// "<type>.<name>"
|
||||
Nibbler n (*it);
|
||||
if (n.getUntil ('.', type) &&
|
||||
type == "hook" &&
|
||||
n.skip ('.') &&
|
||||
n.getUntilEOS (name))
|
||||
{
|
||||
std::string value = context.config.get (*it);
|
||||
Nibbler n (value);
|
||||
|
||||
// <path>:<function> [, ...]
|
||||
while (!n.depleted ())
|
||||
{
|
||||
std::string file;
|
||||
std::string function;
|
||||
if (n.getUntil (':', file) &&
|
||||
n.skip (':') &&
|
||||
n.getUntil (',', function))
|
||||
{
|
||||
context.debug (std::string ("Event '") + name + "' hooked by " + file + ", function " + function);
|
||||
Hook h (name, Path::expand (file), function);
|
||||
all.push_back (h);
|
||||
|
||||
(void) n.skip (',');
|
||||
}
|
||||
else
|
||||
throw std::string ("Malformed hook definition '") + *it + "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
context.debug ("Hooks::initialize - hook system shut off");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Program hooks.
|
||||
bool Hooks::trigger (const std::string& event)
|
||||
{
|
||||
#ifdef HAVE_LIBLUA
|
||||
std::vector <Hook>::iterator it;
|
||||
for (it = all.begin (); it != all.end (); ++it)
|
||||
{
|
||||
if (it->event == event)
|
||||
{
|
||||
Timer timer (std::string ("Hooks::trigger ") + event);
|
||||
|
||||
if (validProgramEvent (event))
|
||||
{
|
||||
context.debug (std::string ("Event ") + event + " triggered");
|
||||
if (! api.callProgramHook (it->file, it->function))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
throw std::string ("Unrecognized hook event '") + event + "'";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// List hooks.
|
||||
bool Hooks::trigger (const std::string& event, std::vector <Task>& tasks)
|
||||
{
|
||||
#ifdef HAVE_LIBLUA
|
||||
std::vector <Hook>::iterator it;
|
||||
for (it = all.begin (); it != all.end (); ++it)
|
||||
{
|
||||
if (it->event == event)
|
||||
{
|
||||
Timer timer (std::string ("Hooks::trigger ") + event);
|
||||
|
||||
if (validListEvent (event))
|
||||
{
|
||||
context.debug (std::string ("Event ") + event + " triggered");
|
||||
if (! api.callListHook (it->file, it->function, tasks))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
throw std::string ("Unrecognized hook event '") + event + "'";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Task hooks.
|
||||
bool Hooks::trigger (const std::string& event, Task& task)
|
||||
{
|
||||
#ifdef HAVE_LIBLUA
|
||||
std::vector <Hook>::iterator it;
|
||||
for (it = all.begin (); it != all.end (); ++it)
|
||||
{
|
||||
if (it->event == event)
|
||||
{
|
||||
Timer timer (std::string ("Hooks::trigger ") + event);
|
||||
|
||||
if (validTaskEvent (event))
|
||||
{
|
||||
context.debug (std::string ("Event ") + event + " triggered");
|
||||
if (! api.callTaskHook (it->file, it->function, task))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
throw std::string ("Unrecognized hook event '") + event + "'";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Field hooks.
|
||||
bool Hooks::trigger (
|
||||
const std::string& event,
|
||||
const std::string& name,
|
||||
std::string& value)
|
||||
{
|
||||
#ifdef HAVE_LIBLUA
|
||||
std::vector <Hook>::iterator it;
|
||||
for (it = all.begin (); it != all.end (); ++it)
|
||||
{
|
||||
if (it->event == event)
|
||||
{
|
||||
Timer timer (std::string ("Hooks::trigger ") + event);
|
||||
|
||||
if (validFieldEvent (event))
|
||||
{
|
||||
context.debug (std::string ("Event ") + event + " triggered");
|
||||
if (! api.callFieldHook (it->file, it->function, name, value))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
throw std::string ("Unrecognized hook event '") + event + "'";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Hooks::validProgramEvent (const std::string& event)
|
||||
{
|
||||
if (event == "post-start" ||
|
||||
event == "pre-fatal-error" ||
|
||||
event == "pre-exit" ||
|
||||
event == "pre-command-line" || event == "post-command-line" ||
|
||||
event == "pre-command-line-override" || event == "post-command-line-override" ||
|
||||
event == "pre-config-create" || event == "post-config-create" ||
|
||||
event == "pre-config-read" || event == "post-config-read" ||
|
||||
event == "pre-config-value-read" || event == "post-config-value-read" ||
|
||||
event == "pre-config-value-write" || event == "post-config-value-write" ||
|
||||
event == "pre-file-lock" || event == "post-file-lock" ||
|
||||
event == "pre-file-unlock" || event == "post-file-unlock" ||
|
||||
event == "pre-file-read" || event == "post-file-read" ||
|
||||
event == "pre-file-write" || event == "post-file-write" ||
|
||||
event == "pre-output" || event == "post-output" ||
|
||||
event == "pre-debug" || event == "post-debug" ||
|
||||
event == "pre-header" || event == "post-header" ||
|
||||
event == "pre-footnote" || event == "post-footnote" ||
|
||||
event == "pre-dispatch" || event == "post-dispatch" ||
|
||||
event == "pre-gc" || event == "post-gc" ||
|
||||
event == "pre-archive" || event == "post-archive" ||
|
||||
event == "pre-purge" || event == "post-purge" ||
|
||||
event == "pre-recurrence" || event == "post-recurrence" ||
|
||||
event == "pre-interactive" || event == "post-interactive" ||
|
||||
event == "pre-undo" || event == "post-undo" ||
|
||||
event == "pre-confirm" || event == "post-confirm" ||
|
||||
event == "pre-shell-prompt" || event == "post-shell-prompt" ||
|
||||
event == "pre-add-command" || event == "post-add-command" ||
|
||||
event == "pre-annotate-command" || event == "post-annotate-command" ||
|
||||
event == "pre-denotate-command" || event == "post-denotate-command" ||
|
||||
event == "pre-append-command" || event == "post-append-command" ||
|
||||
event == "pre-calendar-command" || event == "post-calendar-command" ||
|
||||
event == "pre-color-command" || event == "post-color-command" ||
|
||||
event == "pre-config-command" || event == "post-config-command" ||
|
||||
event == "pre-custom-report-command" || event == "post-custom-report-command" ||
|
||||
event == "pre-default-command" || event == "post-default-command" ||
|
||||
event == "pre-delete-command" || event == "post-delete-command" ||
|
||||
event == "pre-done-command" || event == "post-done-command" ||
|
||||
event == "pre-duplicate-command" || event == "post-duplicate-command" ||
|
||||
event == "pre-edit-command" || event == "post-edit-command" ||
|
||||
event == "pre-export-command" || event == "post-export-command" ||
|
||||
event == "pre-ghistory-command" || event == "post-ghistory-command" ||
|
||||
event == "pre-history-command" || event == "post-history-command" ||
|
||||
event == "pre-import-command" || event == "post-import-command" ||
|
||||
event == "pre-info-command" || event == "post-info-command" ||
|
||||
event == "pre-prepend-command" || event == "post-prepend-command" ||
|
||||
event == "pre-projects-command" || event == "post-projects-command" ||
|
||||
event == "pre-shell-command" || event == "post-shell-command" ||
|
||||
event == "pre-start-command" || event == "post-start-command" ||
|
||||
event == "pre-stats-command" || event == "post-stats-command" ||
|
||||
event == "pre-stop-command" || event == "post-stop-command" ||
|
||||
event == "pre-summary-command" || event == "post-summary-command" ||
|
||||
event == "pre-tags-command" || event == "post-tags-command" ||
|
||||
event == "pre-timesheet-command" || event == "post-timesheet-command" ||
|
||||
event == "pre-undo-command" || event == "post-undo-command" ||
|
||||
event == "pre-usage-command" || event == "post-usage-command" ||
|
||||
event == "pre-version-command" || event == "post-version-command")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Hooks::validListEvent (const std::string& event)
|
||||
{
|
||||
if (event == "pre-filter" || event == "post-filter")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Hooks::validTaskEvent (const std::string& event)
|
||||
{
|
||||
if (event == "pre-display" ||
|
||||
event == "pre-modification" || event == "post-modification" ||
|
||||
event == "pre-delete" || event == "post-delete" ||
|
||||
event == "pre-add" || event == "post-add" ||
|
||||
event == "pre-undo" || event == "post-undo" ||
|
||||
event == "pre-wait" || event == "post-wait" ||
|
||||
event == "pre-unwait" || event == "post-unwait" ||
|
||||
event == "pre-completed" || event == "post-completed" ||
|
||||
event == "pre-priority-change" || event == "post-priority-change" ||
|
||||
event == "pre-project-change" || event == "post-project-change" ||
|
||||
event == "pre-substitution" || event == "post-substitution" ||
|
||||
event == "pre-annotation" || event == "post-annotation" ||
|
||||
event == "pre-tag" || event == "post-tag" ||
|
||||
event == "pre-detag" || event == "post-detag" ||
|
||||
event == "pre-colorization" || event == "post-colorization")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Hooks::validFieldEvent (const std::string& event)
|
||||
{
|
||||
if (
|
||||
event == "format-number" ||
|
||||
event == "format-date" ||
|
||||
event == "format-duration" ||
|
||||
event == "format-text" ||
|
||||
event == "format-id" ||
|
||||
event == "format-uuid" ||
|
||||
event == "format-project" ||
|
||||
event == "format-priority" ||
|
||||
event == "format-priority_long" ||
|
||||
event == "format-entry" ||
|
||||
event == "format-entry_time" ||
|
||||
event == "format-start" ||
|
||||
event == "format-start_time" ||
|
||||
event == "format-end" ||
|
||||
event == "format-end_time" ||
|
||||
event == "format-due" ||
|
||||
event == "format-countdown" ||
|
||||
event == "format-countdown_compact" ||
|
||||
event == "format-age" ||
|
||||
event == "format-age_compact" ||
|
||||
event == "format-active" ||
|
||||
event == "format-tags" ||
|
||||
event == "format-recur" ||
|
||||
event == "format-recurrence_indicator" ||
|
||||
event == "format-tag_indicator" ||
|
||||
event == "format-description_only" ||
|
||||
event == "format-description" ||
|
||||
event == "format-wait" ||
|
||||
event == "format-prompt")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
80
src/Hooks.h
80
src/Hooks.h
@@ -1,80 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef INCLUDED_HOOKS
|
||||
#define INCLUDED_HOOKS
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "API.h"
|
||||
#include "auto.h"
|
||||
|
||||
// Hook class representing a single hook, which is just a three-way map.
|
||||
class Hook
|
||||
{
|
||||
public:
|
||||
Hook ();
|
||||
Hook (const std::string&, const std::string&, const std::string&);
|
||||
Hook (const Hook&);
|
||||
Hook& operator= (const Hook&);
|
||||
|
||||
public:
|
||||
std::string event;
|
||||
std::string file;
|
||||
std::string function;
|
||||
};
|
||||
|
||||
// Hooks class for managing the loading and calling of hook functions.
|
||||
class Hooks
|
||||
{
|
||||
public:
|
||||
Hooks (); // Default constructor
|
||||
~Hooks (); // Destructor
|
||||
Hooks (const Hooks&); // Deliberately unimplemented
|
||||
Hooks& operator= (const Hooks&); // Deliberately unimplemented
|
||||
|
||||
void initialize ();
|
||||
|
||||
bool trigger (const std::string&); // Program
|
||||
bool trigger (const std::string&, std::vector <Task>&); // List
|
||||
bool trigger (const std::string&, Task&); // Task
|
||||
bool trigger (const std::string&, const std::string&, std::string&); // Field
|
||||
|
||||
private:
|
||||
bool validProgramEvent (const std::string&);
|
||||
bool validListEvent (const std::string&);
|
||||
bool validTaskEvent (const std::string&);
|
||||
bool validFieldEvent (const std::string&);
|
||||
|
||||
private:
|
||||
#ifdef HAVE_LIBLUA
|
||||
API api;
|
||||
#endif
|
||||
std::vector <Hook> all; // All current hooks.
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
bin_PROGRAMS = task
|
||||
task_SHORTNAME = t
|
||||
task_SOURCES = API.cpp Att.cpp Cmd.cpp Color.cpp Config.cpp Context.cpp \
|
||||
Date.cpp Directory.cpp Duration.cpp File.cpp Filter.cpp \
|
||||
Grid.cpp Hooks.cpp Keymap.cpp Location.cpp Nibbler.cpp \
|
||||
Path.cpp Permission.cpp Record.cpp Sequence.cpp \
|
||||
StringTable.cpp Subst.cpp TDB.cpp Table.cpp Task.cpp \
|
||||
Taskmod.cpp Timer.cpp command.cpp custom.cpp edit.cpp \
|
||||
export.cpp import.cpp interactive.cpp main.cpp recur.cpp \
|
||||
report.cpp rules.cpp rx.cpp text.cpp util.cpp API.h Att.h \
|
||||
Cmd.h Color.h Config.h Context.h Date.h Directory.h Duration.h \
|
||||
File.h Filter.h Grid.h Hooks.h Keymap.h Location.h Nibbler.h \
|
||||
Path.h Permission.h Record.h Sequence.h StringTable.h Subst.h \
|
||||
TDB.h Table.h Task.h Taskmod.h Timer.h i18n.h main.h text.h \
|
||||
util.h rx.h
|
||||
task_CPPFLAGS=$(LUA_CFLAGS)
|
||||
task_LDFLAGS=$(LUA_LFLAGS)
|
||||
task_SOURCES = Att.cpp Cmd.cpp Config.cpp Context.cpp Date.cpp Duration.cpp \
|
||||
Filter.cpp Grid.cpp Keymap.cpp Location.cpp Nibbler.cpp \
|
||||
Record.cpp Sequence.cpp StringTable.cpp Subst.cpp Task.cpp \
|
||||
TDB.cpp Table.cpp Timer.cpp Permission.cpp color.cpp edit.cpp \
|
||||
command.cpp import.cpp interactive.cpp recur.cpp report.cpp \
|
||||
custom.cpp rules.cpp main.cpp text.cpp util.cpp \
|
||||
Att.h Cmd.h Config.h Context.h Date.h Duration.h Filter.h \
|
||||
Grid.h Keymap.h Location.h Nibbler.h Record.h Sequence.h \
|
||||
StringTable.h Subst.h Task.h TDB.h Table.h Timer.h \
|
||||
Permission.h color.h i18n.h main.h text.h util.h
|
||||
|
||||
336
src/Nibbler.cpp
336
src/Nibbler.cpp
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -26,26 +26,19 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "Nibbler.h"
|
||||
#include "rx.h"
|
||||
|
||||
const char* c_digits = "0123456789";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Nibbler::Nibbler ()
|
||||
: mInput ("")
|
||||
, mLength (0)
|
||||
, mCursor (0)
|
||||
, mSaved (0)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Nibbler::Nibbler (const char* input)
|
||||
: mInput (input)
|
||||
, mLength (strlen (input))
|
||||
, mCursor (0)
|
||||
{
|
||||
}
|
||||
@@ -53,7 +46,6 @@ Nibbler::Nibbler (const char* input)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Nibbler::Nibbler (const std::string& input)
|
||||
: mInput (input)
|
||||
, mLength (input.length ())
|
||||
, mCursor (0)
|
||||
{
|
||||
}
|
||||
@@ -62,7 +54,6 @@ Nibbler::Nibbler (const std::string& input)
|
||||
Nibbler::Nibbler (const Nibbler& other)
|
||||
{
|
||||
mInput = other.mInput;
|
||||
mLength = other.mLength;
|
||||
mCursor = other.mCursor;
|
||||
}
|
||||
|
||||
@@ -72,7 +63,6 @@ Nibbler& Nibbler::operator= (const Nibbler& other)
|
||||
if (this != &other)
|
||||
{
|
||||
mInput = other.mInput;
|
||||
mLength = other.mLength;
|
||||
mCursor = other.mCursor;
|
||||
}
|
||||
|
||||
@@ -85,10 +75,10 @@ Nibbler::~Nibbler ()
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Extract up until the next c (but not including) or EOS.
|
||||
// Extract up until the next c, or EOS.
|
||||
bool Nibbler::getUntil (char c, std::string& result)
|
||||
{
|
||||
if (mCursor < mLength)
|
||||
if (mCursor < mInput.length ())
|
||||
{
|
||||
std::string::size_type i = mInput.find (c, mCursor);
|
||||
if (i != std::string::npos)
|
||||
@@ -98,8 +88,8 @@ bool Nibbler::getUntil (char c, std::string& result)
|
||||
}
|
||||
else
|
||||
{
|
||||
result = mInput.substr (mCursor);
|
||||
mCursor = mLength;
|
||||
result = mInput.substr (mCursor, std::string::npos);
|
||||
mCursor = mInput.length ();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -111,7 +101,7 @@ bool Nibbler::getUntil (char c, std::string& result)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getUntil (const std::string& terminator, std::string& result)
|
||||
{
|
||||
if (mCursor < mLength)
|
||||
if (mCursor < mInput.length ())
|
||||
{
|
||||
std::string::size_type i = mInput.find (terminator, mCursor);
|
||||
if (i != std::string::npos)
|
||||
@@ -121,38 +111,8 @@ bool Nibbler::getUntil (const std::string& terminator, std::string& result)
|
||||
}
|
||||
else
|
||||
{
|
||||
result = mInput.substr (mCursor);
|
||||
mCursor = mLength;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getUntilRx (const std::string& regex, std::string& result)
|
||||
{
|
||||
if (mCursor < mLength)
|
||||
{
|
||||
std::string modified_regex;
|
||||
if (regex[0] != '(')
|
||||
modified_regex = "(" + regex + ")";
|
||||
else
|
||||
modified_regex = regex;
|
||||
|
||||
std::vector <int> start;
|
||||
std::vector <int> end;
|
||||
if (regexMatch (start, end, mInput.substr (mCursor), modified_regex, true))
|
||||
{
|
||||
result = mInput.substr (mCursor, start[0]);
|
||||
mCursor += start[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
result = mInput.substr (mCursor);
|
||||
mCursor = mLength;
|
||||
result = mInput.substr (mCursor, std::string::npos);
|
||||
mCursor = mInput.length ();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -164,7 +124,7 @@ bool Nibbler::getUntilRx (const std::string& regex, std::string& result)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getUntilOneOf (const std::string& chars, std::string& result)
|
||||
{
|
||||
if (mCursor < mLength)
|
||||
if (mCursor < mInput.length ())
|
||||
{
|
||||
std::string::size_type i = mInput.find_first_of (chars, mCursor);
|
||||
if (i != std::string::npos)
|
||||
@@ -174,8 +134,8 @@ bool Nibbler::getUntilOneOf (const std::string& chars, std::string& result)
|
||||
}
|
||||
else
|
||||
{
|
||||
result = mInput.substr (mCursor);
|
||||
mCursor = mLength;
|
||||
result = mInput.substr (mCursor, std::string::npos);
|
||||
mCursor = mInput.length ();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -184,135 +144,13 @@ bool Nibbler::getUntilOneOf (const std::string& chars, std::string& result)
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getUntilWS (std::string& result)
|
||||
{
|
||||
return this->getUntilOneOf (" \t\r\n\f", result);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getUntilEOL (std::string& result)
|
||||
{
|
||||
return getUntil ('\n', result);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getUntilEOS (std::string& result)
|
||||
{
|
||||
if (mCursor < mLength)
|
||||
{
|
||||
result = mInput.substr (mCursor);
|
||||
mCursor = mLength;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getQuoted (char c, std::string& result)
|
||||
{
|
||||
std::string::size_type backup = mCursor;
|
||||
|
||||
if (skip (c) &&
|
||||
getUntil (c, result) &&
|
||||
skip (c))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
mCursor = backup;
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getInt (int& result)
|
||||
{
|
||||
std::string::size_type i = mCursor;
|
||||
|
||||
if (i < mLength)
|
||||
{
|
||||
if (mInput[i] == '-')
|
||||
++i;
|
||||
else if (mInput[i] == '+')
|
||||
++i;
|
||||
}
|
||||
|
||||
// TODO Potential for use of find_first_not_of
|
||||
while (i < mLength && isdigit (mInput[i]))
|
||||
++i;
|
||||
|
||||
if (i > mCursor)
|
||||
{
|
||||
result = atoi (mInput.substr (mCursor, i - mCursor).c_str ());
|
||||
mCursor = i;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getUnsignedInt (int& result)
|
||||
{
|
||||
std::string::size_type i = mCursor;
|
||||
// TODO Potential for use of find_first_not_of
|
||||
while (i < mLength && isdigit (mInput[i]))
|
||||
++i;
|
||||
|
||||
if (i > mCursor)
|
||||
{
|
||||
result = atoi (mInput.substr (mCursor, i - mCursor).c_str ());
|
||||
mCursor = i;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getLiteral (const std::string& literal)
|
||||
{
|
||||
if (mCursor < mLength &&
|
||||
mInput.find (literal, mCursor) == mCursor)
|
||||
{
|
||||
mCursor += literal.length ();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getRx (const std::string& regex, std::string& result)
|
||||
{
|
||||
if (mCursor < mLength)
|
||||
{
|
||||
// Regex may be anchored to the beginning and include capturing parentheses,
|
||||
// otherwise they are added.
|
||||
std::string modified_regex;
|
||||
if (regex.substr (0, 2) != "^(")
|
||||
modified_regex = "^(" + regex + ")";
|
||||
else
|
||||
modified_regex = regex;
|
||||
|
||||
std::vector <std::string> results;
|
||||
if (regexMatch (results, mInput.substr (mCursor), modified_regex, true))
|
||||
{
|
||||
result = results[0];
|
||||
mCursor += result.length ();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::skipN (const int quantity /* = 1 */)
|
||||
{
|
||||
if (mCursor < mLength &&
|
||||
mCursor <= mLength - quantity)
|
||||
if (mCursor >= mInput.length ())
|
||||
return false;
|
||||
|
||||
if (mCursor <= mInput.length () - quantity)
|
||||
{
|
||||
mCursor += quantity;
|
||||
return true;
|
||||
@@ -324,7 +162,7 @@ bool Nibbler::skipN (const int quantity /* = 1 */)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::skip (char c)
|
||||
{
|
||||
if (mCursor < mLength &&
|
||||
if (mCursor < mInput.length () &&
|
||||
mInput[mCursor] == c)
|
||||
{
|
||||
++mCursor;
|
||||
@@ -337,64 +175,30 @@ bool Nibbler::skip (char c)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::skipAll (char c)
|
||||
{
|
||||
if (mCursor < mLength)
|
||||
std::string::size_type i = mCursor;
|
||||
while (i < mInput.length () && mInput[i] == c)
|
||||
++i;
|
||||
|
||||
if (i != mCursor)
|
||||
{
|
||||
std::string::size_type i = mInput.find_first_not_of (c, mCursor);
|
||||
if (i == mCursor)
|
||||
return false;
|
||||
|
||||
if (i == std::string::npos)
|
||||
mCursor = mLength; // Yes, off the end.
|
||||
else
|
||||
mCursor = i;
|
||||
|
||||
mCursor = i;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::skipWS ()
|
||||
{
|
||||
return this->skipAllOneOf (" \t\n\r\f");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::skipRx (const std::string& regex)
|
||||
{
|
||||
if (mCursor < mLength)
|
||||
{
|
||||
// Regex may be anchored to the beginning and include capturing parentheses,
|
||||
// otherwise they are added.
|
||||
std::string modified_regex;
|
||||
if (regex.substr (0, 2) != "^(")
|
||||
modified_regex = "^(" + regex + ")";
|
||||
else
|
||||
modified_regex = regex;
|
||||
|
||||
std::vector <std::string> results;
|
||||
if (regexMatch (results, mInput.substr (mCursor), modified_regex, true))
|
||||
{
|
||||
mCursor += results[0].length ();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::skipAllOneOf (const std::string& chars)
|
||||
{
|
||||
if (mCursor < mLength)
|
||||
if (mCursor < mInput.length ())
|
||||
{
|
||||
std::string::size_type i = mInput.find_first_not_of (chars, mCursor);
|
||||
if (i == mCursor)
|
||||
return false;
|
||||
|
||||
if (i == std::string::npos)
|
||||
mCursor = mLength; // Yes, off the end.
|
||||
mCursor = mInput.length (); // Yes, off the end.
|
||||
else
|
||||
mCursor = i;
|
||||
|
||||
@@ -405,54 +209,96 @@ bool Nibbler::skipAllOneOf (const std::string& chars)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Peeks ahead - does not move cursor.
|
||||
char Nibbler::next ()
|
||||
bool Nibbler::getQuoted (char c, std::string& result)
|
||||
{
|
||||
if (mCursor < mLength)
|
||||
return mInput[mCursor];
|
||||
std::string::size_type start = mCursor;
|
||||
if (start < mInput.length () && mInput[start] == c)
|
||||
{
|
||||
++start;
|
||||
if (start < mInput.length ())
|
||||
{
|
||||
std::string::size_type end = mInput.find (c, start);
|
||||
if (end != std::string::npos)
|
||||
{
|
||||
result = mInput.substr (start, end - start);
|
||||
mCursor = end + 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '\0';
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Peeks ahead - does not move cursor.
|
||||
std::string Nibbler::next (const int quantity)
|
||||
bool Nibbler::getInt (int& result)
|
||||
{
|
||||
if ( mCursor < mLength &&
|
||||
(unsigned) quantity <= mLength &&
|
||||
mCursor <= mLength - quantity)
|
||||
return mInput.substr (mCursor, quantity);
|
||||
std::string::size_type i = mCursor;
|
||||
|
||||
return "";
|
||||
if (i < mInput.length ())
|
||||
{
|
||||
if (mInput[i] == '-')
|
||||
++i;
|
||||
else if (mInput[i] == '+')
|
||||
++i;
|
||||
}
|
||||
|
||||
while (i < mInput.length () && ::isdigit (mInput[i]))
|
||||
++i;
|
||||
|
||||
if (i > mCursor)
|
||||
{
|
||||
result = ::atoi (mInput.substr (mCursor, i - mCursor).c_str ());
|
||||
mCursor = i;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Nibbler::save ()
|
||||
bool Nibbler::getUnsignedInt (int& result)
|
||||
{
|
||||
mSaved = mCursor;
|
||||
std::string::size_type i = mCursor;
|
||||
while (i < mInput.length () && ::isdigit (mInput[i]))
|
||||
++i;
|
||||
|
||||
if (i > mCursor)
|
||||
{
|
||||
result = ::atoi (mInput.substr (mCursor, i - mCursor).c_str ());
|
||||
mCursor = i;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Nibbler::restore ()
|
||||
bool Nibbler::getUntilEOL (std::string& result)
|
||||
{
|
||||
mCursor = mSaved;
|
||||
return getUntil ('\n', result);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getUntilEOS (std::string& result)
|
||||
{
|
||||
if (mCursor < mInput.length ())
|
||||
{
|
||||
result = mInput.substr (mCursor, std::string::npos);
|
||||
mCursor = mInput.length ();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::depleted ()
|
||||
{
|
||||
if (mCursor >= mLength)
|
||||
if (mCursor >= mInput.length ())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Nibbler::dump ()
|
||||
{
|
||||
return std::string ("Nibbler ‹")
|
||||
+ mInput.substr (mCursor)
|
||||
+ "›";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -41,40 +41,21 @@ public:
|
||||
|
||||
bool getUntil (char, std::string&);
|
||||
bool getUntil (const std::string&, std::string&);
|
||||
bool getUntilRx (const std::string&, std::string&);
|
||||
bool getUntilOneOf (const std::string&, std::string&);
|
||||
bool getUntilWS (std::string&);
|
||||
bool getUntilEOL (std::string&);
|
||||
bool getUntilEOS (std::string&);
|
||||
|
||||
bool getQuoted (char, std::string&);
|
||||
bool getInt (int&);
|
||||
bool getUnsignedInt (int&);
|
||||
bool getLiteral (const std::string&);
|
||||
bool getRx (const std::string&, std::string&);
|
||||
|
||||
bool skipN (const int quantity = 1);
|
||||
bool skip (char);
|
||||
bool skipAll (char);
|
||||
bool skipAllOneOf (const std::string&);
|
||||
bool skipWS ();
|
||||
bool skipRx (const std::string&);
|
||||
|
||||
char next ();
|
||||
std::string next (const int quantity);
|
||||
|
||||
void save ();
|
||||
void restore ();
|
||||
|
||||
bool getQuoted (char, std::string&);
|
||||
bool getInt (int&);
|
||||
bool getUnsignedInt (int&i);
|
||||
bool getUntilEOL (std::string&);
|
||||
bool getUntilEOS (std::string&);
|
||||
bool depleted ();
|
||||
|
||||
std::string dump ();
|
||||
|
||||
private:
|
||||
std::string mInput;
|
||||
std::string::size_type mLength;
|
||||
std::string::size_type mCursor;
|
||||
std::string::size_type mSaved;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
217
src/Path.cpp
217
src/Path.cpp
@@ -1,217 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation; either version 2 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program; if not, write to the
|
||||
//
|
||||
// Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor,
|
||||
// Boston, MA
|
||||
// 02110-1301
|
||||
// USA
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <fstream>
|
||||
#include <glob.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
#include "Path.h"
|
||||
#include "../auto.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Path::Path ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Path::Path (const Path& other)
|
||||
{
|
||||
if (this != &other)
|
||||
data = other.data;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Path::Path (const std::string& in)
|
||||
{
|
||||
data = expand (in);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Path::~Path ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Path& Path::operator= (const Path& other)
|
||||
{
|
||||
if (this != &other)
|
||||
this->data = other.data;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Path::operator std::string () const
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Path::name () const
|
||||
{
|
||||
if (data.length ())
|
||||
{
|
||||
std::string::size_type slash = data.rfind ('/');
|
||||
if (slash != std::string::npos)
|
||||
return data.substr (slash + 1, std::string::npos);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Path::parent () const
|
||||
{
|
||||
if (data.length ())
|
||||
{
|
||||
std::string::size_type slash = data.rfind ('/');
|
||||
if (slash != std::string::npos)
|
||||
return data.substr (0, slash);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Path::extension () const
|
||||
{
|
||||
if (data.length ())
|
||||
{
|
||||
std::string::size_type dot = data.rfind ('.');
|
||||
if (dot != std::string::npos)
|
||||
return data.substr (dot + 1, std::string::npos);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Path::exists () const
|
||||
{
|
||||
return access (data.c_str (), F_OK) ? false : true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Path::is_directory () const
|
||||
{
|
||||
struct stat s = {0};
|
||||
if (! stat (data.c_str (), &s) &&
|
||||
s.st_mode & S_IFDIR)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Path::is_absolute () const
|
||||
{
|
||||
if (data.length () && data.substr (0, 1) == "/")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Path::readable () const
|
||||
{
|
||||
return access (data.c_str (), R_OK) ? false : true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Path::writable () const
|
||||
{
|
||||
return access (data.c_str (), W_OK) ? false : true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Path::executable () const
|
||||
{
|
||||
return access (data.c_str (), X_OK) ? false : true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ~ --> /home/user
|
||||
// ~foo/x --> /home/foo/s
|
||||
// ~/x --> /home/foo/x
|
||||
std::string Path::expand (const std::string& in)
|
||||
{
|
||||
std::string copy = in;
|
||||
|
||||
std::string::size_type tilde = copy.find ("~");
|
||||
std::string::size_type slash;
|
||||
|
||||
if (tilde != std::string::npos)
|
||||
{
|
||||
struct passwd* pw = getpwuid (getuid ());
|
||||
|
||||
// Convert: ~ --> /home/user
|
||||
if (copy.length () == 1)
|
||||
{
|
||||
copy = pw->pw_dir;
|
||||
}
|
||||
|
||||
// Convert: ~/x --> /home/user/x
|
||||
else if (copy.length () > tilde + 1 &&
|
||||
copy[tilde + 1] == '/')
|
||||
{
|
||||
copy.replace (tilde, 1, pw->pw_dir);
|
||||
}
|
||||
|
||||
// Convert: ~foo/x --> /home/foo/x
|
||||
else if ((slash = copy.find ("/", tilde)) != std::string::npos)
|
||||
{
|
||||
std::string name = copy.substr (tilde + 1, slash - tilde - 1);
|
||||
struct passwd* pw = getpwnam (name.c_str ());
|
||||
if (pw)
|
||||
copy.replace (tilde, slash - tilde, pw->pw_dir);
|
||||
}
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::vector <std::string> Path::glob (const std::string& pattern)
|
||||
{
|
||||
std::vector <std::string> results;
|
||||
|
||||
glob_t g;
|
||||
#ifdef SOLARIS
|
||||
if (!::glob (pattern.c_str (), GLOB_ERR, NULL, &g))
|
||||
#else
|
||||
if (!::glob (pattern.c_str (), GLOB_ERR | GLOB_BRACE | GLOB_TILDE, NULL, &g))
|
||||
#endif
|
||||
for (int i = 0; i < (int) g.gl_pathc; ++i)
|
||||
results.push_back (g.gl_pathv[i]);
|
||||
|
||||
globfree (&g);
|
||||
return results;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
63
src/Path.h
63
src/Path.h
@@ -1,63 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation; either version 2 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program; if not, write to the
|
||||
//
|
||||
// Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor,
|
||||
// Boston, MA
|
||||
// 02110-1301
|
||||
// USA
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef INCLUDED_PATH
|
||||
#define INCLUDED_PATH
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class Path
|
||||
{
|
||||
public:
|
||||
Path ();
|
||||
Path (const Path&);
|
||||
Path (const std::string&);
|
||||
virtual ~Path ();
|
||||
|
||||
Path& operator= (const Path&);
|
||||
operator std::string () const;
|
||||
|
||||
std::string name () const;
|
||||
std::string parent () const;
|
||||
std::string extension () const;
|
||||
bool exists () const;
|
||||
bool is_directory () const;
|
||||
bool is_absolute () const;
|
||||
bool readable () const;
|
||||
bool writable () const;
|
||||
bool executable () const;
|
||||
|
||||
// Statics
|
||||
static std::string expand (const std::string&);
|
||||
static std::vector<std::string> glob (const std::string&);
|
||||
|
||||
public:
|
||||
std::string data;
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -37,19 +37,15 @@ extern Context context;
|
||||
Permission::Permission ()
|
||||
: needConfirmation (false)
|
||||
, allConfirmed (false)
|
||||
, quit (false)
|
||||
{
|
||||
// Turning confirmations off is the same as entering "all".
|
||||
if (context.config.getBoolean ("confirmation") == false)
|
||||
if (context.config.get ("confirmation", true) == false)
|
||||
allConfirmed = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Permission::confirmed (const Task& task, const std::string& question)
|
||||
{
|
||||
if (quit)
|
||||
return false;
|
||||
|
||||
if (!needConfirmation)
|
||||
return true;
|
||||
|
||||
@@ -61,25 +57,16 @@ bool Permission::confirmed (const Task& task, const std::string& question)
|
||||
<< task.id
|
||||
<< " \""
|
||||
<< task.get ("description")
|
||||
<< "\"";
|
||||
<< "\""
|
||||
<< std::endl;
|
||||
|
||||
if (task.getStatus () == Task::recurring ||
|
||||
task.has ("parent"))
|
||||
{
|
||||
std::cout << " (Recurring)";
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
int answer = confirm4 (question);
|
||||
int answer = confirm3 (question);
|
||||
if (answer == 2)
|
||||
allConfirmed = true;
|
||||
|
||||
if (answer == 1 || answer == 2)
|
||||
if (answer > 0)
|
||||
return true;
|
||||
|
||||
if (answer == 3)
|
||||
quit = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -44,7 +44,6 @@ public:
|
||||
private:
|
||||
bool needConfirmation;
|
||||
bool allConfirmed;
|
||||
bool quit;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -152,17 +152,7 @@ int Record::get_int (const std::string& name) const
|
||||
{
|
||||
Record::const_iterator i = this->find (name);
|
||||
if (i != this->end ())
|
||||
return atoi (i->second.value ().c_str ());
|
||||
|
||||
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 ::atoi (i->second.value ().c_str ());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -47,7 +47,6 @@ 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&);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -98,7 +98,7 @@ void Sequence::parse (const std::string& input)
|
||||
if (! validId (range[0]))
|
||||
throw context.stringtable.get (SEQUENCE_BAD_SEQ, "Invalid ID in sequence");
|
||||
|
||||
int id = atoi (range[0].c_str ());
|
||||
int id = ::atoi (range[0].c_str ());
|
||||
this->push_back (id);
|
||||
}
|
||||
break;
|
||||
@@ -109,8 +109,8 @@ void Sequence::parse (const std::string& input)
|
||||
! validId (range[1]))
|
||||
throw context.stringtable.get (SEQUENCE_BAD_SEQ, "Invalid ID in range");
|
||||
|
||||
int low = atoi (range[0].c_str ());
|
||||
int high = atoi (range[1].c_str ());
|
||||
int low = ::atoi (range[0].c_str ());
|
||||
int high = ::atoi (range[1].c_str ());
|
||||
if (low > high)
|
||||
throw context.stringtable.get (SEQUENCE_INVERTED, "Inverted sequence range high-low");
|
||||
|
||||
@@ -153,7 +153,7 @@ bool Sequence::validId (const std::string& input) const
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < input.length (); ++i)
|
||||
if (!isdigit (input[i]))
|
||||
if (!::isdigit (input[i]))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -72,7 +72,7 @@ void StringTable::load (const std::string& file)
|
||||
std::string::size_type equal = line.find (" "); // no i18n
|
||||
if (equal != std::string::npos)
|
||||
{
|
||||
int key = atoi (trim (line.substr (0, equal), " \t").c_str ()); // no i18n
|
||||
int key = ::atoi (trim (line.substr (0, equal), " \t").c_str ()); // no i18n
|
||||
std::string value = trim (line.substr (equal+1, line.length () - equal), " \t"); // no i18n
|
||||
(*this)[key] = value;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "Subst.h"
|
||||
#include "Nibbler.h"
|
||||
#include "Context.h"
|
||||
#include "text.h"
|
||||
#include "i18n.h"
|
||||
|
||||
extern Context context;
|
||||
@@ -122,48 +121,31 @@ void Subst::apply (
|
||||
std::vector <Att>& annotations) const
|
||||
{
|
||||
std::string::size_type pattern;
|
||||
bool sensitive = context.config.getBoolean ("search.case.sensitive");
|
||||
|
||||
if (mFrom != "")
|
||||
{
|
||||
if (mGlobal)
|
||||
{
|
||||
// Perform all subs on description.
|
||||
int counter = 0;
|
||||
pattern = 0;
|
||||
|
||||
while ((pattern = find (description, mFrom, pattern, sensitive)) != std::string::npos)
|
||||
{
|
||||
while ((pattern = description.find (mFrom)) != std::string::npos)
|
||||
description.replace (pattern, mFrom.length (), mTo);
|
||||
pattern += mTo.length ();
|
||||
|
||||
if (++counter > 1000)
|
||||
throw ("Terminated substitution because more than a thousand changes were made - infinite loop protection.");
|
||||
}
|
||||
|
||||
// Perform all subs on annotations.
|
||||
counter = 0;
|
||||
pattern = 0;
|
||||
std::vector <Att>::iterator i;
|
||||
for (i = annotations.begin (); i != annotations.end (); ++i)
|
||||
{
|
||||
std::string annotation = i->value ();
|
||||
while ((pattern = find (annotation, mFrom, pattern, sensitive)) != std::string::npos)
|
||||
std::string description = i->value ();
|
||||
while ((pattern = description.find (mFrom)) != std::string::npos)
|
||||
{
|
||||
annotation.replace (pattern, mFrom.length (), mTo);
|
||||
pattern += mTo.length ();
|
||||
|
||||
i->value (annotation);
|
||||
|
||||
if (++counter > 1000)
|
||||
throw ("Terminated substitution because more than a thousand changes were made - infinite loop protection.");
|
||||
description.replace (pattern, mFrom.length (), mTo);
|
||||
i->value (description);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Perform first description substitution.
|
||||
if ((pattern = find (description, mFrom, sensitive)) != std::string::npos)
|
||||
if ((pattern = description.find (mFrom)) != std::string::npos)
|
||||
description.replace (pattern, mFrom.length (), mTo);
|
||||
|
||||
// Failing that, perform the first annotation substitution.
|
||||
@@ -172,11 +154,11 @@ void Subst::apply (
|
||||
std::vector <Att>::iterator i;
|
||||
for (i = annotations.begin (); i != annotations.end (); ++i)
|
||||
{
|
||||
std::string annotation = i->value ();
|
||||
if ((pattern = find (annotation, mFrom, sensitive)) != std::string::npos)
|
||||
std::string description = i->value ();
|
||||
if ((pattern = description.find (mFrom)) != std::string::npos)
|
||||
{
|
||||
annotation.replace (pattern, mFrom.length (), mTo);
|
||||
i->value (annotation);
|
||||
description.replace (pattern, mFrom.length (), mTo);
|
||||
i->value (description);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user