Compare commits

..

433 Commits

Author SHA1 Message Date
Federico Hernandez
a13989f18e Release date for 1.9.2 2010-07-10 23:14:06 +02:00
Paul Beckingham
97bb07a617 Documentation
- Removed erroneous entry
2010-07-10 12:39:52 -04:00
Paul Beckingham
01d0d036a4 Documentation
- Synched the wiki FAQ with the man page.
2010-07-10 12:30:01 -04:00
Paul Beckingham
7de5b22f1c Unit Tests
- Corrected misspelling of config variable.
2010-07-09 01:32:00 -04:00
Paul Beckingham
cb635c0d6f Unit Tests
- Changed cal.t calendar colors to avoid false assumptions.
2010-07-09 01:01:16 -04:00
Paul Beckingham
111e9f893d Documentation Update
- Updated the OSX package creation instructions document, after feedback
  from Kevin.
2010-07-09 00:42:33 -04:00
Paul Beckingham
f96d2e6609 Documentation update
- Added Kevin Owens to the AUTHORS file for invaluable help with
  creating OSX 10.5 packages, and debugging the instructions
  document.
2010-07-09 00:38:41 -04:00
Paul Beckingham
8a930653a4 Unit Tests
- Correcting more unit tests that made color assumptions that are no
  longer valid.
2010-07-09 00:30:47 -04:00
Paul Beckingham
bc46888bcd Unit Tests
- Added null values for color.tagged and color.alternate, for the
  tests it affects.
2010-07-08 22:26:41 -04:00
Paul Beckingham
67fd7e2faa Themes
- Final tweak.
2010-07-08 22:03:45 -04:00
Paul Beckingham
9f96ab28ce Merge branch '1.9.2' of tasktools.org:task into 1.9.2 2010-07-08 21:13:28 -04:00
Paul Beckingham
a66f59a7e1 Packaging
- PDF of OSX packaging instructions.
2010-07-08 21:13:04 -04:00
Paul Beckingham
24e1522e32 Packaging
- First minor tweaks.
2010-07-08 19:47:10 -04:00
Paul Beckingham
f5bc5dfd0f Packaging
- Finished first version of the OSX packaging document.
2010-07-08 19:13:31 -04:00
Paul Beckingham
82702bffdc Unit Tests
- Modified unit tests for rc.t, in the hopes that task for OSX 10.5
  can pass them.
2010-07-08 01:55:17 -04:00
Paul Beckingham
1a05224816 Portability
- Fixed warning on Solaris.
2010-07-08 01:44:15 -04:00
Paul Beckingham
e4f7bda430 Packaging
- Updated 'update' script.
- Began README that provides instructions on how to create packages for
  OSX.  Unfinished.
2010-07-08 01:43:30 -04:00
Paul Beckingham
38ca8c8fb5 Themes
- Last tweaking.
2010-07-07 09:12:53 -04:00
Paul Beckingham
ad9c89b9fb Performance
- Found some inefficient string initialization in Table.cpp, report.cpp,
  and in switching over to using more std::string capabilities, realized
  a 25% boost in Table::render speed.
- Eliminated Table::suppressWS.
- Eliminated Table::clean.
2010-07-06 01:37:35 -04:00
Paul Beckingham
25db00e97d Unit Tests
- Added specific calendar colors to the rc file used in cal.t, so that
  the colors in the tests (which are in the old theme) match the new
  default theme.
2010-07-05 23:36:08 -04:00
Paul Beckingham
b3f3261190 Themes
- Contrast adjustments.
2010-07-05 18:16:31 -04:00
Paul Beckingham
6efd3299fe Default Theme
- Linux now uses dark-256 equivalent, when a new .taskrc file is created.
2010-07-05 17:56:44 -04:00
Paul Beckingham
844c980bce Enhancement - strippedLength
- Added a text method that calculates a string length but does not
  include color control codes.
2010-07-05 15:55:50 -04:00
Paul Beckingham
ce99cbf2d4 Themes - default
- Task now defaults to *the equivalent of* the dark-16.theme.
2010-07-05 15:01:15 -04:00
Paul Beckingham
5fb349ca9b Code Cleanup
- Minor formatting change.
2010-07-05 13:33:42 -04:00
Paul Beckingham
00041dce41 Themes
- Included first set of 7 theme files, for light and dark backgrounds,
  with 16- and 256-color support.
- Modified man pages accordingly.
2010-07-05 13:32:11 -04:00
Paul Beckingham
d6631767b5 Themes
- Assorted low-effort theme files, as examples.  More coming.
2010-07-05 12:16:51 -04:00
Paul Beckingham
0c4f83377a RC
- Put a 'calendar.holidays=sparse' entry inside the holidays files,
  which serves to enable the holiday feature if a holiday file is
  included.
2010-07-04 18:04:18 -04:00
Paul Beckingham
a45d6b459f Unit Tests - bug.summary.t
- Fixed tests that expected a newly-added task to have an age of '-',
  but on Cygwin, with the lower performance, the age is actually '3 secs'.
2010-07-04 13:26:19 -04:00
Paul Beckingham
d77a790f21 Portability
- Added stdlib.h to rx.cpp, which is needed by Cygwin at least.
2010-07-04 10:50:34 -04:00
Johannes Schlatow
5ecbd85020 Bug - merge command resulted in an error if
completed/deleted tasks were overwritten with pending tasks
2010-07-04 01:19:44 +02:00
Johannes Schlatow
6428b026ba Missing include 2010-07-04 01:08:21 +02:00
Paul Beckingham
716ed39695 Missing include
- The usual problem, this time <algorithm>.
2010-07-03 18:44:29 -04:00
Paul Beckingham
c650edd4f9 Support #383 - odd feedback when changing an existing, recurring project
- Fixed wording (support issue #383) when modifying a recurring task (thanks
  to T. Charles Yun).
2010-07-03 17:57:31 -04:00
Paul Beckingham
484c31f0e4 Documentation
- Modified the wording of the output of the undo command.
2010-07-03 17:54:02 -04:00
Paul Beckingham
d00b57ec65 Feature - #156
+ Task now supports both a 'side' and 'diff' style of undo.
+ Undo now observes the 'color.undo.before' and 'color.undo.after'
  configuration variables.
2010-07-03 15:50:46 -04:00
Paul Beckingham
724e9b8113 Color
- The ghistory graph bars can now be colored with 'color.history.add',
  'color.history.done' and 'color.history.delete' configuration variables.
2010-07-03 12:51:36 -04:00
Paul Beckingham
356519e58f Bug #420 - Missing ID from help output
- Applied patch from Ed Neville to correct help output for the
  append and prepend commands.
2010-07-03 09:27:11 -04:00
Paul Beckingham
213a7a519b Feature - merge command
- Merged patch that implements the first milestone of the merge
  feature.  Thanks to Johannes Schlatow.
2010-07-01 20:22:33 -04:00
Paul Beckingham
d7c446f010 Bug
- Fixed bug that miscalculated terminal width for the ghistory.annual
  report.
2010-07-01 01:06:43 -04:00
Paul Beckingham
14508742f1 Code Cleanup
- Removed obsolete code from Table object.
2010-06-28 17:46:27 -04:00
Paul Beckingham
6ea6c79375 Bug
- Fixed bug that prevented 'task list priority.above:L' from working.
- Added unit tests.
2010-06-28 17:45:42 -04:00
Paul Beckingham
426eac97aa Feature - sorting by age, age_compact
- Now supports correct sorting of the age and age_compact fields.
2010-06-27 19:31:08 -04:00
Paul Beckingham
7f99d39d19 Unit Tests - timesheet report
- Added unit tests to make sure the timesheet report lists the correct
  tasks in the correct section and week.
2010-06-27 18:43:40 -04:00
Paul Beckingham
623f8d869e Portability
- Added missing includes.
2010-06-27 17:06:51 -04:00
Paul Beckingham
b2eb9c3265 Bug #405 - after upgrade, "due:" filter not working for tasks created in version 1.9.0
- 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).
2010-06-27 16:55:29 -04:00
Paul Beckingham
688233b3a4 Documentation Update
- Fixed formatting problem in taskrc.5, where the indentation was
  not consistent.
2010-06-27 15:40:59 -04:00
Paul Beckingham
12cdee9809 Documentation Update
- Changed the line "New features in 1.9" to "New features in 1.9.2",
  otherwise the list looks a little light.
2010-06-27 15:20:41 -04:00
Paul Beckingham
66fcdfe01f Bug #312 - Task sorting
- Fixed bug #132, which failed to set a sort order so that active tasks sort
  higher than inactive tasks, all things being equal.
- All reports that include the 'active' column now sort on that column.
2010-06-27 15:14:27 -04:00
Paul Beckingham
0f7cf1cd52 Bug #418 - due.before:eow not working
- 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).
- Bug was probably fixed when #416 was fixed, but now has it's own unit tests.
2010-06-27 14:25:03 -04:00
Paul Beckingham
007c194c8c Bug #417 - Sorting by countdown_compact not working
- Added support for more varied durations when specifying recurring tasks,
  such as '3 mths' or '24 hrs'.
- Fixed bug #417, which caused sorting on countdown fields to be wrong
  (thanks to Michell Crane).
- Durations are now based on seconds, rather than days, and can accept/parse
  negative durations.
2010-06-27 13:44:04 -04:00
Paul Beckingham
ff18241f6f Unit Tests
- Enhanced 'run_all' so that by default, it does not run the benchmark.t
  script, but does if the 'slow' argument is specified.
2010-06-27 00:59:28 -04:00
Paul Beckingham
9477660e02 Enhancement - Duration
- Relocated util/formatSeconds and util/formatSecondsCompact into
  Duration object.
- Relocated unit tests.
- Upgraded Duration object to use seconds, not days.
- Enhanced Duration so that it can now parse '4 mins' etc.
2010-06-27 00:57:52 -04:00
Paul Beckingham
1f8f4c631d Enhancement - Duration
- Durations can now parse '3 wks', '1 wk', '1w', and similar for yrs,
  qtrs, mths, wks, days.
- Added unit tests.
2010-06-26 21:47:52 -04:00
Paul Beckingham
05fd9278a6 Code Cleaup
- Reimplemented Nibbler::getQuoted.
- Reimplemented Nibbler::skipN.
2010-06-26 20:14:45 -04:00
Paul Beckingham
f1a0b842dc Nibbler upgrade
- Merged Nibbler code from Tegelsten.
- Updated unit tests.
2010-06-26 19:55:17 -04:00
Paul Beckingham
cd59f7f510 Code Cleanup
- Corrected comments.
- Eliminated redundant code, at the expense of Task::parse call.
2010-06-26 17:33:58 -04:00
Paul Beckingham
6a1a1cd70f Added regular expression support
- Added rx.{h,cpp} from Tegelsten.
- Added unit tests.
2010-06-26 16:54:31 -04:00
Paul Beckingham
3c2987f53f Bug #416 - Sorting by due date with dateformat MD wrong
- Fixed bug #416, which caused sorting on a date to fail if the year was not
  included in the dateformat (thanks to Michelle Crane).
- Added unit tests.
2010-06-25 09:09:20 -04:00
Paul Beckingham
2ab1df77df Merge branch '1.9.2' of tasktools.org:task into 1.9.2 2010-06-23 17:22:21 -04:00
Paul Beckingham
abf31a6b35 Performance Enhancements
- Nibbler: Now locally stores input length rather than repeatedly calling
  std::string::length.
- Nibbler: Makes greater use of std::string::find_first_not_of, instead of
  looping.
- TDB: No longer applies empty filters to lists - just copies the lists.
- TDB: Now caches data when reading completed.data.
- TDB: During loadPending and loadCompleted, makes fewer copies of the data.
- TDB: In commit, breaks out of search loops after finding the right data.
- TDB: In gc, only writes out minimal pending or completed data, instead of
       all data, all the time.
- TDB: No longer reads completed.data in gc, and simply appends completed
       and deleted tasks to it.
2010-06-23 17:21:56 -04:00
Federico Hernandez
b6d320d311 Adjusted denotate
- partly matched strings are now also detected in the middle of the
  annotation and not only from the beginning.
2010-06-21 22:56:05 +02:00
Paul Beckingham
cd648270ab New alias
- Added export.vcalendar as an alias to export.ical.  They are the same.
2010-06-20 23:17:56 -04:00
Paul Beckingham
2161ffac2c Documentation update
- Added RFC references to ChangeLog, NEWS.
- Replaced the answer in the FAQ regarding annotation deletion.
2010-06-20 23:15:04 -04:00
Paul Beckingham
4f4a32b405 Enhancement
- Swapped std::string::find for find (from text.cpp) to allow
  configurable case sensitivity.
2010-06-20 20:22:39 -04:00
Paul Beckingham
99bce308e6 Bug #414 - Tags filtering not working with unicode characters
- 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 #414, that caused filtering on the presence or absence of tags
+   containing Unicode characters to fail (thanks to Michal Josífko).

 ------ old releases ------------------------------
2010-06-20 20:10:20 -04:00
Paul Beckingham
916b8641b3 Feature #415
- 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).
- Modified the 'next' report to only display a page, by default.
2010-06-20 17:32:11 -04:00
Paul Beckingham
2f85941d37 Typo
- Removed residual conflict marker.
2010-06-20 16:03:00 -04:00
Federico Hernandez
f3f4ae15eb Merge branch 'denotate' into 1.9.2 2010-06-20 21:03:36 +02:00
Federico Hernandez
5e53226eb8 Feature #408 - Allow deletion of annotations.
- Added new denotate command
- Added unit tests in denotate.t
- Change task.1 man page
2010-06-20 20:58:46 +02:00
Paul Beckingham
2c7552222a Feature #412
- 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 unit tests.
- Updated man pages.
2010-06-20 13:06:24 -04:00
Paul Beckingham
8572080677 Documentation
- With Charles permission, lifted an excellent description of task from
  a forum message to include in the main man page.  Thanks to T. Charles
  Yun.
2010-06-20 12:22:37 -04:00
Paul Beckingham
ba87499eca FF4
- Removed encodings for ',' -> '&comma;', ''' -> '&squot;', and
  ':' -> '&colon'.
- Retained decodings to provide backward compatibility.
2010-06-20 00:35:09 -04:00
Paul Beckingham
fbe24b3fda Unit Tests
- Added a vramsteg progress bar, which is only used if it is found
  in /usr/local/bin.
2010-06-20 00:31:55 -04:00
Paul Beckingham
5e55166617 Merge branch '1.9.2' of tasktools.org:task into 1.9.2 2010-06-15 08:31:08 -04:00
Paul Beckingham
bcd5524563 Bug #411 - projects command only lists those in use by pending tasks
- Fixed bug in man page that doesn't properly state the above (thanks
  to Dirk Deimeke).
2010-06-15 08:30:15 -04:00
Paul Beckingham
bb19361956 Feature #298 - Configurable recurring task count
- Added new recurrence.limit value (default 1) to control the number of
  future pending tasks generated from a recurring parent task.
- Added unit tests.
- Updated taskrc man page.
2010-06-13 12:45:41 -04:00
Paul Beckingham
78d092c588 Merge branch '1.9.2' of tasktools.org:task into 1.9.2 2010-06-11 20:21:58 -04:00
Paul Beckingham
3da3d3f99d Documentation
- Added FAQ about deleting an annotation.
2010-06-11 20:21:03 -04:00
Paul Beckingham
e2b240fd06 Minor doc edit
- Just to prove push is working.
2010-06-11 18:26:07 -04:00
Federico Hernandez
ee6ab69023 Removed X-2 versions from OS list in NEWS 2010-06-12 00:07:22 +02:00
Federico Hernandez
74e13670d0 Added msg to 'task show' when no config variables are matched 2010-06-08 23:13:38 +02:00
Federico Hernandez
d37c798dbc Enhancement - #407 show command
- finalized the implementation
- a searchstring can now be supplied to limit the display
  of configuration settings
2010-06-08 22:38:35 +02:00
Paul Beckingham
c93db168f3 Typo in comment in config file. 2010-06-08 08:29:57 -04:00
Federico Hernandez
52c029d4d9 Marked place in code with TODO for completion of enhancement #407.
(which was called #307 wrongly in commit 51e5a183)
2010-06-08 10:05:27 +02:00
Federico Hernandez
c9360ad9c4 Minor syntax error in task.1 2010-06-07 23:41:57 +02:00
Federico Hernandez
51e5a18384 Enhancement - #307 show command
- introduced new show command to display configuration settings
- config command is used to just set config values
- modified documentation
- modified some unit tests calling 'task config' to 'task show'
2010-06-07 23:35:58 +02:00
Federico Hernandez
f1368d6ac6 Added missing config variables to the big recognized string 2010-06-04 01:03:21 +02:00
Federico Hernandez
70e6f4f9f6 Enhancement - #390 timestamps in annotations
- added new dateformat for annotations
- documented prev. added format modifiers H, N and S
2010-06-04 00:57:42 +02:00
Federico Hernandez
2bfd220714 Missing include for Ubuntu. 2010-06-03 14:30:13 +02:00
Federico Hernandez
3214c1f02a Added information on bug fix #211 to ChangLog file. 2010-06-03 07:16:07 +02:00
Federico Hernandez
297f48a07c Bug Fix #211 - it was unclear which commands modify a task description
- rearranged commands on man page.
- new subsection for the "modifying" commands.
2010-06-03 06:57:33 +02:00
Paul Beckingham
ea067acb52 Enhancement - Hooks
- Implement task api calls for debug, header and footnote messages.
- Added unit tests.
2010-05-31 20:08:25 -04:00
Paul Beckingham
8a70b78d71 Unit Tests - cmd.t
- Fixed test of whether "export" is a read-only command.  There are now
  two export commands.
2010-05-31 16:45:21 -04:00
Paul Beckingham
e368043fb8 Enhancement - #363 export.ical
- Added feature #363 supporting iCalendar export via the 'export.ical'
  command.
- Updated documentation.
- Removed unnecessary localization of canonical command names.
2010-05-31 16:05:51 -04:00
Paul Beckingham
3ef6aa9f8e Enhancement - Date::toISO
- Added ISO date format support (19980119T070000Z) to Date class, for use
  in export.ical.
- Added unit test.
2010-05-31 13:18:41 -04:00
Paul Beckingham
8cd8c4753b Bug fix - #406
- Fixed bug #406 so that task now includes command aliases in the _commands
  helper command used by shell completion scripts.
2010-05-31 11:40:42 -04:00
Paul Beckingham
24085e0960 Enhancement - consistency checks
- Reintroduced disabled (no idea why) checks that ensure that shadow
  files weren't set up to clobber authoritative task files.
2010-05-30 17:03:42 -04:00
Paul Beckingham
d92e80e289 Enhancement - #36, #37
- Added features #36 and #37, providing annual versions of the 'history'
  and 'ghistory' command as 'history.annual' and 'ghistory.annual'.
- Uses new canonical names history.monthly, history.annual, ghistory.monthly
  and ghistory.annual, with aliases providing original history and ghistory
  commands.
- Updated man pages.
2010-05-30 17:01:38 -04:00
Paul Beckingham
fcbc8a2ee2 Enhancement - #326
- 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 log command to task.1 man page.
- Added log command to task-tutorial.5 man page.
- Added log command to help text.
- Added log command unit tests.
2010-05-30 15:20:12 -04:00
Paul Beckingham
336a4dea01 Bug Fix - Problem with #320
- The new auto-info command interfered with task modification.  Should
  have run all the unit tests before committing that change.
- Added auto-info command to the help text.
2010-05-30 15:03:58 -04:00
Paul Beckingham
67ffd07312 Enhancement - #320
- Added feature #320, so the command "task 123" is interpreted as an
  implicit "task info 123" command (thanks to John Florian).
- Modified task man page.
- Added unit tests.
- Updated supported platform lists with F13 and Ubuntu 10.04.
2010-05-30 13:20:39 -04:00
Federico Hernandez
b2ad305f23 Bumped version number to 1.9.2 2010-05-23 21:38:27 +02:00
Federico Hernandez
fa34f47f8a Packaging for ubuntu and fedora
- Updated packaging details for 1.9.1
2010-05-23 21:29:44 +02:00
Federico Hernandez
9a47e2b748 Added SHA1 of tagged release commit 2010-05-23 21:24:31 +02:00
Paul Beckingham
60d6cd62c8 Packaging for OSX
- Updated packaging details for 1.9.1
2010-05-23 11:03:56 -04:00
Federico Hernandez
60a99725b8 Release date for 1.9.1 2010-05-23 00:03:53 +02:00
Federico Hernandez
635c6432d4 Release date for 1.9.1 2010-05-23 00:03:05 +02:00
Paul Beckingham
eb1304ec41 Unit Tests - fix
- Fixed incorrect regex in hook format unit tests.  Note that this
  doesn't show up in the tinderbox, because that version of task is
  not built with Lua support.
2010-05-22 14:02:33 -04:00
Paul Beckingham
a5b57ec2ac Bug Fix - #395
- When a recurrence period is added to a pending task, the status should
  change from pending to recurring, and a mask attribute should be added.
  The lack of those changes meant that "task 1 recur:1w" did not do what
  was expected.  Thanks to T. Charles Yun.
2010-05-22 13:50:20 -04:00
Federico Hernandez
783225cd70 Typo fixes in ChangeLog 2010-05-13 21:19:18 +02:00
Paul Beckingham
804b6a8cdb Bug Fix - #401
- Fixed bug that ignored the search.case.sensitive configuration
  setting when filtering on project names (thank to John Florian).
2010-05-12 23:13:15 -04:00
Paul Beckingham
a31e9a5a3c Bug Fix - #404
- Refixed #404 that got lost in a recent merge.
2010-05-11 23:52:12 -04:00
Federico Hernandez
8553811889 Automatic computation of easter and related holidays for the calendar 2010-05-11 00:01:17 +02:00
Federico Hernandez
68ae9173ae Added documentation for 'include' to taskrc.5 2010-05-10 23:15:46 +02:00
Federico Hernandez
72763f2a2b Bug Fix
- wrong regexp in cal.t when matching '$month $year'
2010-05-10 21:59:10 +02:00
Paul Beckingham
89267846ca Bug Fix - #404 Compile error on current archlinux
- Applied patch sent by Johannes Schlatow to fix build on Arch Linux.
2010-05-09 18:30:12 -04:00
Paul Beckingham
38d82f6564 Bug Fix
- Deleting a task no longer clobbers any recorded end date (thanks to
  Seneca Cunningham).
2010-04-25 00:57:50 -04:00
Paul Beckingham
ac431ac5c9 Enhancement
- Applied patch from Cory Donnelly to provide default current date to the
  edit command, for new annotations.
2010-04-12 18:19:35 -04:00
Paul Beckingham
fa7ea5cad5 Holidays
- Removed Christmas Eve, which is not really a holiday.
2010-04-12 18:17:24 -04:00
Paul Beckingham
17069843d9 Documentation Update
- Added example of using DeMorgan's theorem when constructing multi-term filters
  to task-faq.5 (thanks to Rich Mintz).
2010-04-12 18:16:59 -04:00
Paul Beckingham
d6251142a2 Unit Tests
- Fixed unit tests that broke because the unit test script took more
  than one second to run.  Ordinarily is a test script does this:

    $ task add foo
    $ task list

  Then the age of the task is listed as '-', which means under one
  second.  But if the test does this:

    $ task add foo
    $ sleep 1
    $ task list

  Then the age is listed as '1 sec'.  Sometimes, as in these tests,
  the host may be just slow enough that the test script expects '-',
  but gets '1 sec'.
2010-04-04 10:00:01 -04:00
Paul Beckingham
a3a941fd92 Documentation
- Correct task-faq.5 so that the sequence \033 shows up properly when
  rendered by 'man', rather than 033.
2010-03-28 23:59:34 -04:00
Paul Beckingham
b6e9b84c80 Portability
- Applied patch from Emil Sköldberg.

Replace 'test ... == ...' with 'test ... = ...',
since [quoted from pkgsrc error message]:

The "test" command, as well as the "[" command, are not required to know
the "==" operator. Only a few implementations like bash and some
versions of ksh support it.

When you run "test foo == foo" on a platform that does not support the
"==" operator, the result will be "false" instead of "true". This can
lead to unexpected behavior.
2010-03-25 17:36:43 -04:00
Paul Beckingham
2791578410 Summary Report
- Made the summary bar colors configurable.
2010-03-25 17:33:43 -04:00
Federico Hernandez
d3628c04db Made easter algorithm static in Date 2010-03-23 02:51:31 +01:00
Federico Hernandez
10450963cb Eeaster algorithm 2010-03-23 02:13:35 +01:00
Paul Beckingham
fa8c33da45 Merge branch '1.9.1' of tasktools.org:task into 1.9.1
Conflicts:
	src/tests/record.t.cpp
2010-03-22 20:35:36 -04:00
Paul Beckingham
e8942d11ee Documentation Update
- Fixed typo.
2010-03-22 20:32:12 -04:00
Paul Beckingham
078e612de0 Unit Tests
- Test claimed to call Record::get_ulong, but was calling Record::get_int.
2010-03-22 20:31:37 -04:00
Federico Hernandez
70da455f1a From: Paul Beckingham <paul@beckingham.net>
Date: Sun, 28 Feb 2010 12:10:06 -0500
Subject: [PATCH] Enhancement - time support in the Date object.

- Added ability to parse and display time, using:
    h - single digit hour
    H - double digit hour
    N - double digit minutes
    S - double digit seconds
- Added a request for mktime() to automatically determine whether
  summer time should be considered.
- Added Date::Date (m, d, y, hr, mi, se) constructor.
- Added Date::sameHour comparison method.
- Added unit tests.
2010-03-22 23:56:45 +01:00
Paul Beckingham
e5f7e18d56 Enhancement - Hooks
- Implemented API calls: task_get_due, task_get_end, task_get_entry,
  task_get_start, task_get_until and task_get_wait.
- Implemented unit tests for API calls.
- Implemented new Record::get_ulong method.
- Implemented unit tests for get_ulong.
2010-03-01 20:53:44 -05:00
Paul Beckingham
98ebe8b7cc Build - with_lua
- Added code to dynamically run different configure scripts depending
  on the OS.
2010-03-01 18:17:14 -05:00
Paul Beckingham
6304ca7c1f Unit Tests - run_all
- Added better formatting of the results.
- Added a count of the skipped tests.
2010-03-01 18:16:29 -05:00
Paul Beckingham
f6ff18e31d Enhancement - Hooks
- Added many more format hooks.
- Added unit tests for all added hooks.
- Added unit tests for format-countdown and format-countdown_compact.
2010-03-01 18:14:06 -05:00
Paul Beckingham
dbf8def7db Unit Tests - record.t
- Cast to size_t to use a (pseudo) appropriate UnitTest::is method.
2010-02-14 12:58:59 -05:00
Paul Beckingham
df8eb7d5ef Unit Tests - record.t
- Fixed bug in unit tests that claimed to be calling Record::get_ulong,
  but was calling Record::get_int instead.  Silly error.
2010-03-14 11:23:15 -04:00
Federico Hernandez
485734e107 Removed space between minus and number in the countdown 2010-03-06 00:19:42 +01:00
Federico Hernandez
f4dc5c3674 Removed space between minus and number in the countdown 2010-03-05 23:47:01 +01:00
Paul Beckingham
95e420bb15 Build - Lua
- Modified the with_lua script to include Ubuntu 9.10 details.
2010-02-14 12:41:56 -05:00
Paul Beckingham
409c6ee9b9 Enhancement - .taskrc timestamp
- Added a "created by ..." entry with timestamp inside the generated
  .taskrc file.
2010-02-28 11:16:35 -05:00
Paul Beckingham
fa195a3cb2 Unit Tests - grid
- Corrected mix of signed and unsigned ints which confuse certain
  combinations of GCC and OS.
2010-02-23 20:38:59 -05:00
Paul Beckingham
cda959a658 Bug Fix - #382
- Changed from testing the ID to testing the sequence size.
2010-02-23 18:07:05 -05:00
Federico Hernandez
a5d8ef524e Bug Fix - #382 task annotate doesn't complain when a task id is omitted
- added error msg when annotating without a task id
2010-02-23 22:50:59 +01:00
Paul Beckingham
cb1b1510a9 Copyright
- Bumped year to 2010.
2010-02-23 01:06:45 -05:00
Paul Beckingham
3f2c68377c Merge branch 'unit-tests' into 1.9.1 2010-02-23 01:05:57 -05:00
Paul Beckingham
846d9bfd83 Merge branch 'config-highlight' into 1.9.1 2010-02-23 01:02:44 -05:00
Paul Beckingham
eac6c3fca9 Merge branch 'lua-test' into 1.9.1 2010-02-23 01:00:08 -05:00
Federico Hernandez
d082a6baad Bumped version number to 1.9.1 2010-02-23 00:21:56 +01:00
Federico Hernandez
251f8e5704 Added SHA1 of tagged release commit 2010-02-23 00:15:41 +01:00
Paul Beckingham
0282e2be28 Packaging - OSX
- Updated packaging files.
2010-02-22 16:12:17 -05:00
Federico Hernandez
dd758f8b33 Release 1.9.0
- Bumped version number to 1.9.0
- Added release date to ChangeLog
- Included Debian in NEWS
2010-02-22 09:46:01 +01:00
Paul Beckingham
8229a96252 Unit Tests - grid
- Added unit tests for Grid object.
2010-02-21 13:32:14 -05:00
John Florian
adf07a9af0 Enhancement - improved vim highlighting of .taskrc
- Added a few more new keywords to bring up to date with current feature set:
    + active.indicator
    + tag.indicator
    + recurrence.indicator
    + color.due.today
    + color.calendar.due.today
2010-02-20 14:21:29 -05:00
Paul Beckingham
be62157308 Documentation Update
- Improved wording in some of the FAQ entries.
2010-02-20 09:05:37 -05:00
Paul Beckingham
061639a370 Bug Fix - #380 Configuration values can no longer be commented out
- Added an explanatory comment to reinforce what is said in the taskrc.5
  man page, about how to deal with defaults, overrides and blanks.
2010-02-17 18:15:24 -05:00
Paul Beckingham
ad7abec3d7 Unit Tests - next.t
- Tests no longer assume that a set of added tasks will show an age
  of /-/, and now uses /(:?-|\d secs?)/.
2010-02-16 07:38:15 -05:00
Paul Beckingham
c34aeba5a4 Enhancement - config error highlights
- Configuration variables that are unrecognized are now highlighted
  in color, as well as being listed out.
2010-02-16 00:16:51 -05:00
Paul Beckingham
816f0533be Unit Tests - Lua
- Added -llua to src/tests/Makefile, to improve the quality of test results.
2010-02-16 00:05:19 -05:00
Paul Beckingham
e923282181 Portability - Haiku
- Added build notes for Haiku, requiring a 'setgcc gcc4' command.
- Modified directory code to accomodate Haiku's struct dirent
  anomalies (same as Solaris).
2010-02-15 23:55:03 -05:00
Paul Beckingham
6554e4d0f4 Packaging
- Latest changes for beta3 package on OSX.
2010-02-15 22:41:06 -05:00
Federico Hernandez
eb65dd42e4 Changes for beta3 2010-02-16 00:09:11 +01:00
Paul Beckingham
d917215417 Merge branch '1.9.0' of tasktools.org:task into 1.9.0 2010-02-15 11:12:30 -05:00
Paul Beckingham
69f2669bee Documentation Update
- Now includes a README.build file that helps troubleshoot problems
  with configure and make.
2010-02-15 11:08:40 -05:00
Federico Hernandez
dfc35f3744 Missing doc for color.due.today and countdown 2010-02-14 23:25:01 +01:00
Federico Hernandez
56dee6975e Fixed failing cal.t unit test due to color blending 2010-02-14 22:11:48 +01:00
Paul Beckingham
9b80017323 Portability - Solaris
- Added include of auto.h to allow #ifdef SOLARIS to work.
- Put #ifdef around glob arguments that aren't supported on Solaris.
- Fixed uninitialized variable that only gcc on Solaris spotted.
2010-02-12 20:58:56 -05:00
Paul Beckingham
75666c56cc Portability - Solaris
- Added a SOLARIS workaround for the lack of de_type member in struct dirent
  that other OSes have.
2010-02-12 01:35:20 -05:00
Paul Beckingham
0a3ee9f0a7 Portability
- Removed obsolete COLOR_* definitions from i18n.h that conflict on Cygwin.
2010-02-12 00:39:07 -05:00
Paul Beckingham
67546f8163 Configuration
- Allows rc.tag.indicator to replace the default + indicator.
- Allows rc.active.indicator to replace the default * indicator.
- Allows rc.recurrence.indicator to replace the default R indicator.
2010-02-11 23:50:55 -05:00
Paul Beckingham
22d99806d0 Build System - with_lua
- Added Cygwin 1.5, 1.7 commands.
2010-02-11 23:34:04 -05:00
Federico Hernandez
883e264319 2 new report columns
- countdown and countdown_compact
2010-02-12 03:01:03 +01:00
Federico Hernandez
e80769794e Added color blending to cal report 2010-02-12 01:15:19 +01:00
Federico Hernandez
4adfec4482 color.due.today and color.calendar.due.today
- tasks due on the current day ("today") can now be colorized with
  their own color.
- this is for reports and the calendar
2010-02-12 00:21:52 +01:00
Paul Beckingham
adb72ef023 Merge branch '1.9.0' of tasktools.org:task into 1.9.0 2010-02-10 23:45:26 -05:00
Paul Beckingham
69e0893c61 Build System
- Modified configure.ac to allow inclusion/exclusion of both ncurses
  and Lua.
- Also allows specification of include and lib directories for ncurses
  and Lua separately.
- This addresses a recent problem with Cygwin 1.7, where the most recent
  patches relocated ncurses from /usr/include to /usr/include/ncurses,
  and consequently broke task's default configuration, which was not
  very clever.
2010-02-10 18:16:46 -05:00
Federico Hernandez
10318fd19e Added Alexander to the AUTHORS file (as he has uploaded task into Debian) 2010-02-09 21:19:20 +01:00
Paul Beckingham
756200676d Packaging
- Modified task.pmdoc for 1.9.0
- Added README.txt and COPYING.txt files for installer to update script.
2010-02-08 22:48:50 -05:00
Paul Beckingham
73d8fb96cb Packaging
- Create 'update' script to handle the population of the tree used to
  create OSX packages.
- Cleaned out the old tree, because it can now be recreated at will.
2010-02-08 22:36:49 -05:00
Federico Hernandez
e9cbedd042 Fixing lintian warning when building deb package.
A man page row should not start with .taskrc as it is mis-interpreted
as groff macro.
2010-02-09 00:37:43 +01:00
Federico Hernandez
b22869f9ef Bumped version number to 1.9.0.beta2 2010-02-08 20:59:20 +01:00
Paul Beckingham
1a02cacc53 Enhancement - Hooks
- Implemented a few hooks.
- Implemented several Lua API calls.
- Unit tests for all hooks and API calls.
2010-02-07 00:22:02 -05:00
Paul Beckingham
cb952329d3 Documentation Update
- Added latest movie script.
2010-02-06 17:09:47 -05:00
Paul Beckingham
579ebe6130 Bug Fix - #372 Color blending/mapping broken
- Corrected problem in unit test that expected the wrong result.
- Fixed Color::Color (const std::string&) so that the foreground and
  background are now considered two different colors, are upgraded
  separately, if necessary, and then blended.  The problem affected
  all instances of "<256-color> on <16-color>".  Hooray for unit
  tests.
2010-02-06 16:59:22 -05:00
Paul Beckingham
89ae64c5fb Unit Tests - color
- Oddly, there were no unit tests for the Color object.  Now there are
  1,033.
- Three of these tests fail, which justifies adding them in the first place.
2010-02-06 15:40:44 -05:00
Paul Beckingham
ad9f318e10 Documentation Update
- Added task-color to the list of man pages referenced in several places.
2010-02-06 15:40:06 -05:00
Paul Beckingham
0e411cd646 Documentation Update
- Changed the default .taskrc file to have the color rules listed
  in their precedence order, along with a comment to that effect
  (thanks to John Florian)
2010-02-06 12:58:09 -05:00
Paul Beckingham
2b2795077b Bug Fix - #371 color.due clobbered by color.alternate
- 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).
2010-02-06 12:23:46 -05:00
Paul Beckingham
58910b07ef Unit Tests - hook.*.t
- Some hook tests were using the _version command, and assuming the
  version was \d.\d+.\d+, whereas it was '1.9.0.beta1'.
2010-02-05 18:40:05 -05:00
Paul Beckingham
5567b04277 Bug Fix - #370
- Task was preventing removal of due date from any task that had a due date,
  which is wrong.  It should be any task with a recur: value and a due date
  (thanks to John Florian).
2010-02-05 18:34:12 -05:00
Paul Beckingham
73d6e05c0e Bug Fix - #369 task config color.alternate does not take multiple args
- Fixed bug that meant these commands would not work:
    $ task config name 'one two three'
    $ task config name one two three
  (thanks to Richard Querin).
2010-02-05 18:22:36 -05:00
John Florian
0642c37c04 Documentation Update
- Indicate how to disable a color rule for which there is a built-in default.
- Added description for the new color.alternate configuration setting.
2010-02-03 21:17:30 -05:00
Paul Beckingham
45b66cd785 Merge branch '1.9.0' of tasktools.org:task into 1.9.0 2010-02-03 19:21:04 -05:00
Paul Beckingham
ed7c3fad57 Enhancement - Hooks
- Added more format hooks.
2010-02-03 19:20:45 -05:00
Paul Beckingham
fa37e002f0 Enhancement - Color
- Improved the labelling of colors in the color report.
2010-02-03 19:18:10 -05:00
Federico Hernandez
f99cd158dd Bumping to 1.9.0.beta1 2010-02-04 00:06:52 +01:00
John Florian
a790958daa Fix - vim syntax errors for taskrc
- calendar.details.report missing expected final '.'
- dateformat.holiday and dateformat.report not handled
- Updated header wasn't updated
2010-02-03 13:36:20 -05:00
John Florian
3341f74374 Enhancement - improved vim highlighting of .taskrc
- Added many new keywords to bring up to date with current feature set.
- Fixed incorrect highlighting of 'due' in report definitions.
2010-02-02 20:52:38 -05:00
Federico Hernandez
1505743fbf Merge branch 'master' into 1.9.0
Conflicts:
	package-config/osx/local/share/doc/task-1.8.5/COPYING
	package-config/osx/local/share/doc/task-1.8.5/README
2010-02-02 00:12:42 +01:00
Paul Beckingham
625ad3d7cf Merge branch '1.9.0' of tasktools.org:task into 1.9.0 2010-01-31 23:32:43 -05:00
Paul Beckingham
f351e17a63 Enhancement - Hooks
- Implemented all command hooks.
- Implemented several field hooks.
- Implemented several task hooks.
- Reorganized event validation code.
- Finalized Hooks -> API::call* mechanism.
- Implemented several hook unit tests.
- Corrected unit tests that didn't specify rc.hooks=on.
- Corrected builds that include Lua.
2010-01-31 23:29:22 -05:00
Federico Hernandez
c1360506c9 Note on task-tutorial 2010-01-31 23:33:36 +01:00
Paul Beckingham
50f27e0952 Merge branch 'special_tags' into 1.9.0
Conflicts:
	ChangeLog
	src/recur.cpp

- Implemented unit tests for the +nonag and +nocolor special tags.
2010-01-31 12:17:55 -05:00
Paul Beckingham
dd423d315b Enhancement - Hooks
- Implemented lots of command hooks.
2010-01-30 23:39:51 -05:00
Paul Beckingham
78c7408380 Build
- Added new theme files to the dist.
- Added new holiday files to the dist.
2010-01-30 21:16:47 -05:00
Paul Beckingham
d09a079199 Enhancement - Hooks
- Implemented a master switch rc.hooks=off that can shut off all
  hooks.  Seems like a good idea.
- Added support for 'hooks' and 'hook.*' as valid configuration
  entries.
2010-01-30 17:43:33 -05:00
Paul Beckingham
ea8b4beede Documentation Update
- Updated the taskrc.5 man page to match 1.9.0 functionality.
- Removed obsolete colorizeMessage code.
2010-01-30 16:08:42 -05:00
Paul Beckingham
30e8b03038 Enhancements - Hooks
- The config command now reports missing or unreadable hook scripts.
2010-01-30 13:34:25 -05:00
Paul Beckingham
79050c29d7 Enhancement - Hooks
- Added timing information for event trigger calls.
2010-01-30 13:25:25 -05:00
Paul Beckingham
98f4e22950 Enhancement - Hooks
- Started to make the 'with_lua' script multi-platform.
2010-01-30 12:53:53 -05:00
Paul Beckingham
47f5a45e47 Bug Fix - #368 Recur until date in task info table displays epoch seconds
- Fixed bug.
- Added unit tests to prevent recurrence.
2010-01-28 09:53:26 -05:00
Paul Beckingham
c37f36510a Documentation Update
- Added a couple of good questions to the task-faq man page.  One is
  a discussion of the ID number resequencing, which really should have
  been addressed in this way years ago.
2010-01-27 23:58:18 -05:00
Paul Beckingham
c65cb536cc Documentation Update
- Added description of the new search.case.sensitive configuration
  setting.
2010-01-27 23:36:44 -05:00
Paul Beckingham
4a8b356867 Documentation update - script-hooks.txt
- Included the script for the hooks movie.
2010-01-27 22:56:41 -05:00
Paul Beckingham
ea2d57edd3 Enhancements - Hooks
- Make the hooks unit tests pass if Lua support is not included.
  We don't like yellow in the tinderbox.
2010-01-27 22:54:40 -05:00
Paul Beckingham
585cbdfcac Merge branch 'hooks' into 1.9.0
Conflicts:
	src/command.cpp
	src/report.cpp
2010-01-27 22:46:20 -05:00
Paul Beckingham
572a833a51 Merge branch '1.9.0' of tasktools.org:task into 1.9.0 2010-01-27 16:53:41 -05:00
Paul Beckingham
b1700f3cf6 Enhancement - caseless compare
- Fixed bug detecting multiple failed negative attribute matches.
2010-01-27 16:52:54 -05:00
Paul Beckingham
4f1183a358 Enhancement - caseless compare
- Fixed bug in text.cpp:find that failed to locate a substring if it occurred
  at the end of the string.
2010-01-27 16:28:57 -05:00
Federico Hernandez
180d4ece77 Spelling... 2010-01-27 18:42:16 +01:00
Paul Beckingham
0c5a71b02f Enhancement - caseless substitution
- Substitutions "task <id> /from/to/" now obey the rc.search.case.sensitive
  setting.
2010-01-27 12:26:06 -05:00
Paul Beckingham
9cab749016 Enhancement - caseless find
- Fixed bug that didn't properly consider the starting offset in find.
2010-01-27 10:38:38 -05:00
Paul Beckingham
06ecef76d3 Enhancement - caseless find
- Added support for a starting offset.
2010-01-27 09:50:10 -05:00
Paul Beckingham
2dfe144236 Enhancement - caseless string compare, find
- Switched the sense of the Boolean parameter to match a more natural
  name in the .taskrc file.
2010-01-27 09:33:26 -05:00
Paul Beckingham
3e5ea8cb6c Enhancement - Caseless string compare, find
- Merged compare and find functions in from metatask.
- Merged unit tests in from metatask.
2010-01-27 09:12:06 -05:00
Federico Hernandez
56edf73d93 Wrong Pingstdagen in holidays-SE.rc 2010-01-25 22:51:34 +01:00
Federico Hernandez
2b63f781e9 Edited ChangeLog according to changes in 401f1b6496 2010-01-25 01:14:49 +01:00
Federico Hernandez
ccb6327131 Merge branch '1.9.0' of tasktools.org:task into 1.9.0 2010-01-25 01:09:43 +01:00
Federico Hernandez
401f1b6496 Holidays and dates
- improved dateformat handling now defaulting to YMD set via
  dateformat.holiday variable
- fixed missing sorting in holiday table output when running
  calendar.holidays=full
- renamed reportdateformat to dateformat.report
- added config file checking for calendar.holidays and calendar.details
- added 2 holiday files for SE and US (watertown, MA)
2010-01-25 01:06:15 +01:00
Paul Beckingham
48bf9d9f85 Bug Fix - #299 Can't use multiple project.hasnt:foo
- Fixed bug that prevented a filter from containing multiple references
  to the same attribute (thanks for John Florian).
- Added unit tests to verify.
2010-01-24 18:40:04 -05:00
Paul Beckingham
cc82823c47 Documentation Update - task-color.5
- Added the new task-color man page to the makefile, so it gets installed
  properly.
- Added the new man page in the ChangeLog file.
2010-01-24 17:48:49 -05:00
Paul Beckingham
383962173e Bug Fix - #360 Huh? "You cannot remove the recurrence from a recurring task. "
- The logic for detecting changes to a recurring task was wrong.
- Added unit tests for this bug.
2010-01-24 17:35:37 -05:00
Paul Beckingham
c8d208b9be Enhancement - Hooks
- Implemented pre-info-command, post-info-command hook.
2010-01-23 13:57:38 -05:00
Paul Beckingham
d6daa336ca Enhancement - Hooks
- Implemented pre-delete, post-delete events.
- Implemented pre-delete-command, post-delete-command events.
2010-01-23 13:43:50 -05:00
Paul Beckingham
b02374c3f5 Enhancement - Hooks
- Implemented pre-completed, post-completed events.
- Added debug info for event triggers.
- Removed support for pre-file-unlock, post-file-unlock, as they are
  called from TDB::~TDB in Context::~Context, which is after Hooks::~Hooks,
  which means segfault.
2010-01-23 13:12:49 -05:00
Paul Beckingham
03f7e0686f Enhancement - Hooks
- Implemented API::callTaskHook.
- Implemented Hook object inside Hooks.cpp, not Hooks.h.
- Implemented Hooks.setTaskId to provide context for task hooks.
- Implemented pre-tag, post-tag, pre-detag, post-detag
  events.
- Implemented pre-file-lock, post-file-lock, pre-file-unlock, post-file-unlock
  events.
2010-01-23 12:47:48 -05:00
Paul Beckingham
545013e839 Enhancement - config command
- Added validation of rc.annotations and rc.default.priority to the config
  command.
2010-01-23 00:12:34 -05:00
Federico Hernandez
4025488cf8 Updated ChangeLog and NEWS 2010-01-22 01:57:01 +01:00
Federico Hernandez
4ce2a1d071 Merge branch '1.9.0' of tasktools.org:task into helg 2010-01-22 01:45:33 +01:00
Federico Hernandez
a7244a999e Holidays
- added displaying of holidays in 'task cal'
  via calendar.holidays
- the legend in the calendar can now be turned off
- weeknumbers in the calendar can now be color-coded
2010-01-22 01:42:32 +01:00
Paul Beckingham
5b2cde4e30 Documentation - task-color.5
- Added new color tutorial man page.
2010-01-20 20:45:17 -05:00
Paul Beckingham
21d5607af2 Unit Tests - post-start, pre-exit
- Implemented unit tests for the post-start and pre-exit hooks.
2010-01-19 23:24:24 -05:00
Paul Beckingham
1cd6d4c7e7 Enhancement - Hooks
- Implemented pre-debug, post-debug.
- Implemented pre-header, post-header.
- Implemented pre-output, post-output.
- Implemented pre-footnote, post-footnote.
- Implemented pre-gc, post-gc.
- Implemented pre-undo, post-undo.
- Implemented pre-add-command, post-add-command.
2010-01-19 23:01:52 -05:00
Paul Beckingham
8540cab0a6 Enhancement - hooks
- Improved diagnostics of C++ side of the Lua API.
2010-01-19 22:19:40 -05:00
Federico Hernandez
e3c28f3fb3 Include statement for Linux 2010-01-20 00:31:41 +01:00
Paul Beckingham
f6f84aaf42 Tweak - default.command
- Trims whitespace off the default command that is reported via Context::header.
2010-01-19 18:04:47 -05:00
Paul Beckingham
b927d95d58 Merge branch '1.9.0' of tasktools.org:task into 1.9.0 2010-01-19 17:53:53 -05:00
Paul Beckingham
dd5623be65 Unit Tests
- Fixed tests that were broken when the config defaults changed.
2010-01-19 17:53:17 -05:00
Paul Beckingham
78063c4df7 Enhancement - Hooks
- Multiple hooks for the same event are now triggered, in the sequence
  they are found in .taskrc
- Program hooks can now cause task to exit.
2010-01-18 20:19:51 -05:00
Federico Hernandez
ab86490b37 Clean up annotation details
- changed variable name from annotation.details to annotations
- added report.X.annotations
- changed values from 2, 1, 0 to full, sparse, none
- made reportdateformat available in timesheet
2010-01-19 00:46:25 +01:00
Paul Beckingham
69cae7731f Enhancement - Hooks
- First fully functioning Lua hooks.  Woohoo.
2010-01-18 18:03:31 -05:00
Paul Beckingham
eeefc8a992 Color
- Removed coloring of only the due date, which is operating outside of
  the colorization rules.
- Removed commented out code.
2010-01-18 00:53:01 -05:00
Paul Beckingham
77e98c8c03 Enhancement - Hooks
- Improved the conditional compilation.
2010-01-17 23:41:02 -05:00
Federico Hernandez
fccd0d6c96 Report date format
Added report.X.dateformat which gives each report the possibility
to have a custom format for the due dates.
2010-01-18 03:45:49 +01:00
Federico Hernandez
4f70969306 Modification of the confirmation dialog for task config name value 2010-01-17 21:30:16 +01:00
Paul Beckingham
57e94585e8 Enhancement - Hooks
- Added Lua copyright notice to the version command.
- Added Lua copyright details to API.cpp, which is the only file that
  interacts with Lua.
- Added hook-type detection.
- Added a hook-type calling mechanism in Hooks.
- Implemented the post-start and pre-exit event triggers.
- Context::initialize now calls Hooks::initialize, which in turn calls
  API::initialize.  We have liftoff!
2010-01-17 14:24:40 -05:00
Paul Beckingham
c66d6b0500 Enhancement - Hooks
- Added bare bones autoconf changes to support Lua.
- Added API class from metatask.git.
- Added skeleton Hooks class.
- Added 'with_lua' helper script.
2010-01-17 01:12:28 -05:00
Paul Beckingham
31055360dc Merge branch '1.9.0' into hooks 2010-01-17 00:35:08 -05:00
Paul Beckingham
229a3d309c Feature - #296 Setting configuration variables in .taskrc
- Now supports 'task config name value', 'task config name ""', and
  'task config name' to directly modify the .taskrc file.
- Updated man page.
- Added unit tests.
- Modified existing config command to also display configuration
  variables that have no values.
2010-01-17 00:13:19 -05:00
Paul Beckingham
c82469fa2c Merge branch '1.9.0' of tasktools.org:task into 1.9.0 2010-01-16 17:47:22 -05:00
Paul Beckingham
5a886f6e58 Unit Tests
- Now sorts the results of a glob, so that the results are in a
  consistent order on all platforms.
2010-01-16 17:46:32 -05:00
Paul Beckingham
abffaa184b Enhancement - Path integration
- Obsoleted util.cpp spit, slurp calls
2010-01-16 17:45:45 -05:00
Federico Hernandez
70a0cd670b Merge branch '1.9.0' of tasktools.org:task into 1.9.0
Conflicts:
	src/Context.cpp
2010-01-16 23:45:07 +01:00
Federico Hernandez
720f28c09c Clean up in Context.cpp 2010-01-16 23:37:37 +01:00
Paul Beckingham
a8f03679ed Demo - color
- Preparing a script for a movie demonstrating color.
2010-01-16 16:05:28 -05:00
Paul Beckingham
0b67dfa38c Review - Config defaults
- Pass 1 of the review, identifying variables that may need to be
  changed.
2010-01-16 14:58:50 -05:00
Paul Beckingham
e53ba8110b Enhancement - Path integration
- Implemented Path::operator (std::string) const, to provide an
  automatic cast to std::string for any Path, File or Directory.
- Made use of new cast in various code.
- Changed use of spaces in atoi () calls.
- Switched from std::string::data () to std::string::c_str () calls.
2010-01-16 14:42:36 -05:00
Paul Beckingham
a6875ced6e Copyright etc
- Added Federico Hernandez to the task copyright, based on the amount
  of work and commits to the project, in the areas of Date handling and
  the calendar report.
- Bumped Cory Donnelly up to Contributing Author for the large quantity
  of ideas, suggestions and testing.
2010-01-16 13:51:11 -05:00
Paul Beckingham
57cac49362 Documentation Update
- Added more Qs the FAQ.
2010-01-16 12:26:59 -05:00
Paul Beckingham
81acaa6ae0 Enhancement
- Eliminated all unlink calls.
2010-01-16 10:35:18 -05:00
Paul Beckingham
b596e96b43 Enhancement - Path, File, Directory integration
- Replaced all access calls.
- Replaced all stat calls.
- Obsoleted util.cpp isAbsoluteDirectory calls.
- Obsoleted util.cpp expandPath calls.
2010-01-16 10:27:31 -05:00
Paul Beckingham
8e47342a18 Unit Tests
- Modified config.t.cpp according to the recent Config.cpp changes.
2010-01-15 22:04:41 -05:00
Paul Beckingham
cb821c2a25 Config - defaults
- Implemented replacement Config::get* methods.
- Replaced all calls throughout the code, with the new methods which
  have no static values as defaults.
2010-01-15 20:55:06 -05:00
Paul Beckingham
0faf7fa8ee Config - defaults
- Config is now providing a default set of all configuration variables.
- The default set is used to both initialize a Config object, and to
  create a sample .taskrc.
2010-01-15 02:50:46 -05:00
Paul Beckingham
0002376f2a Color Themes
- Better names.
2010-01-14 23:44:58 -05:00
Paul Beckingham
f87b2ee636 Color Themes
- Created the four basic themes, with no contents yet.  TBD.
2010-01-14 23:43:00 -05:00
Federico Hernandez
3aae7b180b Feature - #283 verbosity of annotations
- the configuration variable annotation.details now controls the
  verbosity of the output of annotations.
2010-01-14 00:03:52 +01:00
Federico Hernandez
b001c2f40b Merge branch '1.9.0' of tasktools.org:task into 1.9.0 2010-01-12 23:15:19 +01:00
Federico Hernandez
660d0cca3e Report date format
- added new reportdateformat to extend the formatting of due dates
  in the reports and "task info"
- added new conversion sequences a, A, b, B and Y to be used with
  reportdateformat
2010-01-12 23:12:22 +01:00
Paul Beckingham
db1a6601eb Merge branch '1.8.5' of tasktools.org:task into 1.8.5 2010-01-12 08:24:30 -05:00
Paul Beckingham
78778c2819 Packaging
- This is the structure that the OSX package requires.  Note that the
  task binary is 'represented' by an empty file.
- With more time, this could possibly be converted to a tree of symlinks,
  but I'm not sure whether PackageManager deals with them as expected.
2010-01-12 08:22:29 -05:00
Paul Beckingham
585020ef97 Documentation
- Added a few questions to the FAQ.
2010-01-12 08:16:06 -05:00
Paul Beckingham
e1f3f2355a Enhancement
- Added Path::is_absolute, and corresponding unit tests.
- Replaced expandPath and isAbsolutePath call in Config.cpp.
2010-01-12 01:30:59 -05:00
Paul Beckingham
c02cfd594c Path Integration
- Replaced calls to ::access
2010-01-12 01:18:55 -05:00
Paul Beckingham
5dbadda512 Build
- Removed duplicate entry.  Oops.
2010-01-12 01:16:59 -05:00
Paul Beckingham
c73376cb2f Build
- Removed obsolete files that will be replaced soon by the new OSX
  packaging currently on the 1.8.5 branch.
2010-01-12 01:06:29 -05:00
Paul Beckingham
0b5a105b9b Build
- Included the new scripts/vim/syntax/taskrc.vim file in the distribution
  (thanks to John Florian).
2010-01-12 00:58:55 -05:00
Federico Hernandez
e92fb9287a Man pages
- Bumped rest of man pages to same date as FAQ man page.
- Added name section to FAQ man page.
2010-01-10 21:42:34 +01:00
Paul Beckingham
875c5c1880 Build Error
- Fixed missing include.
2010-01-10 01:34:16 -05:00
Paul Beckingham
2b71317e09 Build Error
- Fixed build error on Ubuntu caused by using a Darwin-specific struct
  member.
2010-01-10 01:32:28 -05:00
Paul Beckingham
44aeea8e45 Hooks - starting...
- Tried to include an autoconf Lua detector.  Failed.  Waiting on mailing
  list response.
2010-01-10 01:11:38 -05:00
Paul Beckingham
f435eeed7a Documentation Update
- Changed the official code repo URL from github to tasktools.org.
  The github copy is going away.
- Added an FAQ about recreating a .taskrc, or creating a second one
  for comparison.
2010-01-09 21:30:23 -05:00
Paul Beckingham
a5cb041ef2 Code Reorganization
- Merged Path, File and Directory handling objects from metatask.git.
- Merged unit tests.
- These objects will replace a fair amount of code in task 1.9 and
  more in 2.0.
2010-01-09 17:48:32 -05:00
Paul Beckingham
bfdeee2cea Unit Tests - shell.t
- Began a set of unit tests for shell mode.  Needs work.
2010-01-09 15:17:44 -05:00
Paul Beckingham
414cdf8669 Documentation Update
- Added new 'task-faq' man page.
- Added references to the new man page in various places.
2010-01-09 11:01:06 -05:00
Paul Beckingham
3b52b75d2a Report - minimal
- Added a really minimal report.
2010-01-08 17:01:36 -05:00
Federico Hernandez
f56e1bef54 Minor cleanup. 2010-01-08 22:29:58 +01:00
Federico Hernandez
1b60c20bad Calendar coloring
- Now all due tasks are colorized.
- Setting due=0 now colorizes all due tasks in reports.
2010-01-08 16:49:18 +01:00
Federico Hernandez
7ef5233547 Calendar coloring
- Added 1 new color configuration variables to colorize weekend days
  in the calendar: 'calendar.color.weekend'.
- Changed the default colors in the calendar.
2010-01-08 16:21:27 +01:00
Federico Hernandez
d552b208dd Calendar coloring
- Added 3 new color configuration variables to colorize today, days with due tasks
  and days with overdue tasks in the calendar:
  'calendar.color.today', 'color.calendar.due' and 'calendar.calendar.overdue'
2010-01-08 12:23:26 +01:00
Federico Hernandez
6dd00f41e9 Calendar details
- added 2 new configuration variables 'calendar.details' and
   'calendar.details.report' that make it possible to display
   details of task with due date when doing 'task cal'
2010-01-08 00:15:00 +01:00
Paul Beckingham
a75e7978ab Color Command
- Added support for displaying color samples.  If you run the command
  'task color red on grey12' then task will show you a sample of this
  color, along with other examples.  This is helpful if you are trying
  to choose colors for auto colorization rules.
2010-01-03 12:35:53 -05:00
Paul Beckingham
6abc40ef46 Documentation Update
- Edited and improved the task tutorial, with mention of --, and tips
  on tricking task into allowing special arguments into the description.
2010-01-03 11:36:02 -05:00
Paul Beckingham
0ab2169c65 Documentation Update
- Added a task-tutorial man page mention to the help and version command.
- Corrected comment about attribute entity encoding/decoding.
2010-01-02 22:35:56 -05:00
Federico Hernandez
93067f3c3b Fixed floating point arithmetic when type casting.
See http://stackoverflow.com/questions/1989708/type-casting-with-printf-statements-under-mac-osx-and-linux
2010-01-01 23:58:15 +01:00
Federico Hernandez
8d8f7ddb40 Fixed 2 unit tests that behaved wrong at the end/beginning of a year. 2010-01-01 22:11:10 +01:00
Federico Hernandez
be75b4bf3a Fixed 2 unit tests that behaved wrong at the end/beginning of a year. 2010-01-01 22:05:08 +01:00
Paul Beckingham
3031cf8da9 Merge branch '1.9.0' of tasktools.org:task into 1.9.0 2009-12-31 13:02:03 -05:00
Paul Beckingham
db707d5e15 Feature - new field 'priority_long'
- The new 'priority_long' field can be shown in custom reports, and will
  display 'High' rather than the abbreviated 'H'.
- Unit tests.
2009-12-31 12:57:03 -05:00
Federico Hernandez
065384027e Added ChangeLog entry for new 'config' command. 2009-12-29 21:48:12 +01:00
Federico Hernandez
dca4772f33 New command config
- version now only displays the version number and copyright notice
- config displays the task configuration that version used to show
- configuration variable longversion is not longer needed
2009-12-29 02:46:16 +01:00
Federico Hernandez
48daf13d7f Copyright
- Updated the copyright notices to 2010, for the 1.9.0 release.
- added "unmaintained" comment to zsh completion script asking for
  contributions
2009-12-28 21:37:55 +01:00
Paul Beckingham
79113668cd Feature - color rules for partial project names
- The color.project.foo colorization rules now matches on partial
  project names (like foobar), matching the functionality of filters.
2009-12-27 13:46:55 -05:00
Paul Beckingham
167b9aa8eb Documentation Update
- Reorganized entries in ChangeLog.
- Added missing rc.name= feature description.
2009-12-27 13:43:50 -05:00
Paul Beckingham
9ce55bcf67 Copyright
- Updated the copyright notices to 2010, for the 1.9.0 release.
2009-12-27 12:39:42 -05:00
Paul Beckingham
6cfb913e45 Unit Tests - benchmark2.t
- Gathers timing for runs of the list report for 1, 10, 100 and 1000
  tasks.  This will create a history of data in the tinderbox runs
  for later analysis.
2009-12-27 10:14:45 -05:00
Paul Beckingham
5ef3bcc243 Unit Tests - benchmark2
- Fixed Timer class to use a fixed precision, that for some reason,
  does not work on Haiku.  Put a conditional compile around it for
  now - perhaps later Haiku alpha releases will change things?
- Added benchmark2.t, which enables high-resolution timers for a
  single 'list' command, with 10, 100 and 1000 task databases. Then
  it emits readily-found and parsed data for charts.
- Eliminated obsolete benchmark data for hardware I no longer own.
2009-12-26 19:44:52 -05:00
Paul Beckingham
f43e093515 Unit Tests - util.t
- Added unit tests to make sure formatSeconds is doing the right thing.
  It isn't, and it needs to change, but at least now we can see what is
  wrong with it.
2009-12-22 13:36:47 -05:00
Federico Hernandez
ecb4190e0b Added unknown OS clause for the version command output 2009-12-22 01:03:24 +01:00
Federico Hernandez
338e4dfbc7 basic.t
- check version number against configure.ac
- added test for _version command
2009-12-22 00:18:26 +01:00
Paul Beckingham
1046555c9c Unit Tests - abbreviation.t, basic.t
- Fixed broken unit tests that relied on the string 'ABSOLUTELY NO
  WARRANTY' being present in the output of the version command.  The
  tests now rely upon 'GNU General Public License' instead.
2009-12-20 10:51:51 -05:00
Paul Beckingham
b8377b7e5c Feature - version command
- Added FreeBSD as a recognized operating system.
2009-12-20 10:51:03 -05:00
Paul Beckingham
2a8acaf351 Feature - version command
- Rearranged output of the version command.
- Added build information (OS) and packages (ncurses ...).
2009-12-18 22:31:54 -05:00
Paul Beckingham
2ec5a315cb Feature - simple version report for scripts
- Added a simple _version command that displays only the version
  number and a newline.  This makes it easier for external task support
  scripts to determine which version of task is installed - easier than
  parsing the version command output.
2009-12-18 21:41:48 -05:00
Paul Beckingham
be86c52dc0 Bug Fix - typo
- Typo in message after prepend has finished.
2009-12-16 22:03:35 -05:00
Paul Beckingham
2cf25b7c35 Code Cleanup
- Used the shorter form of std::string::substr that defaults the second
  argument to std::string::npos.
2009-12-13 16:59:28 -05:00
Paul Beckingham
75e738a9c9 Unit Tests - list.t
- Added listIntersect and a Boolean listDiff implementation in main.h.
- Added a set of unit tests for the above.
2009-12-13 12:30:49 -05:00
Paul Beckingham
42981c746e Completion Script - zsh
- With P.C. Shyamshankar's blessing, updated the _task script for zsh
  by using the new task built-in _commands command to enumerate all
  supported commands.  This replaces code that forces task usage output,
  and parses it for commands.
- Note that _task for zsh lacks attribute completion.  We need a zsh
  developer to make this enhancement.
2009-12-13 10:03:59 -05:00
Paul Beckingham
5a66ac94ee Bug Fix - unit tests util.t
- Algorithm uses different numbers to represent a year in the same
  condition.  Bad.
2009-12-12 11:41:47 -05:00
Paul Beckingham
eaeca45eae Bug Fix - broken unit tests on Ubuntu
- Fixed util.cpp formatSeconds and formatSecondsCompact, that were using
  an algorithm that accentuated rounding errors.
- Fixed unit tests that were expecting wrong answers from the wrong
  algorithm above.
2009-12-12 11:30:20 -05:00
Paul Beckingham
37411c7521 Documentation Update - Config
- Updated the generated config file to include examples of the new
  report columns.
2009-12-11 20:44:44 -05:00
Paul Beckingham
4ea71c939a Enhancement - New columns for custom reports
- Added 'entry_time', 'start_time' and 'end_time' columns that include
  the time as well as the date.
2009-12-11 19:08:45 -05:00
John Florian
81ce844d79 Feature - #307 vim support for taskrc
- Added support for syntax highlighting of taskrc within vim.
2009-12-10 18:39:24 -05:00
Paul Beckingham
0780919c2e Feature - #352 rc file should support includes
- Added include file support to Config.cpp.
- Implemented isAbsolutePath helper.
- Added unit tests for isAbsolutePath.
- Fixed small bug in bug.bulk.t.
- Added TODO items to config.t.cpp.
2009-12-09 17:21:09 -05:00
Paul Beckingham
8d43a35ca4 Unit Tests - util.t
- Added unit tests for formatSeconds and formatSecondsCompact.
- Fixed small boundary but in formatSeconds.
2009-12-09 17:12:50 -05:00
Paul Beckingham
42c1b30c31 Feature - Config validation
- The 'version' command now complains about use of deprecated color names and
  duplicate entries.
- Unit tests verify duplicate detection.
- Unit tests verify deprecated color detection.
- Most validation code moved from command.cpp to Config.cpp.
2009-12-08 22:56:01 -05:00
Federico Hernandez
b032a00283 Merge branch '1.9.0' of tasktools.org:task into 1.9.0 2009-12-09 01:16:18 +01:00
Federico Hernandez
b684ded845 Bug #347 - Confirmation dialog is lowercase for "all"
- changed confirmation to be now "All" for multiple changes
- added unit tests for all answers to multiple changes
2009-12-09 01:15:31 +01:00
Federico Hernandez
780d9bb7e7 Bug #347 - Confirmation dialog is lowercase for "all"
- changed confirmation to be now "All" for multiple changes
- added unit tests for all answers to multiple changes
2009-12-09 01:11:14 +01:00
Paul Beckingham
7acef0c9fd Enhancement - related to, but not fixing bug #293
- 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 unit tests for the text.cpp functions.
- Added unit tests including the new modifiers in filters.
- Added unit tests to parse the new modifiers.
- Modified man page.
- Modified the Context::autoFilter processing to use the new modifiers for
  +tag and -tag filtering.
- Added a support email to an error message, while looking at the filter code.
- Added new modifiers to the help report.
- Modified a utf8.t unit test to include an alphanumeric tag, rather than a
  smiley face.
2009-12-07 01:35:47 -05:00
Paul Beckingham
d019126086 Documentation Update
- Included sample maximal taskrc for inclusion as the auto-generated
  .taskrc.  It will be complete, self-documenting, and nicely formatted.
2009-12-06 20:21:22 -05:00
Paul Beckingham
a7feed2ae9 Documentation Update - NEWS
- Cleared out 1.8 NEWS items, added 1.9 items.
- Mentioned 256 color support
- Mentioned Richard Querin's alternate line coloration feature
2009-12-06 13:41:47 -05:00
Paul Beckingham
64c643920f Feature - Special tags
- Implemented the 'nonag' tag that prevents nag messages for a task.
2009-12-06 11:54:23 -05:00
Paul Beckingham
2c5f590fed Feature - Special tags
- Implemented the 'nocolor' special tag.
2009-12-06 11:48:09 -05:00
Paul Beckingham
3003cdaf08 Code Cleanup
- Clarified autoComplete special case comment.
2009-12-06 11:40:19 -05:00
Paul Beckingham
5f353f800d Unit Tests - cal.t
- Fixed a broken fix (e7c8114dff) for
  the calendar command - previously if task could find no tasks with
  due dates, no calendar was displayed, and an error message shown.
  That broken fix was only on the 1.9.0 branch and never released.
  The correct behavior is to show a line of months.  This bug broke
  15 unit tests.
- Fixed minor problem in unit tests where the output was not captured,
  although this has no bearing on the results.
2009-12-06 11:30:51 -05:00
Federico Hernandez
f3d31834ee Merge branch 'master' into 1.9.0
due to release of 1.8.5

Conflicts:
	ChangeLog
	configure.ac
	doc/man/task-tutorial.5
	doc/man/task.1
	doc/man/taskrc.5
	src/Config.cpp
	src/rules.cpp
2009-12-06 04:30:56 +01:00
Federico Hernandez
28377502f6 Added SHA1 of taged release commit 2009-12-06 04:14:40 +01:00
Federico Hernandez
a6c7236ff3 Release date for 1.8.5 2009-12-06 01:49:05 +01:00
Paul Beckingham
204d287b20 Feature - #341 man pages
- 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).

Signed-off-by: Federico Hernandez <ultrafredde@gmail.com>
2009-12-05 22:49:30 +01:00
Paul Beckingham
6fc34eef42 Merge branch '1.9.0' of tasktools.org:task into 1.9.0 2009-12-05 13:43:47 -05:00
Paul Beckingham
e99c01c92c Enhancement - deprecated color
- Improved the warning about deprecated color usage to include actual
  examples from .taskrc.
2009-12-05 13:43:00 -05:00
Paul Beckingham
b3e3c36d50 Documentation Update
- Added missing ChangeLog entry for #310.
2009-12-05 12:46:29 -05:00
Paul Beckingham
e717345f20 Feature - #310 'task add' with external editor
- Simplified and make clearer and error message that complained about
  things that were beyond user control (thanks to John Florian).
(cherry picked from commit a2152628251c6d8c9bc840b8f36851f4ce680c99)

Signed-off-by: Paul Beckingham <paul@beckingham.net>
2009-12-05 12:23:32 -05:00
Paul Beckingham
850135376d Feature - #341 man pages
- 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).
2009-12-05 11:24:05 -05:00
Paul Beckingham
5d0e6c3435 Feature - #336 prepend command
- Added feature #336 which gives task a 'prepend' command for symmetry
  with the 'append' command.
2009-12-04 22:47:44 -05:00
Federico Hernandez
3b354b6d47 Bug Fix - #332 output field "recur_ind" not valid?
- changed man page to include the correct fields
2009-12-02 21:41:20 +01:00
Paul Beckingham
2c0da35225 Bug Fix - #319 Removing tag from many tasks, incorrect change summary
- Fixed bug 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).
2009-12-02 00:14:17 -05:00
Paul Beckingham
13955bc6ae Unit Tests - text.t
- Added more unit tests to cover the new split_minimal function.
2009-12-01 23:41:44 -05:00
Paul Beckingham
1d80a2ebdc Unit Tests - default.t
- The fix to bug #322 means the way default commands are specified
  is now a little different.  If the command "task rc:x" is run, the
  default command no longer needs to also include "rc:x".
2009-12-01 23:29:01 -05:00
Paul Beckingham
d4910f65eb Bug Fix - #332 output field "recur_ind" not valid?
- 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).
- Added ChangeLog entry for the #333 fix.
2009-12-01 22:12:59 -05:00
Federico Hernandez
2b44d513e8 Added unit tests for bug fix #333 2009-12-02 00:28:34 +01:00
Federico Hernandez
7f11f1b560 Bug Fix - #333 duplicate command should display the ID of the created task
- Added missing "Created task" output to duplicate command (thanks to
  Cory Donnelly).
2009-12-01 23:00:40 +01:00
Paul Beckingham
b246fae889 Unit Tests - fixing broken tests
- The split tests are all broken after a recent change.  They need
  to be extended to accommodate the new split_minimal functions.
2009-11-29 22:41:55 -05:00
Federico Hernandez
8c5508de4b Merge branch '1.8.5' of tasktools.org:task into 1.8.5 2009-11-30 00:16:40 +01:00
Federico Hernandez
b3db2245fa Updated OS that task runs on 2009-11-30 00:16:10 +01:00
Paul Beckingham
00b246ce8a Bug Fix - shell mode
- Removed redundant messages when exiting shell mode.
2009-11-29 16:17:26 -05:00
Paul Beckingham
b94706c56e Bug Fix - #322 rc: override for shell command does not propagate
- Fixed bug #322 which failed to propagate rc overrides to shell commands.
- Context now properly records overrides to file and variables.
- The text.cpp:split (...) functions can now skip trivial split results.
2009-11-29 14:23:22 -05:00
Paul Beckingham
8d784da0ae Bug Fix = #317, sorting
- 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.
2009-11-29 08:21:33 -05:00
Paul Beckingham
b5f65850f8 Bug Fix - #327 Deleting due date on recurring task wraps to 1969
- Task now prevents removal of either a due date or a recurrence
  from a recurring task.
2009-11-28 09:53:15 -05:00
Paul Beckingham
b7726bce21 Bug Fix - #329 task shell convert all characters to lowercase
- Fixed bug that inadvertently converted the entire command line to
  lower case in the shell, rather than just the command, for testing
  against the "quit" string (thanks to Juergen Daubert).
2009-11-26 09:41:47 -05:00
Paul Beckingham
d44e9363f0 Enhancement - better confirmation
- Added feature to allow the user to quit when asked to confirm multiple
  changes.  Now task asks "Proceed with change? (Yes/no/all/quit)".
2009-11-21 17:39:50 -05:00
Paul Beckingham
5e905742ad Bug Fix - #317, timesheet report
- 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.
2009-11-18 20:29:45 -05:00
Paul Beckingham
549e700bc8 Bug Fix - timesheet
- The timesheet report was being sorted as though the 'end' date was
  not being considered a date, but simply a string.
2009-11-18 20:28:25 -05:00
Paul Beckingham
b2fc4969b9 Documentation Update
- Minor doc edits.
2009-11-18 20:27:54 -05:00
Federico Hernandez
e319359935 Merge branch 'master' into 1.9.0
Conflicts:
	AUTHORS
	ChangeLog
	configure.ac
	doc/man/task-tutorial.5
	doc/man/task.1
	doc/man/taskrc.5
2009-11-18 10:44:35 +01:00
Federico Hernandez
331b08055a Bumped version number to 1.8.5 2009-11-18 10:22:33 +01:00
Federico Hernandez
847a8b6d49 Added SHA1 of taged release commit 2009-11-18 09:56:14 +01:00
Paul Beckingham
3abce22f0c Bug Fix - color
- Fixed bug that failed to upgrade from 16- to 256-color mode when
  a color like "black on rgb003" was parsed.
2009-11-18 00:36:57 -05:00
Paul Beckingham
c090367eb8 Enhancement - warns on deprecated color use
- If a color is specified using the deprecated 'on_red' instead of
  'on red', generate a warning in the version report.  The version
  report is becoming a report where .taskrc sanity checks occur.
  Is this good?
2009-11-17 23:56:21 -05:00
Paul Beckingham
fff789a509 Bug Fix - #316 timesheet report oddly sorted
- Fixed bug #316 which caused the timesheet report to display an
  oddly sorted list.  Mistakenly used 'std::cout << ...' instead of
  'out << ...'
2009-11-17 22:55:29 -05:00
Paul Beckingham
e7c8114dff Bug Fix - calendar
- Fixed bug that showed a calendar for the year 2037 when 'task calendar due'
  was run, and there are no tasks with due dates.
2009-11-17 22:41:55 -05:00
Paul Beckingham
fbb217538e Code Cleanup
- Removed unnecessary use of the scope resolution operator.
2009-11-17 22:34:28 -05:00
Federico Hernandez
12c4983936 Release date for 1.8.4 2009-11-17 12:00:36 +01:00
Paul Beckingham
39d9f235de HACK - case-insensitive file system problem again. 2009-11-16 23:42:32 -05:00
Paul Beckingham
7aa0c3698a HACK - case-insensitive file system problem again. 2009-11-16 23:42:00 -05:00
Paul Beckingham
bc40ab63b3 Bug Fix - #312 Changing one task changes another
- Added a warning 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).
2009-11-16 23:24:47 -05:00
Paul Beckingham
6e673d2834 Bug Fix - #313 Edit command fails when data.location includes spaces
- Applied patch from Cory Donnelly.
2009-11-16 22:10:47 -05:00
Federico Hernandez
30c6dd0047 Added Joe to AUTHORS file 2009-11-13 23:32:40 +01:00
Paul Beckingham
64bc2a165a Bug fix - hang on cygwin when task updated.
- Fixed bug that caused a hang on cygwin, when a task with multiple
  annotations was edited (thanks to Joe Pulliam).
2009-11-09 22:35:51 -05:00
Paul Beckingham
5b96dbbce8 Bug Fix - wait date editing
- The "wait" date was not being properly formatted, as are all the other
  dates, in the "edit" command.  The result is that an epoch integer date
  was rendered, instead of something readable and in the preferred format.
2009-11-09 18:19:04 -05:00
Paul Beckingham
3214dc5d37 Merge branch '1.9.0' of tasktools.org:task into 1.9.0 2009-11-08 12:54:24 -05:00
Paul Beckingham
bb89e1a70f Unit Tests - annotate.t
- Fixed bug in annotate.t, where a custom report named 'r' was used
  in the unit tests.  This name had to be lengthened to 'rrr' to avoid
  conflict with the 'recurring' report.  This, in itself, is a different
  bug.
2009-11-08 12:51:57 -05:00
Federico Hernandez
a16122bbe9 Fixed regexp matching for colorcoded duedates in unit test 2009-11-06 23:03:47 +01:00
Federico Hernandez
57ef35441d Fixed bug in regexp matching of whitespace between month and year. 2009-11-05 21:37:47 +01:00
Federico Hernandez
77dd930574 Fixed bug in regexp matching of whitespace between month and year. 2009-11-05 21:36:46 +01:00
Paul Beckingham
e222090d1f Feature - default alias
- Added a default alias of "rm" as a synonym of "delete" (thanks to
  Ivo Jimenez).
2009-11-05 01:08:54 -05:00
Federico Hernandez
bf077c0f97 Merge branch 'master' (1.8.3) into 1.9.0
Conflicts which were fixed:
	ChangeLog
	configure.ac
	doc/man/task-tutorial.5
	doc/man/task.1
	doc/man/taskrc.5
	src/report.cpp
2009-10-22 22:55:01 +02:00
Federico Hernandez
f6842941f3 Bumped version number to 1.8.4 2009-10-22 22:40:18 +02:00
Federico Hernandez
e2e0851a69 Merge branch '1.8.3' 2009-10-22 22:27:21 +02:00
Federico Hernandez
1299fe468b Added sha1 for 1.8.3 to Changelog 2009-10-22 22:09:53 +02:00
Federico Hernandez
de50b2902c Merge branch '1.8.3' 2009-10-22 22:02:32 +02:00
Federico Hernandez
bcdcbeeea0 Preparing release
- Updating dist documentation
- Release date in man pages
2009-10-21 22:53:26 +02:00
Pietro Cerutti
469cafa053 Make run_all more portable.
- Changed shebang for portability
- Fix date command for FreeBSD

Signed-off-by: Federico Hernandez <ultrafredde@gmail.com>
2009-10-21 22:20:32 +02:00
Pietro Cerutti
fdb359c180 Fix confirm() to handle EOF
Signed-off-by: Federico Hernandez <ultrafredde@gmail.com>
2009-10-21 22:19:37 +02:00
Paul Beckingham
d321ee242d Bug Fix - Layout on color report
- Fixed layout to include a \n between basic colors and effects.
2009-10-13 11:30:13 -04:00
Paul Beckingham
9f9c19d4ae Unit Tests - fix
- The unit tests for color were still linking against color.o, instead
  of the new Color.o.  Subtle, but wrong.
2009-10-11 16:17:26 -04:00
Paul Beckingham
179b51278f Bug Fix - Color endianness
- Fixed "bug" that caused "red on black" to be emitted as ^[[40;31m
  instead of the expected ^[[31;40m, which is what the unit tests are
  looking for.
2009-10-11 11:49:35 -04:00
Paul Beckingham
1bb907f76d Unit tests - rc.t
- Added tests for the new rc.name=value form, in addition to the
  existing rc.name:value form.
2009-10-10 11:18:38 -04:00
Paul Beckingham
99641e7b0b Enhancement - rc.name=value
- Task now supports both "rc.name:value" and "rc.name=value", not because
  this is generally a good idea, but because it is a very common mistake
  that we are all making, and shouldn't the software be forgiving in an
  unambiguous case like this?
2009-10-10 11:15:32 -04:00
Paul Beckingham
d7bded0d73 Enhancement - Color::colorize
- Made Color::colorize (const std::string&, const std::string&) static,
  so that it is now simple to colorize a string:

      std::cout << Color::colorize ("text", "red");

- Added sample foreground and background colors to the "color" command,
  and used the above shortcut to simplify handleOnColor.
2009-10-10 10:55:48 -04:00
Paul Beckingham
80a3196097 Bug Fix - color.alternate ignoring color/forcecolor overrides
- Fixed bug that caused the alternate line coloration to ignore whether
  color was enabled or not.  This (once again) added color codes to the
  shadow file.  This happens repeatedly - I think a unit test for this
  mistake is needed.
2009-10-06 10:12:07 -04:00
Paul Beckingham
010ef7cd07 Bug Fix - Color::Color (color_id, color_id)
- Removed temporary fix from task code to accommodate above bug.
2009-10-06 00:20:50 -04:00
Paul Beckingham
e5fce9ac08 Bug Fix - missing color
- There's something wrong with Color::Color (int, int), so this is a
  temporary fix.
2009-10-05 23:53:28 -04:00
Paul Beckingham
175dd3eb4f Feature - #292 Alternate line coloration
- Implemented alternate line coloration, triggered by the 'color.alternate'
  configuration variable.
2009-10-05 22:09:19 -04:00
Paul Beckingham
3cd45c3acd Feature - 256 color support
- Inverted the _COLOR_NOFG to be _COLOR_HASFG, for better readability and
  the added benefit of having newly constructed color with no specification
  having a value of 0.
2009-10-04 09:55:06 -04:00
Paul Beckingham
157b32e93b Documentation Update
- Tweaked the output of the "color" command.
2009-10-03 16:03:32 -04:00
Paul Beckingham
0b187f3ff8 Feature - 256-color support
- Improved blending algorithm.
- Added 16- to 256-color upgrade algorithm.
2009-09-27 22:58:40 -04:00
Paul Beckingham
b3d40b2554 Portability - Haiku R1/alpha1
- Added necessary include files and edits in order to build task on
  Haiku R1/alpha1.
2009-09-27 17:02:20 -04:00
Paul Beckingham
bb2eb5f266 Feature - 256-color support
- Added precautionary bit reset for bold and bright in 256-color mode.
  Not sure if it is important, but it's cleaner.
2009-09-23 23:26:39 -04:00
Paul Beckingham
675df6487a Feature - 256-color support
- Added the colorN variants to the rgbRGB and grayN labels.
2009-09-23 23:21:46 -04:00
Paul Beckingham
b2b4fc6b54 Feature - 256-color support
- Implemented new "task color" command to showcase 256-color support.
2009-09-23 23:12:07 -04:00
Paul Beckingham
2074c8bb27 Feature - 256-color support
- Fixed bug that caused \033[m sequences to be emitted when no color
  is specified, in 16-color mode.
2009-09-22 21:36:36 -04:00
Paul Beckingham
ff3b7cf337 Feature - 256-color support
- Integrated new Color object into task.
- Debugging needed - the cyan, green, and yellow colors are mixed up!
2009-09-22 17:01:59 -04:00
Paul Beckingham
58730a48b3 Feature - 256-color support
- Eliminated old color implementation.
- Integration, debugging remains.
2009-09-22 16:42:46 -04:00
Paul Beckingham
37436071a0 Feature - 256-color support
- Added new Color object.
2009-09-22 12:10:13 -04:00
Paul Beckingham
de8a2c36a0 Feature - 256-color support
- Temporary reorganization of files to prepare for a case change in
  from color.* -> Color.* on a Mac.
2009-09-22 12:07:56 -04:00
Federico Hernandez
1d4c942675 Bumped version number to 1.9.0 2009-09-07 16:25:40 +02:00
Federico Hernandez
fba076a0d0 Bumped version number to 1.8.3 2009-09-07 16:13:37 +02:00
Federico Hernandez
09d7940dd3 Revert "Bumping version number to 1.8.3"
This reverts commit 00031dc1ab.
2009-09-07 16:04:24 +02:00
Federico Hernandez
00031dc1ab Bumping version number to 1.8.3 2009-09-07 15:52:51 +02:00
Paul Beckingham
3ef844de5f Packaging
- Adding updated package files for OSX, from the 1.8.2 release.
2009-09-07 09:51:20 -04:00
Federico Hernandez
bb45d91ddb Added sha1 of 1.8.2 to ChangLog 2009-09-07 15:41:51 +02:00
307 changed files with 22982 additions and 6142 deletions

1
.gitignore vendored
View File

@@ -16,3 +16,4 @@ src/tests/all.log
src/tests/*.data
*~
.*.swp
package-config/osx/binary/task

16
AUTHORS
View File

@@ -3,6 +3,7 @@ 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,6 +19,12 @@ The following submitted code, packages or analysis, and deserve special thanks:
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
@@ -26,7 +33,6 @@ Thanks to the following, who submitted detailed bug reports and excellent sugges
Thomas Engel
Nishiishii
galvanizd
Stas Antons
Vincent Fleuranceau
ArchiMark
Carlos Yoder
@@ -39,3 +45,11 @@ Thanks to the following, who submitted detailed bug reports and excellent sugges
Thomas@BIC
Ian Mortimer
Zach Frazier
Ivo Jimenez
Joe Pulliam
Juergen Daubert
Rich Mintz
Seneca Cunningham
Dirk Deimeke
Michelle Crane

241
ChangeLog
View File

@@ -1,7 +1,237 @@
------ current release ---------------------------
1.8.2 (9/7/2009)
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).
@@ -14,8 +244,6 @@
+ Fixed bug #288 which failed to propagate rc file overrides on the command
line to the default command (thanks to Zach Frazier).
------ old releases ------------------------------
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).
@@ -46,8 +274,8 @@
+ 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).
+ 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
+ Added zsh tab completion script (thanks to P.C. Shyamshankar).
@@ -364,7 +592,8 @@
+ 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.

View File

@@ -1,11 +1,11 @@
SUBDIRS = src
dist_man_MANS = doc/man/task.1 doc/man/taskrc.5 doc/man/task-tutorial.5
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
docdir = $(datadir)/doc/${PACKAGE}-${VERSION}
#docdir = $(datadir)/doc/${PACKAGE}-${VERSION}
doc_DATA = AUTHORS ChangeLog COPYING NEWS README
EXTRA_DIST = INSTALL
EXTRA_DIST = INSTALL README.build
bashscriptsdir = $(docdir)
nobase_dist_bashscripts_DATA = scripts/bash/task_completion.sh
@@ -14,7 +14,11 @@ 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
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
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

44
NEWS
View File

@@ -1,31 +1,35 @@
New Features in task 1.8
New Features in task 1.9.2
- 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
- Shell-friendly exit codes
- 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.
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 11 Leonidas and 10 Cambridge
- Ubuntu 9.04 Jaunty Jackalope and 8.10 Intrepid Ibex
- Slackware 12.2
- Arch Linux
- Gentoo Linux
- Solaris 10 and 8
- OpenBSD 4.5
- FreeBSD
- Cygwin 1.5
* 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
While Task has undergone testing, bugs are sure to remain. If you encounter a
bug, please enter a new issue at:

7
README
View File

@@ -4,16 +4,15 @@ 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:
movies, and you'll find all the details at:
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.
code patches, ideas, discussion, bug reports, encouragement or criticism, your
input is needed.
Please send your support questions and code patches to:

98
README.build Normal file
View File

@@ -0,0 +1,98 @@
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.
---

View File

@@ -2,10 +2,20 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT(task, 1.8.2, support@taskwarrior.org)
AC_INIT(task, 1.9.2, 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.
@@ -13,44 +23,158 @@ 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)
# Yes, shell scripts can be used
if test "$enable_debug" = "yes"; then
CXXFLAGS="$CFLAGS -Wall -pedantic -ggdb3 -DDEBUG"
if test "x$enable_debug" = "xyes"; then
CFLAGS="$CFLAGS -Wall -pedantic -ggdb3 -DDEBUG"
CXXFLAGS="$CXXFLAGS -Wall -pedantic -ggdb3 -DDEBUG"
AC_MSG_RESULT(yes)
else
CXXFLAGS="$CFLAGS -Wall -pedantic -O3"
CFLAGS="$CFLAGS -Wall -pedantic -O3"
CXXFLAGS="$CXXFLAGS -Wall -pedantic -O3"
AC_MSG_RESULT(no)
fi
# Check for OS.
OS=`uname|sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
OS=`uname|sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'|cut -c 1-5`
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 Non-Solaris detected])
AC_DEFINE([LINUX], [], [Compiling on Non-Solaris])
AC_MSG_NOTICE([OS not detected])
AC_DEFINE([UNKNOWN], [], [Compiling on Unknown])
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
@@ -59,15 +183,19 @@ 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.

295
doc/man/task-color.5 Normal file
View File

@@ -0,0 +1,295 @@
.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>

322
doc/man/task-faq.5 Normal file
View File

@@ -0,0 +1,322 @@
.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>

View File

@@ -1,12 +1,17 @@
.TH task-tutorial 5 2009-09-07 "task 1.8.2" "User Manuals"
.TH task-tutorial 5 2010-05-22 "task 1.9.2" "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 subcommands that allow you to do various things with it.
has a rich list of commands that allow you to do various things with it.
.SH 30 second tutorial
@@ -53,7 +58,8 @@ $ task ls
No matches
.RE
Easy. But now consider checking out what task can really do...
That's how easy managing your task list can be. But now consider learning what
task can really do...
.SH Simple usage of task
Let us begin by adding some tasks:
@@ -68,8 +74,8 @@ $ task add Reserve a rental car
$ task add Reserve a hotel room
.RE
That's it. You'll notice immediately that task has a very minimalist
interface. Let us take a look at those tasks:
You'll notice immediately that task has a very minimalist interface. Let us take
a look at those tasks:
.br
.RS
$ task ls
@@ -96,18 +102,18 @@ $ task 2 delete
Permanently delete task? (y/n) y
.RE
Task wants you to confirm deletions. To remove the confirmation, edit
Task wants you to confirm deletions. To suppress the confirmation, edit
your .taskrc file and change the line:
.br
.RS
confirmation=yes
.RE
.br
to have a value of "no".
to have a value of "no". If the entry is not there, then add it.
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:
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:
.br
.RS
$ task 1 project:Wedding
@@ -153,8 +159,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
@@ -240,20 +246,37 @@ ID Project Pri Description
2 Wedding M Reserve a rental car
.RE
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.
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.
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
@@ -288,29 +311,8 @@ ID Project Pri Due Active Age Description
2 Wedding M 7 mins Reserve a rental car
.RE
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.
Note that due tasks may be colored to highlight the importance. See the
task-color(5) man page for full details.
Tagging tasks is a good way to group them, aside from specifying a project.
To add a tag to a task:
@@ -356,14 +358,23 @@ 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 \- 2009 P. Beckingham
Copyright (C) 2006 \- 2010 P. Beckingham
This man page was originally written by Federico Hernandez.
@@ -372,7 +383,9 @@ http://www.gnu.org/licenses/gpl-2.0.txt for more information.
.SH SEE ALSO
.BR task(1),
.BR taskrc(5)
.BR taskrc(5),
.BR task-faq(5)
.BR task-color(5)
For more information regarding task, the following may be referenced:
@@ -382,7 +395,7 @@ The official site at
.TP
The official code repository at
<http://github.com/pbeckingham/task/>
<git://tasktools.org/task.git/>
.TP
You can contact the project by writing an email to

View File

@@ -1,4 +1,4 @@
.TH task 1 2009-09-07 "task 1.8.2" "User Manuals"
.TH task 1 2010-05-22 "task 1.9.2" "User Manuals"
.SH NAME
task \- A command line todo manager.
@@ -11,6 +11,14 @@ 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
@@ -18,14 +26,148 @@ has a rich list of subcommands that allow you to do various things with it.
Adds a new task to the task list.
.TP
.B append [tags] [attrs] description
Appends more information to an existing
task.
.B log [tags] [attrs] description
Adds a new task that is already completed, to the task list.
.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.
@@ -44,91 +186,12 @@ Launches an editor to let you modify all aspects of a task directly.
Use carefully.
.TP
.B undo
Reverts the most recent action.
.B append [tags] [attrs] description
Appends information to an existing task.
.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 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.
.B prepend [tags] [attrs] description
Prepends information to an existing task.
.SH REPORT SUBCOMMANDS
@@ -151,9 +214,13 @@ Shows all tasks matching the specified criteria
that are completed.
.TP
.B ls [tags] [attrs] [description]
.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.
.TP
.B list [tags] [attrs] [description]
Provides a more detailed listing of tasks with specified criteria.
@@ -234,7 +301,10 @@ Specifies background color.
.TP
.B limit:<number-of-rows>
Specifies the desired number of rows a report should have.
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.
.TP
.B wait:<wait-date>
@@ -263,6 +333,10 @@ 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:
@@ -437,17 +511,21 @@ can be configured in the configuration file.
.SH "CREDITS & COPYRIGHTS"
task was written by P. Beckingham <paul@beckingham.net>.
.br
Copyright (C) 2006 \- 2009 P. Beckingham
Copyright (C) 2006 \- 2010 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-tutorial(5),
.BR task-faq(5)
.BR task-color(5)
For more information regarding task, the following may be referenced:
@@ -457,7 +535,7 @@ The official site at
.TP
The official code repository at
<http://github.com/pbeckingham/task/>
<git://tasktools.org/task.git/>
.TP
You can contact the project by writing an email to

View File

@@ -1,4 +1,4 @@
.TH taskrc 5 2009-09-07 "task 1.8.2" "User Manuals"
.TH taskrc 5 2010-05-22 "task 1.9.2" "User Manuals"
.SH NAME
taskrc \- Configuration file for the task(1) command
@@ -36,11 +36,13 @@ $ 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>
@@ -57,11 +59,69 @@ 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.
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.
.SH CONFIGURATION VARIABLES
Valid variable names and their default values are:
@@ -70,15 +130,20 @@ 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
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.
.TP
.B locking=on
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.
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.
.SS TERMINAL
.TP
@@ -94,9 +159,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
@@ -109,93 +174,320 @@ 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.
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".
.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".
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".
.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 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.
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.
.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.
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".
.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.
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'.
.SS DATES
.TP
.B dateformat=m/d/Y
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
.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:
.RS
m minimal-digit month, for example 1 or 12
.RS
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
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
.RE
The string may also contain other characters to act as spacers, or formatting. Examples for other
variable values:
.RS
The string may also contain other characters to act as spacers, or formatting.
Examples for other values of dateformat:
.RE
.RS
.RS
.br
d/m/Y would output 24/7/2009
d/m/Y would use for input and output 24/7/2009
.br
YMD would output 20090724
yMD would use for input and output 090724
.br
m-d-y would output 07-24-09
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
.RE
.TP
.B weekstart=Sunday
Determines the day a week starts. Valid values are Sunday or Monday only.
Determines the day a week starts. Valid values are Sunday or Monday only. The
default value is "Sunday".
.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 week number is dependent on the day a week starts. The default value is
"yes".
.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. Defaults to 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.
.TP
.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.
.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.
.SS COLOR CONTROLS
@@ -207,12 +499,13 @@ use dashes (-----) to underline column headings.
.TP
.B fontunderline=on
Determines if font underlines or ASCII dashes should be used to underline
headers.
headers, even when color is enabled.
.RE
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
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:
.RS
.B task color
@@ -223,87 +516,166 @@ The coloration rules and their defaults are:
.RE
.RS
.RS
.B color.overdue=bold_red
.B color.overdue=bold red
The color for overdue tasks.
.br
.B color.due=bold_yellow
.B color.due.today=bold magenta
The color of tasks due today.
.br
.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.
.B color.pri.M=on yellow
The color of priority:M tasks. No default value.
.br
.B color.pri.L=on_green
The color of priority:L tasks.
.B color.pri.L=on green
The color of priority:L tasks. No default value.
.br
.B color.pri.none=white on_blue
The color of priority: tasks.
.B color.pri.none=white on blue
The color of priority: tasks. No default value.
.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
The value for the coloration rules may be one optional foreground color and one optional
color. For example, the value may be
.RE
To disable a coloration rule for which there is a default, set the value to
nothing, for example:
.RS
.RS
bold_red on_bright_yellow
.B color.tagged=
.RE
.RE
.RS
Certain attributes like tags, projects and keywords can also have their own coloration rules.
See the task-color(5) man pages for color details.
.RE
Certain attributes like tags, projects and keywords can 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 contains X.
.B color.keyword.X=on blue
Colors any task where the description or any annotation contains X.
.RE
.TP
.B color.header=green
Colors any of the messages printed prior to the report output.
.TP
.B color.message=green
Colors any of the messages printed after the report output.
.RE
.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
@@ -327,20 +699,20 @@ file is updated by some task command.
default.project=foo
Provides a default project name for the
.I task add
command.
command, if you don't specify one. The default is blank.
.TP
.B
default.priority=M
Provides a default priority for the
.I task add
command.
command, if you don't specify one. The default is blank.
.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
@@ -349,8 +721,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
@@ -384,24 +756,41 @@ 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_ind, age, age_compact,
active, tags, description, description_only. The IDs are separated by commas.
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.
.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.
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.
.TP
.B report.X.limit
@@ -409,7 +798,8 @@ 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
@@ -421,6 +811,10 @@ 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
@@ -462,7 +856,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 \- 2009 P. Beckingham
Copyright (C) 2006 \- 2010 P. Beckingham
This man page was originally written by Federico Hernandez.
@@ -471,7 +865,9 @@ http://www.gnu.org/licenses/gpl-2.0.txt for more information.
.SH SEE ALSO
.BR task(1),
.BR task-tutorial(5)
.BR task-tutorial(5),
.BR task-faq(5)
.BR task-color(5)
For more information regarding task, the following may be referenced:
@@ -481,7 +877,7 @@ The official site at
.TP
The official code repository at
<http://github.com/pbeckingham/task/>
<git://tasktools.org/task.git/>
.TP
You can contact the project by writing an email to

34
doc/misc/script-color.txt Normal file
View File

@@ -0,0 +1,34 @@
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

View File

@@ -0,0 +1,40 @@
$ # 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

33
doc/misc/script-hooks.txt Normal file
View File

@@ -0,0 +1,33 @@
$
$ # 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

37
doc/rc/dark-16.theme Normal file
View File

@@ -0,0 +1,37 @@
# 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=

37
doc/rc/dark-256.theme Normal file
View File

@@ -0,0 +1,37 @@
# 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

View File

@@ -0,0 +1,37 @@
# 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

View File

@@ -0,0 +1,37 @@
# 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

37
doc/rc/dark-red-256.theme Normal file
View File

@@ -0,0 +1,37 @@
# 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

36
doc/rc/holidays-SE.rc Normal file
View File

@@ -0,0 +1,36 @@
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

28
doc/rc/holidays-US.rc Normal file
View File

@@ -0,0 +1,28 @@
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

37
doc/rc/light-16.theme Normal file
View File

@@ -0,0 +1,37 @@
# 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=

37
doc/rc/light-256.theme Normal file
View File

@@ -0,0 +1,37 @@
# 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

View File

@@ -40,13 +40,12 @@
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
@@ -55,10 +54,12 @@
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
@@ -99,57 +100,20 @@
# 5xx Colors
500 bold
501 underline
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
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
# 6xx Config

View File

@@ -1,5 +1,5 @@
Name: task
Version: 1.8.1
Version: 1.9.1
Release: 1%{?dist}
Summary: A command-line to do list manager
@@ -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, multiuser file locking, recurring tasks.
options, multi-user file locking, recurring tasks.
%prep
%setup -q
@@ -40,15 +40,37 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README scripts i18n
%doc AUTHORS ChangeLog COPYING NEWS README scripts i18n doc/rc
%{_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
%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
@@ -60,12 +82,12 @@ rm -rf $RPM_BUILD_ROOT
* Tue Jul 07 2009 Federico Hernandez <ultrafredde@gmail.com> - 1.8.0.beta1-1
Intial RPM for task beta release 1.8.0.beta1
* 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.

278
package-config/osx/README Normal file
View File

@@ -0,0 +1,278 @@
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.
---

View File

@@ -1,281 +0,0 @@
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

View File

@@ -1,24 +0,0 @@
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.
---

View File

@@ -0,0 +1 @@
<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>

View File

@@ -0,0 +1 @@
<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>

View File

@@ -1 +0,0 @@
<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>

View File

@@ -1 +0,0 @@
<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>

View File

@@ -1 +1 @@
<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>
<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>

34
package-config/osx/update Executable file
View File

@@ -0,0 +1,34 @@
#!/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

View File

@@ -1,3 +1,75 @@
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

View File

@@ -3,13 +3,13 @@ Section: utils
Priority: optional
Maintainer: Federico Hernandez <ultrafredde@gmail.com>
XSBC-Original-Maintainer: Federico Hernandez <ultrafredde@gmail.com>
Build-Depends: debhelper (>= 7), autotools-dev, libncurses5-dev
Standards-Version: 3.8.0.1
Build-Depends: cdbs, debhelper (>= 7), autotools-dev, libncurses5-dev
Standards-Version: 3.8.4
Homepage: http://taskwarrior.org
Package: task
Architecture: any
Depends: ${shlibs:Depends}
Depends: ${shlibs:Depends}, ${misc: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

View File

@@ -1,6 +1,6 @@
This package was debianized by:
Federico Hernandez <ultrafredde@gmail.com> on Thu, 20 Aug 2009 20:26:33 +0200
Federico Hernandez <ultrafredde@gmail.com> on Sun, 23 May 2010 00:24:42 +0200
It was downloaded from:
@@ -25,13 +25,19 @@ Upstream Authors:
Johan Friis
Steven de Brouwer
Pietro Cerutti
Cory Donnelly
Alexander Neumann
Emil Sköldberg
Johannes Schlatow
Copyright:
Copyright 2006 - 2009, Paul Beckingham
Copyright 2009 Federico Hernandez
Copyright 2006 - 2010, Paul Beckingham
Copyright 2009 - 2010 Federico Hernandez
Copyright 2006 - 2010, Paul Beckingham, Federico Hernandez
Copyright 2009 - 2010 John Florian
Copyright 2009 P.C. Shyamshankar
Copyright 2009 John Florian
Copyright © 19942008 Lua.org, PUC-Rio
License:
@@ -54,6 +60,6 @@ Public License can be found in `/usr/share/common-licenses/GPL-2'.
The Debian packaging is:
Copyright (C) 2009, Federico Hernandez <ultrafredde@gmail.com>
Copyright (C) 2009 - 2010, Federico Hernandez <ultrafredde@gmail.com>
and is licensed under the GPL, see above.

View File

@@ -1,2 +0,0 @@
scripts
i18n

View File

@@ -2,7 +2,7 @@
config.status: configure
dh_testdir
./configure $(CROSS) --prefix=/usr --docdir=$(DATADIR)/doc/task
./configure $(CROSS) --prefix=/usr
build: build-stamp
@@ -31,9 +31,7 @@ binary-arch: install
dh_installchangelogs
dh_installdocs
dh_installman
dh_installexamples
install -D -m644 scripts/bash/task_completion.sh $(CURDIR)/debian/task/etc/bash_completion.d/task
rm -rf $(CURDIR)/debian/task/usr/share/doc/task-1.8.1
dh_strip
dh_compress
dh_fixperms

View File

@@ -0,0 +1 @@
1.0

View File

@@ -1,3 +1,5 @@
# Compulsory line, this is a version 3 file
version=3
http://taskwarrior.org/download/task-(.*)\.tar\.gz
# the main taskwarrior download website
http://taskwarrior.org/wiki/taskwarrior/Download http://www.taskwarrior.org/download/task-(.*)\.tar\.gz

View File

@@ -1,6 +1,6 @@
# bash completion support for task
#
# Copyright 2009 Federico Hernandez
# Copyright 2009-2010 Federico Hernandez
# All rights reserved.
#
# This script is part of the task project.

View File

@@ -2,21 +2,21 @@
Configure VIM for Syntax Highlighting of Task Data
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.
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.
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,18 +27,20 @@ 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/
@@ -49,9 +51,9 @@ or
You should then be ready to go.
---
All three above mentioned files are
All four above mentioned files are
Copyright 2009 John Florian
Copyright 2009-2010 John Florian
and are available under the GNU Public License version 2 or later.
For the full text of this license, see COPYING.

View File

@@ -1,18 +1,22 @@
" Vim support file to detect task data files and single task edits
" Vim support file to detect Task Warrior data and configuration files and
" single task edits
"
" Maintainer: John Florian <jflorian@doubledog.org>
" Updated: Wed Jul 8 19:45:55 EDT 2009
" Updated: Thu Dec 10 18:28:26 EST 2009
"
" Copyright 2009 John Florian
" 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 the raw data files
" Task Warrior data files
au BufRead,BufNewFile {pending,completed,undo}.data set filetype=taskdata
" for 'task 42 edit'
" Task Warrior configuration file
au BufRead,BufNewFile .taskrc set filetype=taskrc
" Task Warrior handling of 'task 42 edit'
au BufRead,BufNewFile *.task set filetype=taskedit
" vim:noexpandtab

View File

@@ -3,7 +3,7 @@
" Maintainer: John Florian <jflorian@doubledog.org>
" Updated: Wed Jul 8 19:46:20 EDT 2009
"
" Copyright 2009 John Florian
" 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.

View File

@@ -3,7 +3,7 @@
" Maintainer: John Florian <jflorian@doubledog.org>
" Updated: Wed Jul 8 19:46:32 EDT 2009
"
" Copyright 2009 John Florian
" 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.

View File

@@ -0,0 +1,52 @@
" 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

View File

@@ -1,4 +1,11 @@
#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
@@ -27,10 +34,7 @@
#
typeset -g _task_cmds
_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_cmds=($(task _commands))
_task() {
_arguments -s -S \

1
src/.gitignore vendored
View File

@@ -1,2 +1,3 @@
*.o
Makefile.in
*_test

792
src/API.cpp Normal file
View File

@@ -0,0 +1,792 @@
////////////////////////////////////////////////////////////////////////////////
// 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 © 19942008 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 = &current;
// 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 Normal file
View File

@@ -0,0 +1,74 @@
////////////////////////////////////////////////////////////////////////////////
// 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
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, 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,6 +50,7 @@ static const char* internalNames[] =
"limit",
"status",
"description",
// Note that annotations are not listed.
};
static const char* modifiableNames[] =
@@ -77,6 +78,8 @@ static const char* modifierNames[] =
"hasnt",
"startswith", "left",
"endswith", "right",
"word",
"noword"
};
#define NUM_INTERNAL_NAMES (sizeof (internalNames) / sizeof (internalNames[0]))
@@ -102,7 +105,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;
@@ -122,7 +125,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;
@@ -152,6 +155,14 @@ 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 ()
{
@@ -319,8 +330,8 @@ bool Att::validNameValue (
else if (name == "fg" || name == "bg")
{
if (value != "")
Text::guessColor (value);
// TODO Determine whether color abbreviations are supported, and if so,
// modify 'value' here accordingly.
}
else if (name == "due" ||
@@ -329,7 +340,7 @@ bool Att::validNameValue (
{
// Validate and convert to epoch.
if (value != "")
value = Date (value, context.config.get ("dateformat", "m/d/Y")).toEpochString ();
value = Date (value, context.config.get ("dateformat")).toEpochString ();
}
else if (name == "recur")
@@ -342,8 +353,8 @@ bool Att::validNameValue (
else if (name == "limit")
{
if (value == "" || !digitsOnly (value))
throw std::string ("The '") + name + "' attribute must be an integer.";
if (value == "" || (value != "page" && !digitsOnly (value)))
throw std::string ("The '") + name + "' attribute must be an integer, or the value 'page'.";
}
else if (name == "status")
@@ -375,7 +386,7 @@ bool Att::validNameValue (
}
////////////////////////////////////////////////////////////////////////////////
// TODO Obsolete
// TODO Deprecated - remove.
bool Att::validMod (const std::string& mod)
{
for (unsigned int i = 0; i < NUM_MODIFIER_NAMES; ++i)
@@ -403,6 +414,9 @@ std::string Att::type (const std::string& name) const
else if (name == "limit")
return "number";
else if (name == "priority")
return "priority";
else
return "text";
}
@@ -412,7 +426,9 @@ std::string Att::type (const std::string& name) const
std::string Att::modType (const std::string& name) const
{
if (name == "hasnt" ||
name == "isnt")
name == "isnt" ||
name == "not" || // TODO Verify this.
name == "noword")
return "negative";
return "positive";
@@ -483,32 +499,49 @@ 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 == "")
{
if (mValue != other.mValue)
return false;
// 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;
}
}
// has = contains as a substring.
else if (mMod == "has" || mMod == "contains") // TODO i18n
{
if (other.mValue.find (mValue) == std::string::npos)
if (find (other.mValue, mValue, (bool) case_sensitive) == std::string::npos)
return false;
}
// is = equal. Nop.
else if (mMod == "is" || mMod == "equals") // TODO i18n
{
if (mValue != other.mValue)
if (!compare (mValue, other.mValue, (bool) case_sensitive))
return false;
}
// isnt = not equal.
else if (mMod == "isnt" || mMod == "not") // TODO i18n
{
if (mValue == other.mValue)
if (compare (mValue, other.mValue, (bool) case_sensitive))
return false;
}
@@ -532,7 +565,7 @@ bool Att::match (const Att& other) const
if (other.mValue.length () < mValue.length ())
return false;
if (mValue != other.mValue.substr (0, mValue.length ()))
if (!compare (mValue, other.mValue.substr (0, mValue.length ()), (bool) case_sensitive))
return false;
}
@@ -542,16 +575,16 @@ bool Att::match (const Att& other) const
if (other.mValue.length () < mValue.length ())
return false;
if (mValue != other.mValue.substr (
if (!compare (mValue, other.mValue.substr (
other.mValue.length () - mValue.length (),
std::string::npos))
std::string::npos), (bool) case_sensitive))
return false;
}
// hasnt = does not contain as a substring.
else if (mMod == "hasnt") // TODO i18n
{
if (other.mValue.find (mValue) != std::string::npos)
if (find (other.mValue, mValue, (bool) case_sensitive) != std::string::npos)
return false;
}
@@ -562,20 +595,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", "m/d/Y"));
Date variable ((time_t)::atoi (other.mValue.c_str ()));
Date literal (mValue.c_str (), context.config.get ("dateformat"));
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")
@@ -583,6 +616,14 @@ 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 = >
@@ -592,20 +633,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", "m/d/Y"));
Date variable ((time_t)::atoi (other.mValue.c_str ()));
Date literal (mValue.c_str (), context.config.get ("dateformat"));
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")
@@ -613,6 +654,43 @@ 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;
@@ -678,7 +756,20 @@ void Att::value (const std::string& value)
////////////////////////////////////////////////////////////////////////////////
int Att::value_int () const
{
return ::atoi (mValue.c_str ());
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]);
}
////////////////////////////////////////////////////////////////////////////////
@@ -710,11 +801,9 @@ void Att::dequote (std::string& value) const
////////////////////////////////////////////////////////////////////////////////
// Encode values prior to serialization.
// \t -> &tab;
// " -> &quot;
// , -> &comma;
// " -> &dquot;
// [ -> &open;
// ] -> &close;
// : -> &colon;
void Att::encode (std::string& value) const
{
std::string::size_type i;
@@ -722,23 +811,14 @@ void Att::encode (std::string& value) const
while ((i = value.find ('\t')) != std::string::npos)
value.replace (i, 1, "&tab;"); // no i18n
while ((i = value.find ('\'')) != std::string::npos)
value.replace (i, 1, "&squot;"); // no i18n
while ((i = value.find ('"')) != std::string::npos)
value.replace (i, 1, "&dquot;"); // no i18n
while ((i = value.find (',')) != std::string::npos)
value.replace (i, 1, "&comma;"); // 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, "&colon;"); // no i18n
}
////////////////////////////////////////////////////////////////////////////////
@@ -754,28 +834,32 @@ void Att::decode (std::string& value) const
{
std::string::size_type i;
while ((i = value.find ("&tab;")) != std::string::npos) // no i18n
// Supported encodings.
while ((i = value.find ("&tab;")) != std::string::npos)
value.replace (i, 5, "\t");
while ((i = value.find ("&dquot;")) != std::string::npos) // no i18n
while ((i = value.find ("&dquot;")) != std::string::npos)
value.replace (i, 7, "\"");
while ((i = value.find ("&squot;")) != std::string::npos) // no i18n
value.replace (i, 7, "'");
while ((i = value.find ("&quot;")) != std::string::npos) // no i18n
while ((i = value.find ("&quot;")) != std::string::npos)
value.replace (i, 6, "\"");
while ((i = value.find ("&comma;")) != std::string::npos) // no i18n
value.replace (i, 7, ",");
while ((i = value.find ("&open;")) != std::string::npos) // no i18n
while ((i = value.find ("&open;")) != std::string::npos)
value.replace (i, 6, "[");
while ((i = value.find ("&close;")) != std::string::npos) // no i18n
while ((i = value.find ("&close;")) != std::string::npos)
value.replace (i, 7, "]");
while ((i = value.find ("&colon;")) != std::string::npos) // no i18n
// 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 ("&comma;")) != std::string::npos)
value.replace (i, 7, ",");
while ((i = value.find ("&colon;")) != std::string::npos)
value.replace (i, 7, ":");
}

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -41,6 +41,7 @@ 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;
@@ -69,6 +70,8 @@ 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;

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -105,38 +105,51 @@ 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 (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"));
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"));
#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;
@@ -146,7 +159,7 @@ void Cmd::load ()
{
if (i->substr (0, 7) == "report.")
{
std::string report = i->substr (7, std::string::npos);
std::string report = i->substr (7);
std::string::size_type columns = report.find (".columns");
if (columns != std::string::npos)
{
@@ -186,25 +199,31 @@ 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 == 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") ||
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") ||
validCustom (command))
return true;
@@ -215,14 +234,18 @@ bool Cmd::isReadOnlyCommand ()
// Commands that directly modify the data files.
bool Cmd::isWriteCommand ()
{
if (command == context.stringtable.get (CMD_ADD, "add") ||
if (command == "_merge" ||
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"))

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under

557
src/Color.cpp Normal file
View File

@@ -0,0 +1,557 @@
////////////////////////////////////////////////////////////////////////////////
// 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 Normal file
View File

@@ -0,0 +1,78 @@
////////////////////////////////////////////////////////////////////////////////
// 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
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -27,30 +27,347 @@
#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"
////////////////////////////////////////////////////////////////////////////////
// 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.
// 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.
Config::Config ()
{
setDefaults ();
}
////////////////////////////////////////////////////////////////////////////////
Config::Config (const std::string& file)
{
setDefaults ();
load (file);
}
@@ -58,288 +375,128 @@ 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.
bool Config::load (const std::string& file)
//
// Nested files are now supported, with the following construct:
// include /absolute/path/to/file
//
void Config::load (const std::string& file, int nest /* = 1 */)
{
std::ifstream in;
in.open (file.c_str (), std::ifstream::in);
if (in.good ())
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::string line;
while (getline (in, line))
{
// 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::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
(*this)[key] = value;
}
}
}
in.close ();
return true;
setDefaults ();
original_file = File (file);
}
return false;
// 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::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
(*this)[key] = value;
}
else
{
std::string::size_type include = line.find ("include"); // no i18n.
if (include != 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 + "'";
}
else
throw std::string ("Malformed entry '") + line + "'";
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
void Config::createDefaultRC (const std::string& rc, const std::string& data)
{
// Create a sample .taskrc file.
std::stringstream contents;
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";
// Override data.location in the defaults.
std::string::size_type loc = defaults.find ("data.location=~/.task");
// loc+0^ +14^ +21^
spit (rc, contents.str ());
Date now;
std::stringstream contents;
contents << "# [Created by "
<< PACKAGE_STRING
<< " "
<< now.toStringWithTime ()
<< "]\n"
<< defaults.substr (0, loc + 14)
<< data
<< defaults.substr (loc + 21);
// Write out the new file.
if (! File::write (rc, contents.str ()))
throw std::string ("Could not write to '") + rc + "'";
}
////////////////////////////////////////////////////////////////////////////////
void Config::createDefaultData (const std::string& data)
{
if (access (data.c_str (), F_OK))
mkdir (data.c_str (), S_IRWXU);
Directory d (data);
if (! d.exists ())
d.create ();
}
////////////////////////////////////////////////////////////////////////////////
void Config::setDefaults ()
{
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
parse (defaults);
}
////////////////////////////////////////////////////////////////////////////////
// Return the configuration value given the specified key.
const std::string Config::get (const char* key)
void Config::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));
std::map <std::string, std::string>::clear ();
}
////////////////////////////////////////////////////////////////////////////////
@@ -350,56 +507,42 @@ const std::string Config::get (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)
const int Config::getInteger (const std::string& key)
{
if ((*this).find (key) != (*this).end ())
return (*this)[key];
return atoi ((*this)[key].c_str ());
return default_value;
return 0;
}
////////////////////////////////////////////////////////////////////////////////
bool Config::get (const std::string& key, const bool 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)
{
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 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;
return false;
}
////////////////////////////////////////////////////////////////////////////////
@@ -433,3 +576,37 @@ 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 ();
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -30,6 +30,7 @@
#include <map>
#include <vector>
#include <string>
#include "File.h"
class Config : public std::map <std::string, std::string>
{
@@ -40,22 +41,31 @@ public:
Config (const Config&);
Config& operator= (const Config&);
bool load (const std::string&);
void load (const std::string&, int nest = 1);
void parse (const std::string&, int nest = 1);
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

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -30,7 +30,10 @@
#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"
@@ -49,7 +52,8 @@ Context::Context ()
, tdb ()
, stringtable ()
, program ("")
, overrides ("")
, file_override ("")
, var_overrides ("")
, cmd ()
, inShadow (false)
{
@@ -65,6 +69,7 @@ void Context::initialize (int argc, char** argv)
{
// Capture the args.
for (int i = 0; i < argc; ++i)
{
if (i == 0)
{
program = argv[i];
@@ -75,8 +80,14 @@ 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");
}
////////////////////////////////////////////////////////////////////////////////
@@ -94,16 +105,16 @@ void Context::initialize ()
{
config.set ("curses", "off");
if (! config.get (std::string ("_forcecolor"), false))
if (! config.getBoolean ("_forcecolor"))
config.set ("color", "off");
}
if (config.get ("color", true))
if (config.getBoolean ("color"))
initializeColorRules ();
// Load appropriate stringtable as soon after the config file as possible, to
// allow all subsequent messages to be localizable.
std::string location = expandPath (config.get ("data.location"));
Directory location (config.get ("data.location"));
std::string locale = config.get ("locale");
// If there is a locale variant (en-US.<variant>), then strip it.
@@ -112,7 +123,7 @@ void Context::initialize ()
locale = locale.substr (0, period);
if (locale != "")
stringtable.load (location + "/strings." + locale);
stringtable.load (location.data + "/strings." + locale);
// TODO Handle "--version, -v" right here?
@@ -121,15 +132,13 @@ void Context::initialize ()
std::vector <std::string> all;
split (all, location, ',');
foreach (path, all)
tdb.location (expandPath (*path));
tdb.location (*path);
}
////////////////////////////////////////////////////////////////////////////////
int Context::run ()
{
int rc;
Timer t ("Context::run");
std::string output;
try
{
@@ -150,30 +159,39 @@ int Context::run ()
}
// Dump all debug messages.
if (config.get (std::string ("debug"), false))
hooks.trigger ("pre-debug");
if (config.getBoolean ("debug"))
foreach (d, debugMessages)
if (config.get ("color", true) || config.get (std::string ("_forcecolor"), false))
if (config.getBoolean ("color") || config.getBoolean ("_forcecolor"))
std::cout << colorizeDebug (*d) << std::endl;
else
std::cout << *d << std::endl;
hooks.trigger ("post-debug");
// Dump all headers.
hooks.trigger ("pre-header");
foreach (h, headers)
if (config.get ("color", true) || config.get (std::string ("_forcecolor"), false))
if (config.getBoolean ("color") || config.getBoolean ("_forcecolor"))
std::cout << colorizeHeader (*h) << std::endl;
else
std::cout << *h << std::endl;
hooks.trigger ("post-header");
// 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.get ("color", true) || config.get (std::string ("_forcecolor"), false))
if (config.getBoolean ("color") || config.getBoolean ("_forcecolor"))
std::cout << colorizeFootnote (*f) << std::endl;
else
std::cout << *f << std::endl;
hooks.trigger ("post-footnote");
hooks.trigger ("pre-exit");
return rc;
}
@@ -181,55 +199,71 @@ int Context::run ()
int Context::dispatch (std::string &out)
{
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 == "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") { rc = handleReportHistory (out); }
else if (cmd.command == "ghistory") { rc = handleReportGHistory (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 == "append") { rc = handleAppend (out); }
else if (cmd.command == "annotate") { rc = handleAnnotate (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") { rc = handleExport (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); }
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); }
#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 == "_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 == "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 == "" &&
sequence.size ()) { rc = handleModify (out); }
sequence.size ()) { rc = handleModify (out); }
// 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 (); rc = handleReportNext (out); }
else if (cmd.validCustom (cmd.command)) { if (!inShadow) tdb.gc (); rc = handleCustomReport (cmd.command, out); }
// If the command is not recognized, display usage.
else { rc = shortUsage (out); }
else { hooks.trigger ("pre-usage-command");
rc = shortUsage (out);
hooks.trigger ("post-usage-command"); }
// Only update the shadow file if such an update was not suppressed (shadow),
if (cmd.isWriteCommand () && !inShadow)
shadow ();
hooks.trigger ("post-dispatch");
return rc;
}
@@ -237,22 +271,20 @@ int Context::dispatch (std::string &out)
void Context::shadow ()
{
// Determine if shadow file is enabled.
std::string shadowFile = expandPath (config.get ("shadow.file"));
if (shadowFile != "")
File shadowFile (config.get ("shadow.file"));
if (shadowFile.data != "")
{
inShadow = true; // Prevents recursion in case shadow command writes.
// TODO Reinstate these checks.
/*
// Check for silly shadow file settings.
if (shadowFile == dataLocation + "/pending.data")
std::string dataLocation = config.get ("data.location");
if (shadowFile.data == dataLocation + "/pending.data")
throw std::string ("Configuration variable 'shadow.file' is set to "
"overwrite your pending tasks. Please change it.");
if (shadowFile == dataLocation + "/completed.data")
if (shadowFile.data == 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");
@@ -261,8 +293,10 @@ void Context::shadow ()
// Run report. Use shadow.command, using default.command as a fallback
// with "list" as a default.
std::string command = config.get ("shadow.command",
config.get ("default.command", "list"));
std::string command = config.get ("shadow.command");
if (command == "")
command = config.get ("default.command");
split (args, command, ' ');
initialize ();
@@ -272,21 +306,21 @@ void Context::shadow ()
parse ();
std::string result;
(void)dispatch (result);
std::ofstream out (shadowFile.c_str ());
std::ofstream out (shadowFile.data.c_str ());
if (out.good ())
{
out << result;
out.close ();
}
else
throw std::string ("Could not write file '") + shadowFile + "'";
throw std::string ("Could not write file '") + shadowFile.data + "'";
config.set ("curses", oldCurses);
config.set ("color", oldColor);
// Optionally display a notification that the shadow file was updated.
if (config.get (std::string ("shadow.notify"), false))
footnote (std::string ("[Shadow file '") + shadowFile + "' updated]");
if (config.getBoolean ("shadow.notify"))
footnote (std::string ("[Shadow file '") + shadowFile.data + "' updated]");
inShadow = false;
}
@@ -346,60 +380,61 @@ void Context::loadCorrectConfigFile ()
"Could not read home directory from the passwd file."));
std::string home = pw->pw_dir;
std::string rc = home + "/.taskrc";
std::string data = home + "/.task";
File rc (home + "/.taskrc");
Directory data (home + "./task");
// Is there an override for rc?
// Is there an file_override for rc:?
foreach (arg, args)
{
if (*arg == "--")
break;
else if (arg->substr (0, 3) == "rc:")
{
rc = arg->substr (3, std::string::npos);
file_override = *arg;
rc = File (arg->substr (3));
home = rc;
std::string::size_type last_slash = rc.rfind ("/");
std::string::size_type last_slash = rc.data.rfind ("/");
if (last_slash != std::string::npos)
home = rc.substr (0, last_slash);
home = rc.data.substr (0, last_slash);
else
home = ".";
args.erase (arg);
header ("Using alternate .taskrc file " + rc); // TODO i18n
header ("Using alternate .taskrc file " + rc.data); // TODO i18n
break;
}
}
// Load rc file.
config.clear (); // Dump current values.
config.setDefaults (); // Add in the custom reports.
config.load (rc); // Load new file.
config.load (rc); // Load new file.
if (config.get ("data.location") != "")
data = config.get ("data.location");
data = Directory (config.get ("data.location"));
// Is there an override for data?
// Are there any var_overrides for data.location?
foreach (arg, args)
{
if (*arg == "--")
break;
else if (arg->substr (0, 17) == "rc.data.location:")
else if (arg->substr (0, 17) == "rc.data.location:" ||
arg->substr (0, 17) == "rc.data.location=")
{
data = arg->substr (17, std::string::npos);
header ("Using alternate data.location " + data); // TODO i18n
data = Directory (arg->substr (17));
header ("Using alternate data.location " + data.data); // TODO i18n
break;
}
}
// Do we need to create a default rc?
if (access (rc.c_str (), F_OK))
if (! rc.exists ())
{
if (confirm ("A configuration file could not be found in " // TODO i18n
+ home
+ "\n\n"
+ "Would you like a sample "
+ rc
+ rc.data
+ " created, so task can proceed?"))
{
config.createDefaultRC (rc, data);
@@ -411,12 +446,13 @@ void Context::loadCorrectConfigFile ()
// 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"
// Apply overrides of type: "rc.name:value", or "rc.name=value".
std::vector <std::string> filtered;
bool foundTerminator = false;
foreach (arg, args)
@@ -432,16 +468,16 @@ void Context::loadCorrectConfigFile ()
std::string name;
std::string value;
Nibbler n (*arg);
if (n.getUntil ('.', name) &&
n.skip ('.') &&
n.getUntil (':', name) &&
n.skip (':') &&
if (n.getUntil ('.', name) &&
n.skip ('.') &&
n.getUntilOneOf (":=", name) &&
n.skipN (1) &&
n.getUntilEOS (value))
{
config.set (name, value);
overrides += " " + *arg;
var_overrides += " " + *arg;
footnote (std::string ("Configuration override ") + // TODO i18n
arg->substr (3, std::string::npos));
arg->substr (3));
}
}
else
@@ -462,7 +498,7 @@ void Context::loadAliases ()
{
if (var->substr (0, 6) == "alias.")
{
std::string alias = var->substr (6, std::string::npos);
std::string alias = var->substr (6);
std::string canonical = config.get (*var);
aliases[alias] = canonical;
@@ -495,6 +531,7 @@ void Context::parse (
bool terminated = false;
bool foundSequence = false;
bool foundSomethingAfterSequence = false;
bool foundNonSequence = false;
foreach (arg, parseArgs)
{
@@ -509,7 +546,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))
{
@@ -527,12 +564,14 @@ 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, std::string::npos));
parseTask.addTag (arg->substr (1, std::string::npos));
tagAdditions.push_back (arg->substr (1));
parseTask.addTag (arg->substr (1));
}
// Tags to remove begin with '-'.
@@ -544,11 +583,13 @@ 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, std::string::npos));
tagRemovals.push_back (arg->substr (1));
}
// Atributes - name[.mod]:[value]
@@ -558,6 +599,8 @@ 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.
@@ -576,6 +619,8 @@ void Context::parse (
parseTask[name + "." + mod] = attribute;
else
parseTask[name] = attribute;
autoFilter (attribute, parseFilter);
}
// *arg has the appearance of an attribute (foo:bar), but isn't
@@ -585,6 +630,8 @@ void Context::parse (
if (foundSequence)
foundSomethingAfterSequence = true;
foundNonSequence = true;
if (descCandidate.length ())
descCandidate += " ";
descCandidate += *arg;
@@ -597,6 +644,8 @@ void Context::parse (
if (foundSequence)
foundSomethingAfterSequence = true;
foundNonSequence = true;
debug ("parse subst '" + *arg + "'");
parseSubst.parse (*arg);
}
@@ -610,6 +659,8 @@ void Context::parse (
if (foundSequence)
foundSomethingAfterSequence = true;
foundNonSequence = true;
}
// Anything else is just considered description.
@@ -618,6 +669,8 @@ void Context::parse (
if (foundSequence)
foundSomethingAfterSequence = true;
foundNonSequence = true;
if (descCandidate.length ())
descCandidate += " ";
descCandidate += *arg;
@@ -641,6 +694,21 @@ 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.
@@ -648,35 +716,57 @@ void Context::parse (
parseCmd.parse (descCandidate);
// Read-only command (reports, status, info ...) use filters. Write commands
// (add, done ...) do not.
// (add, done ...) do not. The filter was constructed iteratively above, but
// tags were omitted, so they are added now.
if (parseCmd.isReadOnlyCommand ())
autoFilter (parseTask, parseFilter);
autoFilter (parseFilter);
// If no command was specified, and there were no command line arguments
// then invoke the default command.
if (parseCmd.command == "" && parseArgs.size () == 0)
if (parseCmd.command == "")
{
// Apply overrides, if any.
std::string defaultCommand = config.get ("default.command") + overrides;
if (defaultCommand != "")
if (parseArgs.size () == 0)
{
// Stuff the command line.
args.clear ();
split (args, defaultCommand, ' ');
header ("[task " + defaultCommand + "]");
// Apply overrides, if any.
std::string defaultCommand = config.get ("default.command");
if (defaultCommand != "")
{
// Add on the overrides.
defaultCommand += " " + file_override + " " + var_overrides;
// Reinitialize the context and recurse.
initialize ();
parse (args, cmd, task, sequence, subst, filter);
// 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";
}
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;
@@ -690,6 +780,8 @@ void Context::clear ()
// stringtable.clear ();
program = "";
args.clear ();
file_override = "";
var_overrides = "";
cmd.command = "";
tagAdditions.clear ();
tagRemovals.clear ();
@@ -700,78 +792,86 @@ void Context::clear ()
////////////////////////////////////////////////////////////////////////////////
// Add all the attributes in the task to the filter. All except uuid.
void Context::autoFilter (Task& t, Filter& f)
void Context::autoFilter (Att& a, Filter& f)
{
foreach (att, t)
// Words are found in the description using the .has modifier.
if (a.name () == "description" && a.mod () == "")
{
// Words are found in the description using the .has modifier.
if (att->second.name () == "description" && att->second.mod () == "")
std::vector <std::string> words;
split (words, a.value (), ' ');
foreach (word, words)
{
std::vector <std::string> words;
split (words, att->second.value (), ' ');
foreach (word, words)
{
f.push_back (Att ("description", "has", *word));
debug ("auto filter: " + att->second.name () + ".has:" + *word);
}
}
// Projects are matched left-most.
else if (att->second.name () == "project" && att->second.mod () == "")
{
if (att->second.value () != "")
{
f.push_back (Att ("project", "startswith", att->second.value ()));
debug ("auto filter: " + att->second.name () + ".startswith:" + att->second.value ());
}
else
{
f.push_back (Att ("project", "is", att->second.value ()));
debug ("auto filter: " + att->second.name () + ".is:" + att->second.value ());
}
}
// The limit attribute does not participate in filtering, and needs to be
// specifically handled in handleCustomReport.
else if (att->second.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 (att->second.name () == "uuid")
{
}
// The mechanism for filtering on tags is +/-<tag>.
else if (att->second.name () == "tags")
{
}
// Generic attribute matching.
else
{
f.push_back (att->second);
debug ("auto filter: " +
att->second.name () +
(att->second.mod () != "" ?
("." + att->second.mod () + ":") :
":") +
att->second.value ());
f.push_back (Att ("description", "has", *word));
debug ("auto filter: " + a.name () + ".has:" + *word);
}
}
// Projects are matched left-most.
else if (a.name () == "project" && a.mod () == "")
{
if (a.value () != "")
{
f.push_back (Att ("project", "startswith", a.value ()));
debug ("auto filter: " + a.name () + ".startswith:" + a.value ());
}
else
{
f.push_back (Att ("project", "is", a.value ()));
debug ("auto filter: " + a.name () + ".is:" + a.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", "has", *tag));
f.push_back (Att ("tags", "word", *tag));
debug ("auto filter: +" + *tag);
}
// Include tagRemovals.
foreach (tag, tagRemovals)
{
f.push_back (Att ("tags", "hasnt", *tag));
f.push_back (Att ("tags", "noword", *tag));
debug ("auto filter: -" + *tag);
}
}

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -36,6 +36,7 @@
#include "Task.h"
#include "TDB.h"
#include "StringTable.h"
#include "Hooks.h"
class Context
{
@@ -54,6 +55,7 @@ public:
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
@@ -70,7 +72,8 @@ public:
private:
void loadCorrectConfigFile ();
void loadAliases ();
void autoFilter (Task&, Filter&);
void autoFilter (Att&, Filter&);
void autoFilter (Filter&);
public:
Config config;
@@ -83,13 +86,14 @@ public:
StringTable stringtable;
std::string program;
std::vector <std::string> args;
std::string overrides;
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;

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham, Federico Hernandez.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -25,13 +25,18 @@
//
////////////////////////////////////////////////////////////////////////////////
#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".
@@ -51,9 +56,27 @@ Date::Date (const int m, const int d, const int y)
{
// Error if not valid.
struct tm t = {0};
t.tm_mday = d;
t.tm_mon = m - 1;
t.tm_year = y - 1900;
t.tm_isdst = -1; // Requests that mktime determine summer time effect.
t.tm_mday = d;
t.tm_mon = m - 1;
t.tm_year = y - 1900;
mT = mktime (&t);
}
////////////////////////////////////////////////////////////////////////////////
Date::Date (const int m, const int d, const int y,
const int hr, const int mi, const int se)
{
// Error if not valid.
struct tm t = {0};
t.tm_isdst = -1; // Requests that mktime determine summer time effect.
t.tm_mday = d;
t.tm_mon = m - 1;
t.tm_year = y - 1900;
t.tm_hour = hr;
t.tm_min = mi;
t.tm_sec = se;
mT = mktime (&t);
}
@@ -61,9 +84,12 @@ Date::Date (const int m, const int d, const int y)
////////////////////////////////////////////////////////////////////////////////
Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
{
int month = 0;
int day = 0;
int year = 0;
int month = 0;
int day = 0;
int year = -1; // So we can check later.
int hour = 0;
int minute = 0;
int second = 0;
// Perhaps it is an epoch date, in string form?
if (isEpoch (mdy))
@@ -82,120 +108,253 @@ 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.";
throw std::string ("\"") + mdy + "\" is not a valid date (m).";
}
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.";
throw std::string ("\"") + mdy + "\" is not a valid date (d).";
}
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.";
throw std::string ("\"") + mdy + "\" is not a valid date (y).";
}
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.";
throw std::string ("\"") + mdy + "\" is not a valid date (M).";
}
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.";
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).";
}
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.";
throw std::string ("\"") + mdy + "\" is not a valid date (Y).";
}
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.";
throw std::string ("\"") + mdy + "\" is not a valid date (DEFAULT).";
}
++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.";
throw std::string ("\"") + mdy + "\" is not a valid date (VALID).";
// Duplicate Date::Date (const int, const int, const int);
// Convert to epoch.
struct tm t = {0};
t.tm_mday = day;
t.tm_mon = month - 1;
t.tm_year = year - 1900;
t.tm_isdst = -1; // Requests that mktime determine summer time effect.
t.tm_mday = day;
t.tm_mon = month - 1;
t.tm_year = year - 1900;
t.tm_hour = hour;
t.tm_min = minute;
t.tm_sec = second;
mT = mktime (&t);
}
@@ -225,6 +384,25 @@ 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)
{
@@ -255,13 +433,22 @@ 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;
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;
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;
}
formatted += buffer;
@@ -270,6 +457,19 @@ 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)
{
@@ -286,6 +486,22 @@ bool Date::valid (const std::string& input, const std::string& format)
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool Date::valid (const int m, const int d, const int y, const int hr,
const int mi, const int se)
{
if (hr < 0 || hr > 23)
return false;
if (mi < 0 || mi > 59)
return false;
if (se < 0 || se > 59)
return false;
return Date::valid (m, d, y);
}
////////////////////////////////////////////////////////////////////////////////
bool Date::valid (const int m, const int d, const int y)
{
@@ -403,7 +619,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;
@@ -423,17 +639,64 @@ int Date::dayOfWeek (const std::string& input)
{
std::string in = lowerCase (input);
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;
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;
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
{
@@ -455,6 +718,27 @@ 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)
{
@@ -491,6 +775,18 @@ bool Date::operator>= (const Date& rhs)
return mT >= rhs.mT;
}
////////////////////////////////////////////////////////////////////////////////
bool Date::sameHour (const Date& rhs)
{
if (this->year () == rhs.year () &&
this->month () == rhs.month () &&
this->day () == rhs.day () &&
this->hour () == rhs.hour ())
return true;
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Date::sameDay (const Date& rhs)
{
@@ -524,7 +820,7 @@ bool Date::sameYear (const Date& rhs)
////////////////////////////////////////////////////////////////////////////////
Date Date::operator+ (const int delta)
{
return Date::Date (mT + delta);
return Date (mT + delta);
}
////////////////////////////////////////////////////////////////////////////////
@@ -553,7 +849,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;
}
@@ -594,6 +890,13 @@ bool Date::isRelativeDate (const std::string& input)
supported.push_back ("eow");
supported.push_back ("eom");
supported.push_back ("eoy");
supported.push_back ("goodfriday");
supported.push_back ("easter");
supported.push_back ("eastermonday");
supported.push_back ("ascension");
supported.push_back ("pentecost");
supported.push_back ("midsommar");
supported.push_back ("midsommarafton");
std::vector <std::string> matches;
if (autoComplete (in, supported, matches) == 1)
@@ -658,6 +961,60 @@ bool Date::isRelativeDate (const std::string& input)
mT = then.mT;
return true;
}
else if (found == "goodfriday")
{
Date then (Date::easter(today.year()));
mT = then.mT - 86400*2;
return true;
}
else if (found == "easter")
{
Date then (Date::easter(today.year()));
mT = then.mT;
return true;
}
else if (found == "eastermonday")
{
Date then (Date::easter(today.year()));
mT = then.mT + 86400;
return true;
}
else if (found == "ascension")
{
Date then (Date::easter(today.year()));
mT = then.mT + 86400*39;
return true;
}
else if (found == "pentecost")
{
Date then (Date::easter(today.year()));
mT = then.mT + 86400*49;
return true;
}
else if (found == "midsommar")
{
for (int midsommar = 20; midsommar <= 26; midsommar++)
{
Date then (6, midsommar, today.year ());
if (6 == then.dayOfWeek ())
{
mT = then.mT;
return true;
}
}
}
else if (found == "midsommarafton")
{
for (int midsommar = 19; midsommar <= 25; midsommar++)
{
Date then (6, midsommar, today.year ());
if (5 == then.dayOfWeek ())
{
mT = then.mT;
return true;
}
}
}
}
// Support "21st" to indicate the next date that is the 21st day.
@@ -669,13 +1026,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, std::string::npos));
number = atoi (input.substr (0, 2).c_str ());
ordinal = lowerCase (input.substr (2));
}
else
{
number = ::atoi (input.substr (0, 2).c_str ());
ordinal = lowerCase (input.substr (1, std::string::npos));
number = atoi (input.substr (0, 2).c_str ());
ordinal = lowerCase (input.substr (1));
}
// Sanity check.

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham, Federico Hernandez.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -30,6 +30,7 @@
#include <stdio.h>
#include <string>
class Date;
class Date
@@ -38,6 +39,7 @@ public:
Date ();
Date (time_t);
Date (const int, const int, const int);
Date (const int, const int, const int, const int, const int, const int);
Date (const std::string&, const std::string& format = "m/d/Y");
Date (const Date&);
virtual ~Date ();
@@ -45,11 +47,15 @@ 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);
@@ -57,12 +63,16 @@ 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&);
@@ -70,6 +80,7 @@ public:
bool operator> (const Date&);
bool operator<= (const Date&);
bool operator>= (const Date&);
bool sameHour (const Date&);
bool sameDay (const Date&);
bool sameMonth (const Date&);
bool sameYear (const Date&);

144
src/Directory.cpp Normal file
View File

@@ -0,0 +1,144 @@
////////////////////////////////////////////////////////////////////////////////
// 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);
}
}
////////////////////////////////////////////////////////////////////////////////

55
src/Directory.h Normal file
View File

@@ -0,0 +1,55 @@
////////////////////////////////////////////////////////////////////////////////
// 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
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -29,20 +29,32 @@
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "text.h"
#include "util.h"
#include "Duration.h"
////////////////////////////////////////////////////////////////////////////////
Duration::Duration ()
: mDays (0)
: mSecs (0)
, mNegative (false)
{
}
////////////////////////////////////////////////////////////////////////////////
Duration::Duration (time_t input)
{
mDays = input;
if (input < 0)
{
mSecs = -input;
mNegative = true;
}
else
{
mSecs = input;
mNegative = false;
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -54,27 +66,101 @@ Duration::Duration (const std::string& input)
////////////////////////////////////////////////////////////////////////////////
Duration::operator time_t ()
{
return mDays;
return mSecs;
}
////////////////////////////////////////////////////////////////////////////////
Duration::operator std::string ()
{
std::stringstream s;
s << mDays;
s << (mNegative ? -mSecs : mSecs);
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)
{
return mDays < other.mDays;
long left = (long) ( mNegative ? -mSecs : mSecs);
long right = (long) (other.mNegative ? -other.mSecs : other.mSecs);
return left < right;
}
////////////////////////////////////////////////////////////////////////////////
bool Duration::operator> (const Duration& other)
{
return mDays > other.mDays;
long left = (long) ( mNegative ? -mSecs : mSecs);
long right = (long) (other.mNegative ? -other.mSecs : other.mSecs);
return left > right;
}
////////////////////////////////////////////////////////////////////////////////
@@ -108,22 +194,52 @@ bool Duration::valid (const std::string& input) const
if (autoComplete (lower_input, supported, matches) == 1)
return true;
// 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)
// 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))
{
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;
}
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;
}
return false;
@@ -156,43 +272,72 @@ void Duration::parse (const std::string& input)
{
std::string found = matches[0];
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
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
}
// Support \d+ d|w|m|q|y
// 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.
else
{
// 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)
{
if (! isdigit (lower_input[i]) &&
i == length - 1)
{
int number = ::atoi (lower_input.substr (0, i).c_str ());
Nibbler n (lower_input);
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
}
}
n.skipAll (' ');
mNegative = false;
if (n.skip ('-'))
mNegative = true;
int value;
if (n.getUnsignedInt (value))
{
n.skipAll (' ');
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;
}
}
if (mDays == 0)
if (mSecs == 0)
throw std::string ("The duration '") + input + "' was not recognized."; // TODO i18n
}

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -38,16 +38,21 @@ public:
Duration (const std::string&); // Parse
bool operator< (const Duration&);
bool operator> (const Duration&);
Duration& operator= (const Duration&);
~Duration (); // Destructor
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 mDays;
time_t mSecs;
bool mNegative;
};
#endif

286
src/File.cpp Normal file
View File

@@ -0,0 +1,286 @@
////////////////////////////////////////////////////////////////////////////////
// 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 Normal file
View File

@@ -0,0 +1,81 @@
////////////////////////////////////////////////////////////////////////////////
// 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
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -42,17 +42,22 @@ bool Filter::pass (const Record& record) const
{
// Descriptions have special handling such that they are linked to
// annotations, and filtering on description implies identical filtering
// on annotations, and that both filter matches must succeed for the filter
// to succeed overall.
// 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.
if (att->name () == "description")
{
bool description_result = true;
bool pass = true;
int annotation_pass_count = 0;
int annotation_fail_count = 0;
if ((r = record.find (att->name ())) != record.end ())
{
description_result = att->match (r->second);
pass = att->match (r->second);
foreach (ra, record)
{
@@ -66,6 +71,8 @@ bool Filter::pass (const Record& record) const
}
}
}
// Missing attribute implies failure.
else if (! att->match (Att ()))
return false;
@@ -74,12 +81,12 @@ bool Filter::pass (const Record& record) const
// are willing to invest a week understanding and testing it.
if (att->modType (att->mod ()) == "positive")
{
if (! (description_result || annotation_pass_count > 0))
if (! (pass || annotation_pass_count))
return false;
}
else
{
if (!description_result || annotation_fail_count > 0)
if (! (pass && annotation_fail_count == 0))
return false;
}
}
@@ -125,7 +132,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");
throw std::string ("Sequence filtering error - please report this error to support@taskwarrior.org");
if (right.size ())
{

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, 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;

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under

383
src/Hooks.cpp Normal file
View File

@@ -0,0 +1,383 @@
////////////////////////////////////////////////////////////////////////////////
// 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 Normal file
View File

@@ -0,0 +1,80 @@
////////////////////////////////////////////////////////////////////////////////
// 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
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under

View File

@@ -1,11 +1,17 @@
bin_PROGRAMS = task
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
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)

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham, Federico Hernandez.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -26,19 +26,26 @@
////////////////////////////////////////////////////////////////////////////////
#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)
{
}
@@ -46,6 +53,7 @@ Nibbler::Nibbler (const char* input)
////////////////////////////////////////////////////////////////////////////////
Nibbler::Nibbler (const std::string& input)
: mInput (input)
, mLength (input.length ())
, mCursor (0)
{
}
@@ -54,6 +62,7 @@ Nibbler::Nibbler (const std::string& input)
Nibbler::Nibbler (const Nibbler& other)
{
mInput = other.mInput;
mLength = other.mLength;
mCursor = other.mCursor;
}
@@ -63,6 +72,7 @@ Nibbler& Nibbler::operator= (const Nibbler& other)
if (this != &other)
{
mInput = other.mInput;
mLength = other.mLength;
mCursor = other.mCursor;
}
@@ -75,10 +85,10 @@ Nibbler::~Nibbler ()
}
////////////////////////////////////////////////////////////////////////////////
// Extract up until the next c, or EOS.
// Extract up until the next c (but not including) or EOS.
bool Nibbler::getUntil (char c, std::string& result)
{
if (mCursor < mInput.length ())
if (mCursor < mLength)
{
std::string::size_type i = mInput.find (c, mCursor);
if (i != std::string::npos)
@@ -88,8 +98,8 @@ bool Nibbler::getUntil (char c, std::string& result)
}
else
{
result = mInput.substr (mCursor, std::string::npos);
mCursor = mInput.length ();
result = mInput.substr (mCursor);
mCursor = mLength;
}
return true;
@@ -101,7 +111,7 @@ bool Nibbler::getUntil (char c, std::string& result)
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::getUntil (const std::string& terminator, std::string& result)
{
if (mCursor < mInput.length ())
if (mCursor < mLength)
{
std::string::size_type i = mInput.find (terminator, mCursor);
if (i != std::string::npos)
@@ -111,8 +121,38 @@ bool Nibbler::getUntil (const std::string& terminator, std::string& result)
}
else
{
result = mInput.substr (mCursor, std::string::npos);
mCursor = mInput.length ();
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;
}
return true;
@@ -124,7 +164,7 @@ bool Nibbler::getUntil (const std::string& terminator, std::string& result)
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::getUntilOneOf (const std::string& chars, std::string& result)
{
if (mCursor < mInput.length ())
if (mCursor < mLength)
{
std::string::size_type i = mInput.find_first_of (chars, mCursor);
if (i != std::string::npos)
@@ -134,8 +174,8 @@ bool Nibbler::getUntilOneOf (const std::string& chars, std::string& result)
}
else
{
result = mInput.substr (mCursor, std::string::npos);
mCursor = mInput.length ();
result = mInput.substr (mCursor);
mCursor = mLength;
}
return true;
@@ -144,13 +184,135 @@ 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 >= mInput.length ())
return false;
if (mCursor <= mInput.length () - quantity)
if (mCursor < mLength &&
mCursor <= mLength - quantity)
{
mCursor += quantity;
return true;
@@ -162,7 +324,7 @@ bool Nibbler::skipN (const int quantity /* = 1 */)
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::skip (char c)
{
if (mCursor < mInput.length () &&
if (mCursor < mLength &&
mInput[mCursor] == c)
{
++mCursor;
@@ -175,30 +337,14 @@ bool Nibbler::skip (char c)
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::skipAll (char c)
{
std::string::size_type i = mCursor;
while (i < mInput.length () && mInput[i] == c)
++i;
if (i != mCursor)
if (mCursor < mLength)
{
mCursor = i;
return true;
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::skipAllOneOf (const std::string& chars)
{
if (mCursor < mInput.length ())
{
std::string::size_type i = mInput.find_first_not_of (chars, mCursor);
std::string::size_type i = mInput.find_first_not_of (c, mCursor);
if (i == mCursor)
return false;
if (i == std::string::npos)
mCursor = mInput.length (); // Yes, off the end.
mCursor = mLength; // Yes, off the end.
else
mCursor = i;
@@ -209,21 +355,29 @@ bool Nibbler::skipAllOneOf (const std::string& chars)
}
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::getQuoted (char c, std::string& result)
bool Nibbler::skipWS ()
{
std::string::size_type start = mCursor;
if (start < mInput.length () && mInput[start] == c)
return this->skipAllOneOf (" \t\n\r\f");
}
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::skipRx (const std::string& regex)
{
if (mCursor < mLength)
{
++start;
if (start < mInput.length ())
// 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))
{
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;
}
mCursor += results[0].length ();
return true;
}
}
@@ -231,25 +385,19 @@ bool Nibbler::getQuoted (char c, std::string& result)
}
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::getInt (int& result)
bool Nibbler::skipAllOneOf (const std::string& chars)
{
std::string::size_type i = mCursor;
if (i < mInput.length ())
if (mCursor < mLength)
{
if (mInput[i] == '-')
++i;
else if (mInput[i] == '+')
++i;
}
std::string::size_type i = mInput.find_first_not_of (chars, mCursor);
if (i == mCursor)
return false;
while (i < mInput.length () && ::isdigit (mInput[i]))
++i;
if (i == std::string::npos)
mCursor = mLength; // Yes, off the end.
else
mCursor = i;
if (i > mCursor)
{
result = ::atoi (mInput.substr (mCursor, i - mCursor).c_str ());
mCursor = i;
return true;
}
@@ -257,48 +405,54 @@ bool Nibbler::getInt (int& result)
}
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::getUnsignedInt (int& result)
// Peeks ahead - does not move cursor.
char Nibbler::next ()
{
std::string::size_type i = mCursor;
while (i < mInput.length () && ::isdigit (mInput[i]))
++i;
if (mCursor < mLength)
return mInput[mCursor];
if (i > mCursor)
{
result = ::atoi (mInput.substr (mCursor, i - mCursor).c_str ());
mCursor = i;
return true;
}
return false;
return '\0';
}
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::getUntilEOL (std::string& result)
// Peeks ahead - does not move cursor.
std::string Nibbler::next (const int quantity)
{
return getUntil ('\n', result);
if ( mCursor < mLength &&
(unsigned) quantity <= mLength &&
mCursor <= mLength - quantity)
return mInput.substr (mCursor, quantity);
return "";
}
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::getUntilEOS (std::string& result)
void Nibbler::save ()
{
if (mCursor < mInput.length ())
{
result = mInput.substr (mCursor, std::string::npos);
mCursor = mInput.length ();
return true;
}
mSaved = mCursor;
}
return false;
////////////////////////////////////////////////////////////////////////////////
void Nibbler::restore ()
{
mCursor = mSaved;
}
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::depleted ()
{
if (mCursor >= mInput.length ())
if (mCursor >= mLength)
return true;
return false;
}
////////////////////////////////////////////////////////////////////////////////
std::string Nibbler::dump ()
{
return std::string ("Nibbler ")
+ mInput.substr (mCursor)
+ "";
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham, Federico Hernandez.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -41,21 +41,40 @@ 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 getQuoted (char, std::string&);
bool getInt (int&);
bool getUnsignedInt (int&i);
bool getUntilEOL (std::string&);
bool getUntilEOS (std::string&);
bool skipWS ();
bool skipRx (const std::string&);
char next ();
std::string next (const int quantity);
void save ();
void restore ();
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 Normal file
View File

@@ -0,0 +1,217 @@
////////////////////////////////////////////////////////////////////////////////
// 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 Normal file
View File

@@ -0,0 +1,63 @@
////////////////////////////////////////////////////////////////////////////////
// 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
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -37,15 +37,19 @@ extern Context context;
Permission::Permission ()
: needConfirmation (false)
, allConfirmed (false)
, quit (false)
{
// Turning confirmations off is the same as entering "all".
if (context.config.get ("confirmation", true) == false)
if (context.config.getBoolean ("confirmation") == false)
allConfirmed = true;
}
////////////////////////////////////////////////////////////////////////////////
bool Permission::confirmed (const Task& task, const std::string& question)
{
if (quit)
return false;
if (!needConfirmation)
return true;
@@ -57,16 +61,25 @@ bool Permission::confirmed (const Task& task, const std::string& question)
<< task.id
<< " \""
<< task.get ("description")
<< "\""
<< std::endl;
<< "\"";
int answer = confirm3 (question);
if (task.getStatus () == Task::recurring ||
task.has ("parent"))
{
std::cout << " (Recurring)";
}
std::cout << std::endl;
int answer = confirm4 (question);
if (answer == 2)
allConfirmed = true;
if (answer > 0)
if (answer == 1 || answer == 2)
return true;
if (answer == 3)
quit = true;
return false;
}

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -44,6 +44,7 @@ public:
private:
bool needConfirmation;
bool allConfirmed;
bool quit;
};
#endif

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -152,7 +152,17 @@ 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 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 0;
}

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -47,6 +47,7 @@ public:
std::vector <Att> all ();
const std::string get (const std::string&) const;
int get_int (const std::string&) const;
unsigned long get_ulong (const std::string&) const;
void set (const std::string&, const std::string&);
void set (const std::string&, int);
void remove (const std::string&);

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, 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;

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, 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;
}

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -28,6 +28,7 @@
#include "Subst.h"
#include "Nibbler.h"
#include "Context.h"
#include "text.h"
#include "i18n.h"
extern Context context;
@@ -121,31 +122,48 @@ 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.
while ((pattern = description.find (mFrom)) != std::string::npos)
int counter = 0;
pattern = 0;
while ((pattern = find (description, mFrom, pattern, sensitive)) != 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 description = i->value ();
while ((pattern = description.find (mFrom)) != std::string::npos)
std::string annotation = i->value ();
while ((pattern = find (annotation, mFrom, pattern, sensitive)) != std::string::npos)
{
description.replace (pattern, mFrom.length (), mTo);
i->value (description);
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.");
}
}
}
else
{
// Perform first description substitution.
if ((pattern = description.find (mFrom)) != std::string::npos)
if ((pattern = find (description, mFrom, sensitive)) != std::string::npos)
description.replace (pattern, mFrom.length (), mTo);
// Failing that, perform the first annotation substitution.
@@ -154,11 +172,11 @@ void Subst::apply (
std::vector <Att>::iterator i;
for (i = annotations.begin (); i != annotations.end (); ++i)
{
std::string description = i->value ();
if ((pattern = description.find (mFrom)) != std::string::npos)
std::string annotation = i->value ();
if ((pattern = find (annotation, mFrom, sensitive)) != std::string::npos)
{
description.replace (pattern, mFrom.length (), mTo);
i->value (description);
annotation.replace (pattern, mFrom.length (), mTo);
i->value (annotation);
break;
}
}

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -62,6 +62,7 @@ public:
int gc (); // Clean up pending
int nextId ();
void undo ();
void merge (const std::string&);
private:
FILE* openAndLock (const std::string&);
@@ -75,11 +76,9 @@ private:
int mId;
std::vector <Task> mPending; // Contents of pending.data
std::vector <Task> mCompleted; // Contents of pending.data
std::vector <Task> mNew; // Uncommitted new tasks
std::vector <Task> mModified; // Uncommitted modified tasks
// TODO Need cache of raw file contents to preserve comments.
};
#endif

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// task - a command line task list manager.
//
// Copyright 2006 - 2009, Paul Beckingham.
// Copyright 2006 - 2010, Paul Beckingham.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
@@ -52,6 +52,9 @@
#include "Timer.h"
#include "text.h"
#include "util.h"
#include "Context.h"
extern Context context;
////////////////////////////////////////////////////////////////////////////////
Table::Table ()
@@ -60,7 +63,6 @@ Table::Table ()
, mDashedUnderline (false)
, mTablePadding (0)
, mTableWidth (0)
, mSuppressWS (false)
{
}
@@ -70,22 +72,9 @@ Table::~Table ()
}
////////////////////////////////////////////////////////////////////////////////
void Table::setTableColor (Text::color fg, Text::color bg)
void Table::setTableAlternateColor (const Color& c)
{
mFg["table"] = Text::colorName (fg);
mBg["table"] = Text::colorName (bg);
}
////////////////////////////////////////////////////////////////////////////////
void Table::setTableFg (Text::color c)
{
mFg["table"] = Text::colorName (c);
}
////////////////////////////////////////////////////////////////////////////////
void Table::setTableBg (Text::color c)
{
mBg["table"] = Text::colorName (c);
alternate = c;
}
////////////////////////////////////////////////////////////////////////////////
@@ -125,37 +114,12 @@ int Table::addColumn (const std::string& col)
return mColumns.size () - 1;
}
////////////////////////////////////////////////////////////////////////////////
void Table::setColumnColor (int column, Text::color fg, Text::color bg)
{
char id[12];
sprintf (id, "col:%d", column);
mFg[id] = Text::colorName (fg);
mBg[id] = Text::colorName (bg);
}
////////////////////////////////////////////////////////////////////////////////
void Table::setColumnFg (int column, Text::color c)
{
char id[12];
sprintf (id, "col:%d", column);
mFg[id] = Text::colorName (c);
}
////////////////////////////////////////////////////////////////////////////////
void Table::setColumnBg (int column, Text::color c)
{
char id[12];
sprintf (id, "col:%d", column);
mBg[id] = Text::colorName (c);
}
////////////////////////////////////////////////////////////////////////////////
void Table::setColumnUnderline (int column)
{
char id[12];
sprintf (id, "col:%d", column);
mUnderline[id] = Text::underline;
mUnderline[id] = Color (Color::nocolor, Color::nocolor, true, false, false);
}
////////////////////////////////////////////////////////////////////////////////
@@ -203,28 +167,11 @@ int Table::addRow ()
}
////////////////////////////////////////////////////////////////////////////////
void Table::setRowColor (const int row, const Text::color fg, const Text::color bg)
void Table::setRowColor (const int row, const Color& c)
{
char id[12];
sprintf (id, "row:%d", row);
mFg[id] = Text::colorName (fg);
mBg[id] = Text::colorName (bg);
}
////////////////////////////////////////////////////////////////////////////////
void Table::setRowFg (const int row, const Text::color c)
{
char id[12];
sprintf (id, "row:%d", row);
mFg[id] = Text::colorName (c);
}
////////////////////////////////////////////////////////////////////////////////
void Table::setRowBg (const int row, const Text::color c)
{
char id[12];
sprintf (id, "row:%d", row);
mBg[id] = Text::colorName (c);
mColor[id].blend (c);
}
////////////////////////////////////////////////////////////////////////////////
@@ -232,50 +179,23 @@ void Table::addCell (const int row, const int col, const std::string& data)
{
unsigned int length = 0;
if (mSuppressWS)
if (mCommify.find (col) != mCommify.end ())
mData.add (row, col, commify (data));
else
mData.add (row, col, data);
// For multi-line cells, find the longest line.
if (data.find ("\n") != std::string::npos)
{
std::string data2;
if (mCommify.find (col) != mCommify.end ())
data2 = commify (data);
else
data2 = data;
clean (data2);
// For multi-line cells, find the longest line.
if (data2.find ("\n") != std::string::npos)
{
length = 0;
std::vector <std::string> lines;
split (lines, data2, "\n");
for (unsigned int i = 0; i < lines.size (); ++i)
if (lines[i].length () > length)
length = lines[i].length ();
}
else
length = data2.length ();
mData.add (row, col, data2);
length = 0;
std::vector <std::string> lines;
split (lines, data, "\n");
for (unsigned int i = 0; i < lines.size (); ++i)
if (lines[i].length () > length)
length = lines[i].length ();
}
else
{
if (mCommify.find (col) != mCommify.end ())
mData.add (row, col, commify (data));
else
mData.add (row, col, data);
// For multi-line cells, find the longest line.
if (data.find ("\n") != std::string::npos)
{
length = 0;
std::vector <std::string> lines;
split (lines, data, "\n");
for (unsigned int i = 0; i < lines.size (); ++i)
if (lines[i].length () > length)
length = lines[i].length ();
}
else
length = data.length ();
}
length = data.length ();
// Automatically maintain max width.
mMaxDataWidth[col] = max (mMaxDataWidth[col], (int)length);
@@ -302,7 +222,7 @@ void Table::addCell (const int row, const int col, const int data)
mData.add (row, col, value);
// Automatically maintain max width.
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) strlen (value));
}
////////////////////////////////////////////////////////////////////////////////
@@ -317,7 +237,7 @@ void Table::addCell (const int row, const int col, const float data)
mData.add (row, col, value);
// Automatically maintain max width.
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) strlen (value));
}
////////////////////////////////////////////////////////////////////////////////
@@ -332,32 +252,15 @@ void Table::addCell (const int row, const int col, const double data)
mData.add (row, col, value);
// Automatically maintain max width.
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) strlen (value));
}
////////////////////////////////////////////////////////////////////////////////
void Table::setCellColor (const int row, const int col, const Text::color fg, const Text::color bg)
void Table::setCellColor (const int row, const int col, const Color& c)
{
char id[24];
sprintf (id, "cell:%d,%d", row, col);
mFg[id] = Text::colorName (fg);
mBg[id] = Text::colorName (bg);
}
////////////////////////////////////////////////////////////////////////////////
void Table::setCellFg (const int row, const int col, const Text::color c)
{
char id[24];
sprintf (id, "cell:%d,%d", row, col);
mFg[id] = Text::colorName (c);
}
////////////////////////////////////////////////////////////////////////////////
void Table::setCellBg (const int row, const int col, const Text::color c)
{
char id[24];
sprintf (id, "cell:%d,%d", row, col);
mBg[id] = Text::colorName (c);
mColor[id] = c;
}
////////////////////////////////////////////////////////////////////////////////
@@ -371,83 +274,51 @@ std::string Table::getCell (const int row, const int col)
}
////////////////////////////////////////////////////////////////////////////////
Text::color Table::getFg (const int row, const int col)
Color Table::getColor (const int index, const int row, const int col)
{
char idCell[24];
sprintf (idCell, "cell:%d,%d", row, col);
if (mFg.find (idCell) != mFg.end ())
return Text::colorCode (mFg[idCell]);
// Color defaults to trivial.
Color c;
char idRow[12];
sprintf (idRow, "row:%d", row);
if (mFg.find (idRow) != mFg.end ())
return Text::colorCode (mFg[idRow]);
// For alternating rows, use Table::alternate.
std::map <std::string, Color>::iterator i;
char id[24];
char idCol[12];
sprintf (idCol, "col:%d", col);
if (mFg.find (idCol) != mFg.end ())
return Text::colorCode (mFg[idCol]);
if (index % 2)
c = alternate;
if (mFg.find ("table") != mFg.end ())
return Text::colorCode (mFg["table"]);
/*
// TODO Obsolete - this is not used. Consider removal.
// Blend with a table color, if specified.
if ((i = mColor.find ("table")) != mColor.end ())
c.blend (i->second);
return Text::nocolor;
// Blend with a column color, if specified.
sprintf (id, "col:%d", col);
if ((i = mColor.find (id)) != mColor.end ())
c.blend (i->second);
*/
// Blend with a row color, if specified.
sprintf (id, "row:%d", row);
if ((i = mColor.find (id)) != mColor.end ())
c.blend (i->second);
// Blend with a cell color, if specified.
sprintf (id, "cell:%d,%d", row, col);
if ((i = mColor.find (id)) != mColor.end ())
c.blend (i->second);
return c;
}
////////////////////////////////////////////////////////////////////////////////
Text::color Table::getHeaderFg (int col)
Color Table::getHeaderUnderline (int col)
{
char idCol[12];
sprintf (idCol, "col:%d", col);
return mFg.find (idCol) != mFg.end () ? Text::colorCode (mFg[idCol])
: mFg.find ("table") != mFg.end () ? Text::colorCode (mFg["table"])
: Text::nocolor;
}
////////////////////////////////////////////////////////////////////////////////
Text::color Table::getBg (const int row, const int col)
{
char idCell[24];
sprintf (idCell, "cell:%d,%d", row, col);
if (mBg.find (idCell) != mBg.end ())
return Text::colorCode (mBg[idCell]);
char idRow[12];
sprintf (idRow, "row:%d", row);
if (mBg.find (idRow) != mBg.end ())
return Text::colorCode (mBg[idRow]);
char idCol[12];
sprintf (idCol, "col:%d", col);
if (mBg.find (idCol) != mBg.end ())
return Text::colorCode (mBg[idCol]);
if (mBg.find ("table") != mBg.end ())
return Text::colorCode (mBg["table"]);
return Text::nocolor;
}
////////////////////////////////////////////////////////////////////////////////
Text::color Table::getHeaderBg (int col)
{
char idCol[12];
sprintf (idCol, "col:%d", col);
return mBg.find (idCol) != mBg.end () ? Text::colorCode (mBg[idCol])
: mBg.find ("table") != mBg.end () ? Text::colorCode (mBg["table"])
: Text::nocolor;
}
////////////////////////////////////////////////////////////////////////////////
Text::color Table::getHeaderUnderline (int col)
{
char idCol[12];
sprintf (idCol, "col:%d", col);
return mUnderline.find (idCol) != mUnderline.end () ? Text::underline
: Text::nocolor;
return mUnderline.find (idCol) != mUnderline.end () ? mUnderline[idCol]
: Color ();
}
////////////////////////////////////////////////////////////////////////////////
@@ -584,36 +455,24 @@ const std::string Table::formatHeader (
{
assert (width > 0);
Text::color fg = getHeaderFg (col);
Text::color bg = getHeaderBg (col);
std::string data = mColumns[col];
Text::color decoration = getHeaderUnderline (col);
std::string data = mColumns[col];
Color c = getHeaderUnderline (col);
int gap = width - strippedLength (data);
std::string pad = "";
std::string intraPad = "";
std::string preJust = "";
std::string attrOn = "";
std::string attrOff = "";
std::string pad = std::string (padding, ' ');
// TODO When the following is replaced by:
// std::string postJust = std::string (gap, ' ');
// two unit tests fail.
std::string postJust = "";
for (int i = 0; i < padding; ++i)
pad += " ";
// Place the value within the available space - justify.
int gap = width - data.length ();
for (int i = 0; i < gap; ++i)
postJust += " ";
std::string intraPad = "";
if (col < (signed) mColumns.size () - 1)
for (int i = 0; i < getIntraPadding (); ++i)
intraPad += " ";
intraPad = std::string (getIntraPadding (), ' ');
return Text::colorize (
fg, bg,
Text::colorize (
decoration, Text::nocolor,
pad + preJust + data + postJust + pad) + intraPad);
return c.colorize (pad + data + postJust + pad) + intraPad;
}
////////////////////////////////////////////////////////////////////////////////
@@ -638,36 +497,22 @@ const std::string Table::formatHeaderDashedUnderline (
{
assert (width > 0);
Text::color fg = getHeaderFg (col);
Text::color bg = getHeaderBg (col);
Text::color decoration = getHeaderUnderline (col);
Color c = getHeaderUnderline (col);
std::string data = "";
for (int i = 0; i < width; ++i)
data += '-';
std::string pad = "";
std::string data = std::string (width, '-');
std::string pad = std::string (padding, ' ');
std::string intraPad = "";
std::string attrOn = "";
std::string attrOff = "";
for (int i = 0; i < padding; ++i)
pad += " ";
// Place the value within the available space - justify.
if (col < (signed) mColumns.size () - 1)
for (int i = 0; i < getIntraPadding (); ++i)
intraPad += " ";
intraPad = std::string (getIntraPadding (), ' ');
return Text::colorize (
fg, bg,
Text::colorize (
decoration, Text::nocolor,
pad + data + pad) + intraPad);
return c.colorize (pad + data + pad) + intraPad;
}
////////////////////////////////////////////////////////////////////////////////
void Table::formatCell (
const int index,
const int row,
const int col,
const int width,
@@ -677,20 +522,15 @@ void Table::formatCell (
{
assert (width > 0);
Text::color fg = getFg (row, col);
Text::color bg = getBg (row, col);
Color c = getColor (index, row, col);
just justification = getJustification (row, col);
std::string data = getCell (row, col);
std::string pad = "";
std::string pad = std::string (padding, ' ');
std::string intraPad = "";
for (int i = 0; i < padding; ++i)
pad += " ";
if (col < (signed) mColumns.size () - 1)
for (int i = 0; i < getIntraPadding (); ++i)
intraPad += " ";
intraPad = std::string (getIntraPadding (), ' ');
// Break the text into chunks of width characters.
std::string preJust;
@@ -706,38 +546,24 @@ void Table::formatCell (
postJust = "";
if (justification == left)
for (int i = 0; i < gap; ++i)
postJust += " ";
postJust = std::string (gap, ' ');
else if (justification == right)
for (int i = 0; i < gap; ++i)
preJust += " ";
preJust = std::string (gap, ' ');
else if (justification == center)
{
for (int i = 0; i < gap / 2; ++i)
preJust += " ";
for (size_t i = 0; i < gap - preJust.length (); ++i)
postJust += " ";
preJust = std::string (gap / 2, ' ');
postJust = std::string (gap - preJust.length (), ' ');
}
lines.push_back (
Text::colorize (fg, bg, pad + preJust + chunks[chunk] + postJust + pad + intraPad));
lines.push_back (c.colorize (pad + preJust + chunks[chunk] + postJust + pad + intraPad));
}
// The blank is used to vertically pad cells that have blank lines.
pad = "";
for (int i = 0; i < width; ++i)
pad += " ";
pad = std::string (width, ' ');
blank = Text::colorize (fg, bg, pad + intraPad);
}
////////////////////////////////////////////////////////////////////////////////
void Table::suppressWS ()
{
mSuppressWS = true;
blank = c.colorize (pad + intraPad);
}
////////////////////////////////////////////////////////////////////////////////
@@ -746,6 +572,12 @@ void Table::setDateFormat (const std::string& dateFormat)
mDateFormat = dateFormat;
}
////////////////////////////////////////////////////////////////////////////////
void Table::setReportName (const std::string& reportName)
{
mReportName = reportName;
}
////////////////////////////////////////////////////////////////////////////////
int Table::rowCount ()
{
@@ -758,79 +590,6 @@ int Table::columnCount ()
return mColumns.size ();
}
////////////////////////////////////////////////////////////////////////////////
// Removes extraneous output characters, such as:
// - removal of redundant color codes:
// ^[[31mName^[[0m ^[[31mValue^[[0m -> ^[[31mName Value^[[0m
//
// This method is a work in progress.
void Table::optimize (std::string& output) const
{
// int start = output.length ();
/*
Well, how about that!
The benchmark.t unit test adds a 1000 tasks, fiddles with some of them, then
runs a series of reports. The results are timed, and look like this:
1000 tasks added in 3 seconds
600 tasks altered in 32 seconds
'task ls' in 26 seconds
'task list' in 17 seconds
'task list pri:H' in 19 seconds
'task list +tag' in 0 seconds
'task list project_A' in 0 seconds
'task long' in 29 seconds
'task completed' in 2 seconds
'task history' in 0 seconds
'task ghistory' in 0 seconds
This performance is terrible. To identify the worst offender, Various Timer
objects were added in Table::render, assuming that table sorting is the major
bottleneck. But no, it is Table::optimize that is the problem. After
commenting out this method, the results are now:
1000 tasks added in 3 seconds
600 tasks altered in 29 seconds
'task ls' in 0 seconds
'task list' in 0 seconds
'task list pri:H' in 1 seconds
'task list +tag' in 0 seconds
'task list project_A' in 0 seconds
'task long' in 0 seconds
'task completed' in 0 seconds
'task history' in 0 seconds
'task ghistory' in 0 seconds
Much better.
*/
char patterns[5][16] =
{
" \n",
" \n",
" \n",
" \n",
};
std::string::size_type trailing;
for (int i = 0; i < 4; i++)
{
do
{
trailing = output.find (patterns[i]);
if (trailing != std::string::npos)
output.replace (trailing, strlen (patterns[i]), "\n");
}
while (trailing != std::string::npos);
}
// std::cout << int ((100 * (start - output.length ()) / start))
// << "%" << std::endl;
}
////////////////////////////////////////////////////////////////////////////////
// Combsort11, with O(n log n) average, O(n log n) worst case performance.
//
@@ -876,7 +635,7 @@ void Table::sort (std::vector <int>& order)
if (gap > 1)
{
gap = (int) ((float)gap / 1.3);
if (gap == 10 or gap == 9)
if (gap == 10 || gap == 9)
gap = 11;
}
@@ -973,6 +732,54 @@ void Table::sort (std::vector <int>& order)
}
break;
case ascendingDueDate:
{
if ((std::string)*left != "" && (std::string)*right == "")
break;
else if ((std::string)*left == "" && (std::string)*right != "")
SWAP
else
{
std::string format = context.config.get ("report." + mReportName + ".dateformat");
if (format == "")
format = context.config.get ("dateformat.report");
if (format == "")
format = context.config.get ("dateformat");
Date dl ((std::string)*left, format);
Date dr ((std::string)*right, format);
if (dl > dr)
SWAP
}
}
break;
case descendingDueDate:
{
if ((std::string)*left != "" && (std::string)*right == "")
break;
else if ((std::string)*left == "" && (std::string)*right != "")
SWAP
else
{
std::string format = context.config.get ("report." + mReportName + ".dateformat");
if (format == "")
format = context.config.get ("dateformat.report");
if (format == "")
format = context.config.get ("dateformat");
Date dl ((std::string)*left, format);
Date dr ((std::string)*right, format);
if (dl < dr)
SWAP
}
}
break;
case ascendingPriority:
if (((std::string)*left == "" && (std::string)*right != "") ||
((std::string)*left == "M" && (std::string)*right == "L") ||
@@ -1014,35 +821,13 @@ void Table::sort (std::vector <int>& order)
}
////////////////////////////////////////////////////////////////////////////////
void Table::clean (std::string& value)
{
size_t start = 0;
size_t pos;
while ((pos = value.find ('\t', start)) != std::string::npos)
{
value.replace (pos, 1, " ");
start = pos; // Not pos + 1, because we have a destructive operation, and
// this is ultimately safer.
}
while ((pos = value.find ('\r', start)) != std::string::npos)
{
value.replace (pos, 1, " ");
start = pos;
}
while ((pos = value.find ('\n', start)) != std::string::npos)
{
value.replace (pos, 1, " ");
start = pos;
}
}
////////////////////////////////////////////////////////////////////////////////
const std::string Table::render (int maximum /* = 0 */)
const std::string Table::render (int maxrows /* = 0 */, int maxlines /* = 0 */)
{
Timer t ("Table::render");
// May not exceed maxlines, if non-zero.
int renderedlines = 0;
calculateColumnWidths ();
// Print column headers in column order.
@@ -1063,8 +848,12 @@ const std::string Table::render (int maximum /* = 0 */)
}
output += "\n";
++renderedlines;
if (underline.length ())
{
output += underline + "\n";
++renderedlines;
}
// Determine row order, according to sort options.
std::vector <int> order;
@@ -1075,14 +864,17 @@ const std::string Table::render (int maximum /* = 0 */)
if (mSortColumns.size ())
sort (order);
// If a non-zero maximum is specified, then it limits the number of rows of
// If a non-zero maxrows is specified, then it limits the number of rows of
// the table that are rendered.
int limit = mRows;
if (maximum != 0)
limit = min (maximum, mRows);
int limitrows = mRows;
if (maxrows != 0)
limitrows = min (maxrows, mRows);
// If a non-zero maxlines is specified, then it limits the number of lines
// of output from the table that are rendered.
// Print all rows.
for (int row = 0; row < limit; ++row)
for (int row = 0; row < limitrows; ++row)
{
std::vector <std::vector <std::string> > columns;
std::vector <std::string> blanks;
@@ -1093,6 +885,7 @@ const std::string Table::render (int maximum /* = 0 */)
std::vector <std::string> lines;
std::string blank;
formatCell (
row,
order[row],
col,
mCalculatedWidth[col],
@@ -1119,6 +912,11 @@ const std::string Table::render (int maximum /* = 0 */)
// Trim right.
output.erase (output.find_last_not_of (" ") + 1);
output += "\n";
++renderedlines;
if (maxlines != 0 && renderedlines >= maxlines)
break;
}
}
else
@@ -1127,9 +925,11 @@ const std::string Table::render (int maximum /* = 0 */)
output.erase (output.find_last_not_of (" ") + 1);
output += "\n";
}
if (maxlines != 0 && renderedlines >= maxlines)
break;
}
optimize (output);
return output;
}

Some files were not shown because too many files have changed in this diff Show More