Compare commits

..

279 Commits

Author SHA1 Message Date
Federico Hernandez
b9dc0813d9 Version number and release date for 2.4.2 2015-03-16 00:01:52 +01:00
Paul Beckingham
25c687e1ec Themes
- Updated default theme to match dark-16 or dark-256.
2015-03-15 12:16:40 -04:00
Paul Beckingham
6e98bbbd85 Themes
- Consistency tweaks across all themes.
2015-03-15 12:06:02 -04:00
Paul Beckingham
06c8976be5 Themes
- Changed color.error to white on red.
- Changed color.debug to blue.
- Made color.active more yellow.
- Added color.scheduled.
- Changed due, due.today and overdue to be more yellow.
- Changed color.summary.background to match theme.
- Changed color.undo to match theme.
2015-03-15 11:55:32 -04:00
Paul Beckingham
d13a5a3f47 Themes
- Changed color.error to white on red.
- Changed color.debug to blue.
- Added color.scheduled.
- Changed color.due, color.overdue to match theme.
- Added color.summary.background.
2015-03-15 11:46:00 -04:00
Paul Beckingham
b662afa1ff Themes
- Removed color.completed, color.deleted.
- Darkened color.alternate.
- Changed color.debug to blue.
- Changed color.error to white on red.
- Added fg to color.scheduled.
- Changed color.tag.next to match theme.
- Changed color.undo to match theme.
2015-03-15 11:37:57 -04:00
Paul Beckingham
bde83d3195 Themes
- Darkened color.alternate.
- Changed color.debug to blue.
- Changed color.error to white on red.
- Changed color.warning to match theme.
- Removed color.completed, color.deleted.
- Added fg to color.scheduled.
- Added color.summary.background.
- Darkened color.undo.before.
2015-03-15 11:32:51 -04:00
Paul Beckingham
0edb7e57f6 Themes
- Changed color.debug to blue.
- Change color.error to white on red.
- Added fg to burndown and history.
- Added color.summary.bckground.
- Changed undo colors to match theme.
2015-03-15 11:27:55 -04:00
Paul Beckingham
4569d2da24 Themes
- Changed color.debug to a common blue.
- Changed color.error to white on red.
- Added fg to color.calendar.due.
- Fixed typo for color.synd.added.
2015-03-15 11:21:13 -04:00
Paul Beckingham
6b00f08794 Themes
- Removed color.completed, color.deleted.
- Made color.scheduled more blue than green.
- Made summary light on dark blue.
2015-03-15 11:16:14 -04:00
Paul Beckingham
e83809c6aa Themes
- Lightened color.alternate.
- Changed color.debug to a common blue.
2015-03-15 11:12:26 -04:00
Paul Beckingham
39b736d23e Themes
- Changed color.debug to a readable color.
- Added fg to color.scheduled.
- Removed color.completed, color.deleted.
2015-03-15 11:08:34 -04:00
Paul Beckingham
3e90554f40 Themes
- Removed background color from debug.
- Removed color.completed, color.deleted.
- Darkened color.active, for contrast.
- Removed color.pri.none, which was the same as color.pri.M.
- Inverted color.calendar.holiday.
- Changed burndown and history to use red, yellow, green.

+color.history.delete=color0 on rgb550

 # Report: summary
 color.summary.bar=on rgb141
@@ -82,7 +82,7 @@ color.summary.background=on gray20
 # Command: calendar
 color.calendar.due=on rgb343
 color.calendar.due.today=on rgb353
-color.calendar.holiday=rgb420
+color.calendar.holiday=color0 on rgb530
 color.calendar.overdue=on rgb533
 color.calendar.today=rgb005
 color.calendar.weekend=on gray21
2015-03-15 11:02:27 -04:00
Paul Beckingham
4690b1a6cb Themes
- Removed background color from debug messages.
- Removed color.completed and color.deleted.
- Swapped the overdue magenta for red.
- Changed burndown and history to use red, yellow, green.
- Inverted the calendar holiday colors.
- Removed background from color.calendar.weeknumber.
2015-03-15 10:52:28 -04:00
Paul Beckingham
ce1a7b921c Themes
- Removed all the 16-color names, which do not apply to the solarized palette.
- Modified color.blocking and color.blocked so that both fg and bg are specified.
- Modified color.burndown.* and color.history.* to use red, yellow, green.
2015-03-15 10:40:11 -04:00
Paul Beckingham
7a1645bba3 Themes
- Fixed color.burndown.done and color.burndown.started, which were two different
  shades of red.
- Fixed color.history.done, which was dark gray and should be closer to green.
2015-03-15 10:13:08 -04:00
Paul Beckingham
9f1b3e0d56 Themes
- Added run.default to test the default theme.
2015-03-15 10:08:47 -04:00
Paul Beckingham
0af8b1dbab Themes
- Added 'task color legend' to the scripts to make it easier to spot broken
  themes.
- Removed the 'run' script, which is no longer used.
2015-03-15 09:09:54 -04:00
Tomas Babej
1465bcb918 Context: Do not apply context for the export command 2015-03-14 17:28:20 -04:00
Paul Beckingham
4eb70e68b7 TW-63
- TW-63 indicators for UDAs (thanks to Datvid Patrick).
- Note that this was implemented in 2.4.0 and tracked via the duplicate
  issue TW-161.
2015-03-14 11:57:22 -04:00
Renato Alves
cd216bd4fd simpletap - Add color to test state when running on tty 2015-03-12 20:49:50 +00:00
Renato Alves
ac4a5c6d62 simpletap - Include scenario for expected failures
* Expected failures are treated as "ok" followed by a report of what went wrong
2015-03-12 20:00:02 +00:00
Renato Alves
a67593decf Tests - merge bug.1110.t with filter.t and convert to python 2015-03-12 19:34:58 +00:00
Renato Alves
7be294267b Tests - rename bug.1065.t to custom.config.t and convert to python 2015-03-11 15:32:54 +00:00
Renato Alves
920cdcca10 Tests - convert bug.1063.t to python 2015-03-11 15:32:54 +00:00
Paul Beckingham
7cc410f58e Documentation
- Fixed obsolete wiki reference in the main man page (thanks to David Patrick).
2015-03-11 08:46:05 -04:00
Paul Beckingham
5d42c0f6b6 Themes
- Updated the README for this version, not the previous one.
2015-03-10 19:17:17 -04:00
Renato Alves
cff680d074 Tests - merge bug.1056.t with project.t and convert to python 2015-03-10 19:18:55 +00:00
Renato Alves
dda190703e Tests - merge basic.t with version.t and convert to python
* _version now outputs "2.4.2 (git-ref)" instead of only "git-ref" when building from git.
* Changelog updated accordingly.
2015-03-09 16:02:26 +00:00
Wilhelm Schuermann
281edcc38f Unit Tests
- The Sith must never be allowed to regain their power over us.
2015-03-08 09:04:39 -04:00
Paul Beckingham
87d00698db Unit Tests
- Successful hook tests now query the task to make sure processing continued.
  Could be better.
2015-03-07 16:18:44 -05:00
Paul Beckingham
19674ee339 Unit Tests
- Specifically set certain color rules to '' to override default theme.
2015-03-07 16:11:38 -05:00
Paul Beckingham
9f654a5c95 Unit Tests
- Test was wrong.
2015-03-07 16:06:18 -05:00
Paul Beckingham
87e9578666 Unit Tests
- Combined all the separate color rule tests into one script, and converted
  it to Python.
2015-03-07 13:29:59 -05:00
Paul Beckingham
e3ec52f6ca Unit Tests
- Cleaned up color.t.cpp.
2015-03-07 12:14:39 -05:00
Paul Beckingham
70c3d9845c Unіt Tests
- Merged width.t.cpp into utf8.t.cpp.
2015-03-07 11:59:37 -05:00
Paul Beckingham
9d1c4101c2 Unit Tests
- Renamed feature.exit.t to shell.t so that this test script is known to
  contain shell-interaction tests.
- Converted to Python.
2015-03-07 11:48:42 -05:00
Paul Beckingham
44ed974fa2 Unit Tests
- Fixed all the test descriptions.
2015-03-07 11:44:44 -05:00
Paul Beckingham
3cf7a701c8 Conversion
- Updated script for BSD.
2015-03-07 11:38:52 -05:00
Paul Beckingham
d390f99fc5 Unit Tests
- Simplified the msg.t.cpp tests.
2015-03-07 11:35:48 -05:00
Paul Beckingham
a2cae67644 Unit Tests
- Converted filter-prefix.t to Python.  Still needs a rename and possible merge
  with other tests.
2015-03-07 11:11:18 -05:00
Renato Alves
ebd6977480 Tests - merge bug.1044 into project.t and convert to python 2015-03-06 16:44:28 +00:00
Renato Alves
276050ce0b Tests - rename bug.1043.t to completion.t and convert to python 2015-03-06 15:19:04 +00:00
Renato Alves
197815a3a7 Tests - convert bug.1036.t to python 2015-03-06 15:10:07 +00:00
Paul Beckingham
5e8426f0cc Config
- The 'next' report was not sㄡrted by urgency, which is wrong (thanks
  to Adam Coddington).
2015-03-05 18:26:43 -05:00
Wilhelm Schuermann
138360b7bc Hooks
- Fixed on-modify hook regression which stopped hooks from modifying
  tasks.  On a related note, more hooks tests are definitely needed.
2015-03-05 07:21:30 -05:00
Renato Alves
7fa3c5ac84 Tests - convert bug.1031.t to python 2015-03-04 00:54:40 +00:00
Renato Alves
b5da4acab9 Tests - run_all script now exports TASKD_USE_PATH=1 2015-03-03 01:50:57 +00:00
Renato Alves
180c382de2 Tests - Finer control on which binaries to look for on PATH
* It is now possible to control whether taskw and/or taskd are looked up
on the PATH by setting TASK_USE_PATH/TASKD_USE_PATH to "1"
2015-03-03 01:46:53 +00:00
Renato Alves
23d4e2b3c9 Tests - rename bug.1023.t to feature.default.project.t and convert to python
Also add testcase from TW-1287 and TW-1279 which are part of the same feature
2015-03-03 01:25:45 +00:00
Paul Beckingham
96185cbd61 Merge branch '2.4.2' of ssh://git.tasktools.org/tm/task into 2.4.2 2015-03-02 16:17:09 -05:00
Paul Beckingham
7665d13d42 Duration
- Removed legacy duration value mapping, which causes much performance
  degradation.
2015-03-02 16:16:39 -05:00
Paul Beckingham
a40967a324 Unit Tests
- Fixed project.t errors.
2015-03-02 11:35:19 -05:00
Paul Beckingham
01feec568b Merge branch '2.4.2' of ssh://git.tasktools.org/tm/task into 2.4.2 2015-03-02 09:35:45 -05:00
Paul Beckingham
104aeb3905 TDB2
- Commented and reorganized for threading.
2015-03-02 09:33:57 -05:00
Tomas Babej
f0cc0151b7 TDB2: Explicitly mark updates done as addition to optimize performance
We are able to avoid loading the completed.data in certain scenarios.
2015-02-28 16:54:09 -05:00
Tomas Babej
48be6986c2 Make tasks affect statistics of super-projects 2015-02-28 09:34:10 -05:00
Tomas Babej
ffd6465661 CmdProjects: Enforce garbage collector 2015-02-28 09:33:36 -05:00
Paul Beckingham
58e62711f3 Virtual Tags
- The 'info' command now shows virtual tags.
2015-02-26 21:09:50 -05:00
Tomas Babej
3b9d88a87b completion: Add bash completion for contexts 2015-02-26 20:51:39 -05:00
Paul Beckingham
aa8cd54142 TW-1535
- TW-1535 move default listing-break from list to ls (thanks to David Patrick).
2015-02-24 22:57:56 -05:00
Paul Beckingham
651ac3f174 Tw-1551
- TW-1551 Unable to get a UDA value from DOM (thanks to Tomas Babej).
2015-02-24 22:35:18 -05:00
Paul Beckingham
ea78200ae3 TW-1549
- TW-1549 task annotate hangs with specific text pattern (thanks to Alexandre
          de Verteuil).
2015-02-24 22:04:05 -05:00
Paul Beckingham
ad89a90d12 TW-1550
- TW-1550 _contexts helper-command (thanks to David Patrick).
2015-02-24 20:43:28 -05:00
Tomas Babej
85d0e1789a CmdContext: Validate context's filter upon definition 2015-02-24 16:55:28 -05:00
Tomas Babej
e19c99ce1e CmdContext: Fix incorrect exception handling 2015-02-24 16:53:23 -05:00
Tomas Babej
0868ba757c CmdConfig: Do not leave empty line upon variable removal 2015-02-24 16:52:55 -05:00
Tomas Babej
bf5f246168 man: Fix copy-paste error in task.1 2015-02-24 16:51:28 -05:00
Tomas Babej
9748fa2ab1 tests: Fix asserted strings in context tests 2015-02-24 16:51:20 -05:00
Tomas Babej
1a0f479394 CmdContext: Add helpful hint to output when setting context 2015-02-24 16:51:05 -05:00
Wilhelm Schuermann
e2f35a1a06 Hooks
- onAdd, onExit, onLaunch and onModify hooks now output feedback messages
  as footnotes when hooks exit with status 0, as per hooks documentation.
2015-02-24 16:45:23 -05:00
Paul Beckingham
394acae790 CmdContext
- Trivіal code edits.
2015-02-23 20:07:53 -05:00
Tomas Babej
e8d385119a Update NEWS and ChangeLog files with the info about the context 2015-02-23 19:25:40 -05:00
Tomas Babej
070fdf60fa localization: Update other locale files 2015-02-23 19:22:06 -05:00
Tomas Babej
1278226c16 CmdContext: Localize the hardcoded strings 2015-02-23 19:22:01 -05:00
Tomas Babej
98410cff42 CmdShow: Add context related variables 2015-02-23 19:21:57 -05:00
Tomas Babej
ee23a099f2 CmdContext: Minor style and message changes 2015-02-23 19:21:50 -05:00
Tomas Babej
0ab1dc0c9c man: Update task and taskrc manpages with the information about context 2015-02-23 19:21:46 -05:00
Tomas Babej
c2a9bb65e6 tests: Add tests for the context feature 2015-02-23 19:20:00 -05:00
Tomas Babej
75cf742a55 tests: Add taskrc_content property 2015-02-23 19:19:55 -05:00
Tomas Babej
dc0502dd9f CLI: Apply context filter directly in getFilter method 2015-02-23 19:19:51 -05:00
Tomas Babej
3a77a5f291 CLI: Add addContextFilter method 2015-02-23 19:19:47 -05:00
Tomas Babej
1abda3900b CLI: Abstract adding new raw filter to a new helper method 2015-02-23 19:19:44 -05:00
Tomas Babej
09fe5be086 CmdContext: Add show subcommand 2015-02-23 19:19:41 -05:00
Tomas Babej
1a3550541b CmdContext: Add support for unsetting context 2015-02-23 19:19:38 -05:00
Tomas Babej
371ca27da0 CmdContext: Add support for setting context 2015-02-23 19:19:35 -05:00
Tomas Babej
5f3dd43893 CmdCompletionContext: Implement the context completion list 2015-02-23 19:19:32 -05:00
Tomas Babej
edb54a51b3 CmdContext: Add list subcommand 2015-02-23 19:19:29 -05:00
Tomas Babej
636f6bfd96 CmdContext: Add initial implementation of the delete subcommand 2015-02-23 19:19:24 -05:00
Tomas Babej
e91063426a CmdContext: Add initial implementation of the context define subcommand 2015-02-23 19:19:18 -05:00
Tomas Babej
a4d5ab07e9 CmdConfig: Abstract saving and removal of the configuration values into separate methods 2015-02-23 19:19:15 -05:00
Tomas Babej
49a7e46eaf CmdContext: Add initial plumbing 2015-02-23 19:19:08 -05:00
Wilhelm Schuermann
0891ed4b57 Util
- Closed dangling pipes in execute (), resolving problems when a hook script
  forks (thanks to Jens Erat).
2015-02-22 14:43:16 -05:00
Wilhelm Schuermann
af772f4c49 Util
- Closed dangling pipes in execute (), resolving problems when a hook script
  forks.
2015-02-22 14:03:30 -05:00
Wilhelm Schuermann
3484e44c7d CMake
- Added workaround for Cygwin build errors.
2015-02-22 13:53:53 -05:00
Wilhelm Schuermann
be855af8c4 CMake
- Custom compile flags and flags for c++11 ignored even less on OSX now...
2015-02-19 19:17:14 -08:00
Paul Beckingham
1ae4ea2ea3 I18N
- Removed unnecessary string termination and exceptions.
- Removed associated localized errors.
2015-02-19 08:51:36 -08:00
Renato Alves
d37937d970 Tests - add total number of tests to conversion script 2015-02-19 14:11:19 +00:00
Renato Alves
51e947064f Tests - merge args.[2-5].t with enpassant.t and convert to python 2015-02-19 13:38:27 +00:00
Renato Alves
606a7505d3 Tests - convert args.5.t to python 2015-02-19 13:02:46 +00:00
Renato Alves
846dd14a9f Tests - convert args.4.t to python 2015-02-19 12:56:19 +00:00
Renato Alves
d8f436cca9 Tests - convert args.3.t to python 2015-02-19 12:54:45 +00:00
Renato Alves
ac9c726782 Tests - convert args.2.t to python 2015-02-19 12:50:40 +00:00
Paul Beckingham
88d65b23c1 CMake Feedback Messages
- Reworded the '-std=c++11' feedback messages to user fewer '!' characters,
  and be more emphatic about upgrading the compiler.
2015-02-18 21:15:58 -08:00
Paul Beckingham
f2998aba74 TW-1547
- TW-1547 Recur column is always shown even if no recurring task is displayed
          (thanks to Renato Alves).
2015-02-18 20:53:56 -08:00
Paul Beckingham
d2b2631db7 TW-1546
- TW-1546 column type due.remaining breaks colors on due tasks (thanks to Renato
          Alves).
2015-02-18 20:18:31 -08:00
Renato Alves
4c491d8a0d Tests - convert args.1.t to python 2015-02-18 19:54:45 +00:00
Renato Alves
917a152a1e Tests - convert args.t to python 2015-02-18 19:32:58 +00:00
Renato Alves
289e45499a Tests - convert append.t to python 2015-02-18 16:26:59 +00:00
Renato Alves
2efb9594d9 Tests - convert annotate.t to python 2015-02-18 14:05:53 +00:00
Wilhelm Schuermann
0d096a5a42 CMake
- Fixed the C++11 config to actually check for availability of C++11 before trying to use it.
- Custom CXX flags no longer ignored on some platforms.
2015-02-17 16:16:02 -08:00
Paul Beckingham
cc1c063925 Merge branch '2.4.2' of ssh://git.tasktools.org/tm/task into 2.4.2 2015-02-17 18:46:41 -05:00
Paul Beckingham
dd31a15001 Portability
- Removed pthreads linkage.
2015-02-17 12:49:58 -05:00
Paul Beckingham
c11601e30e Cleanup
- Removed unused Nibbler::getHex.
2015-02-17 10:58:45 -05:00
Paul Beckingham
520067f522 Cleanup
- Eliminated text.cpp upperCase(), as it was not UTF8-safe, and is no longer
  used.
2015-02-17 10:44:31 -05:00
Paul Beckingham
693fe9b8fd ColPriority
- Made the acceptance of lower-case priorities explicitly either lower or upper
  case, but converted to upper case. This eliminates the dependency on text.cpp
  upperCase(), which is not UTF8-safe.
2015-02-17 10:40:51 -05:00
Renato Alves
fa249bfedd Tests - Convert alias.t to python 2015-02-17 13:46:00 +00:00
Paul Beckingham
952d743218 Cleanup
- Removed duplicate legacy value map entry.
- Added version number to legacy mapping.
- Added TODO for later clarification.
2015-02-17 08:39:53 -05:00
Paul Beckingham
91f6980d2f Documents
- Updated INSTALL instructions with dependencies.
2015-02-17 08:39:17 -05:00
Renato Alves
d211969236 Tests - clarify that USE_PATH alone is not enough. 2015-02-17 13:37:39 +00:00
Renato Alves
bd320b6729 Tests - Remove commented code 2015-02-17 12:24:13 +00:00
Renato Alves
3f004f547e Tests - Don't hang if spawning taskw fails 2015-02-17 12:24:13 +00:00
Paul Beckingham
3b192cddcf Merge branch '2.4.2' of ssh://git.tasktools.org/tm/task into 2.4.2 2015-02-16 19:33:14 -05:00
Paul Beckingham
ca6061a987 Documentation
- Updated for 2.4.2.
2015-02-16 19:32:02 -05:00
Federico Hernandez
2787ee960b Cleanup NEWS file 2015-02-17 00:22:07 +01:00
Federico Hernandez
c27ad4dc27 Bumped version number in ref page 2015-02-17 00:18:45 +01:00
Federico Hernandez
a36eb974ee Bumped version number to 2.4.2 2015-02-17 00:04:04 +01:00
Federico Hernandez
a55a7bf1a2 Added SHA1 of tagged release commit 2015-02-17 00:00:20 +01:00
Federico Hernandez
82e019a4a8 Version number and release date for 2.4.1 2015-02-16 23:38:16 +01:00
Renato Alves
9180aa6e33 Tests - minor formatting changes 2015-02-16 15:37:31 +00:00
Renato Alves
32d837fb25 Tests - Convert add.t to python
* Also added UUID_regex to basetest.utils, likely to be reused
2015-02-16 15:36:38 +00:00
Renato Alves
395b08385b Tests - Rename testname of abbreviation.t 2015-02-16 15:36:09 +00:00
Renato Alves
9cc9e19757 Tests - conversion script was failing due to binaries matching 2015-02-16 14:50:35 +00:00
Renato Alves
c07d74574d Tests - Silence "vramsteg not found" message 2015-02-16 14:36:47 +00:00
Renato Alves
73401664b6 Tests - Convert abbreviation.t to Python and add one more testcase 2015-02-16 14:30:11 +00:00
Renato Alves
d052b8752d Tests - remove unused imports 2015-02-16 14:09:04 +00:00
Renato Alves
68d9e3bb5e Tests - List perl tests to migrate with ./conversion -v 2015-02-16 03:58:49 +00:00
Renato Alves
86837022d3 Tests - conversion script was giving false positives for python 2015-02-16 03:47:12 +00:00
Renato Alves
e831f85823 Tests - Migrate bug.1006.t to python 2015-02-16 03:47:12 +00:00
Renato Alves
4b839f2c83 Tests - Significant speed improvement at cost of CPU cycles 2015-02-16 01:59:47 +00:00
Renato Alves
1e1bd32c42 Tests - Rework how taskw is launched from python
* Should avoid some odd race conditions
2015-02-16 01:59:32 +00:00
Renato Alves
880ab5d665 Tests - Correct use of non-existent exception 2015-02-15 19:43:09 +00:00
Renato Alves
ef583dedea Tests - Update template.t to include assertValidJSONOutput 2015-02-15 18:13:49 +00:00
Renato Alves
1bd26fe9ab Tests - Default to having Python objects as "hook log" 2015-02-15 18:10:36 +00:00
Renato Alves
80c01f3ffb Tests - Remove assertTriggered, redundant with assertTriggeredCount 2015-02-15 18:10:36 +00:00
Renato Alves
7cd42b5d2f Tests - Less verbose hooks.on-*.t tests 2015-02-15 18:10:36 +00:00
Renato Alves
1b218d68f5 Tests - Invalid JSON replies in hooks no longer fail the test framework 2015-02-15 18:10:36 +00:00
Paul Beckingham
e6031183dd Documentation
- Added 'taskd.trust' setting warning in the NEWS file.
2015-02-15 12:10:08 -05:00
Paul Beckingham
f9bcb8cfc8 Unit Tests
- Added unit tests for TW-1542.
2015-02-15 11:45:31 -05:00
Paul Beckingham
2ef0214248 TW-1542
- TW-1542 Large numeric UDA values get rendered in scientific notation on export
          (thanks to Ralph Bean).
2015-02-15 11:24:24 -05:00
Paul Beckingham
0a62061ca8 L10N
- Localized the new strings in Hooks.cpp.
2015-02-15 02:03:24 -05:00
Paul Beckingham
5d96547c07 Documentation
- Prepared more docs for the 2.4.1 release.
2015-02-14 21:12:16 -05:00
Paul Beckingham
eb3afa1fdc Documentation
- Updated ChangeLog.
2015-02-14 20:44:56 -05:00
Paul Beckingham
885ff46066 Unit Tests
- Renamed tw-1452.t to take it out of play, because the bug is not going to be
  fixed for 2.4.1.
2015-02-14 19:10:57 -05:00
Paul Beckingham
5a060802e7 Hooks
- It is now an error for a failing hook script to fail to also generate some
  feedback.
- Updated NEWS file to mention stricter hook script controls.
2015-02-14 18:16:32 -05:00
Paul Beckingham
acce2d5a68 Unit Tests
- Corrected expected output from on-modify-misbehave6 test hook script.
2015-02-14 17:55:02 -05:00
Paul Beckingham
adac566665 Unit Tests
- Corrected expected output from the on-modify-misbehave4 test hook script.
- Moved JSON syntax error details to debug output.
2015-02-14 17:50:28 -05:00
Paul Beckingham
f454eecafb Unit Tests
- Corrected expected output.
- Added 'complete' task to the on-modify-misbehave4 test hook script.
2015-02-14 17:46:24 -05:00
Paul Beckingham
f83702076b Unit Tests
- Updated expected error for on-modify-misbehave3 test hook script.
2015-02-14 17:44:21 -05:00
Paul Beckingham
83519a44c6 Unit Tests
- Added feedback to the on-modify-misbehave2 test hook script.
2015-02-14 17:42:03 -05:00
Paul Beckingham
a2e980c6b8 Hooks
- Deferred JSON checking until after we know whether the hooks voluntarily
  failed the event.
2015-02-14 17:33:48 -05:00
Paul Beckingham
e00704a375 Hooks
- Cleaned up logic for crude JSON detection.
2015-02-14 17:31:37 -05:00
Paul Beckingham
8fb3161a02 Hooks
- Modified expected output from an on-modify hooks script, because it's 1 line
  of JSON, not 2.
2015-02-14 17:19:44 -05:00
Tomas Babej
fa528beb58 Tests: Add test for TW-1510 2015-02-14 17:10:22 -05:00
Paul Beckingham
c5a2b7f759 Unit Tests
- Fixed exected error for on-add-misbehave5. This highlights a potential
  error in the test suite with the one failing test.
2015-02-14 17:03:43 -05:00
Paul Beckingham
4213afd408 Unit Tests
- Fixed on-add-misbehave6 error.
2015-02-14 16:52:47 -05:00
Paul Beckingham
8ad0c1172e Unit Tests
- on-add now detects JSON emitted by hooks for different tasks.
2015-02-14 16:46:52 -05:00
Paul Beckingham
f887173bf7 TW-1510
- TW-1510 Task can save empty value in the data backlog (thanks to Tomas Babej).
2015-02-14 16:33:45 -05:00
Tomas Babej
328b7ec260 Task: Do not export empty attributes in composeJSON 2015-02-14 16:32:41 -05:00
Paul Beckingham
ab41e005c9 Unit Tests
- Added on-exit test for unexpected JSON output.
2015-02-14 16:19:36 -05:00
Paul Beckingham
bd785ffad5 Hooks
- Added a new on-launch-misbehave2 script that emits unexpected JSON.
2015-02-14 16:14:20 -05:00
Paul Beckingham
3cce6c23f5 Hooks
- Hooks now verify the expected number of JSON lines emitted by hook scripts.
2015-02-14 15:50:51 -05:00
Paul Beckingham
ec919a8677 TW-1534
- TW-1534 Urgency coefficient for user project disables 'info' output(thanks to
          Martin).
- Reimplemented 'information' command urgency details as a ViewText.
- Fixed math bug in rightJustify.
2015-02-14 12:50:10 -05:00
Paul Beckingham
5911286218 Documentation
- Relocated Tomas to a better seat.
2015-02-14 11:52:07 -05:00
Paul Beckingham
9e49325d6e TW-1531
- TW-1531 'task export' should handle recurrence (thanks to Tomas Babej).
2015-02-13 20:35:04 -05:00
Tomas Babej
c483c8dda9 CmdExport: Generate recurrent tasks 2015-02-13 20:31:46 -05:00
Paul Beckingham
2d2579d801 Unit Tests
- Fixed bug in test where the rc path name contains a number, which is found by
  the test in place of an unexpected week number.
2015-02-08 14:04:22 -05:00
Paul Beckingham
4f6c51e7ae Unit Tests
- Updated README with suggested work.
- Removed obsolete TAP.py.
- Added 'conversion' script to check on the Perl -> Python progress.
2015-02-08 13:51:27 -05:00
Paul Beckingham
cd6808ab15 Unit Tests
- Removed color.duetoday.t, because of two reasons. First, the test is flawed,
  and second the test is duplicated in tw-285.t.
2015-02-08 13:22:05 -05:00
Paul Beckingham
8b648bc690 Unit Tests
- Reduced hh from 99:00:00 to 95:00:00, because with the +01:00 it becomes
  100:00:00, and '100' exceeds Nibbler::getDigit2.
2015-02-08 13:18:23 -05:00
Paul Beckingham
9a0a6188b1 Documentation
- Added email address to which patches should be sent (thanks to mathstuf).
2015-02-07 18:50:03 -05:00
Paul Beckingham
b79453afa7 TW-1532
- TW-1532 Hooks does not execute any script on Cygwin (thanks to Taisuke
          Hachimura).
2015-02-07 14:45:06 -05:00
Paul Beckingham
60dddffda3 TW-1524
- TW-1524 Build Broken (thanks to Jack).
2015-02-07 14:39:25 -05:00
Paul Beckingham
e8dc5a16a1 Portability
- Clarified the requirements regarding C++11 support, libuuid and gnutls.
2015-02-07 14:37:51 -05:00
Paul Beckingham
528e72062b Hooks
- Fixed the ::execute function used by Hooks and CmdCalendar to run commands,
  by following the convention:

    "The first argument, by convention, should point to the file name associated
     with the file being executed."
     (man execvp)
2015-02-07 14:08:58 -05:00
Paul Beckingham
876820ee1a Unit Tests
- Restored bash as the interpreter for wrapper.sh.
2015-02-07 10:39:16 -05:00
Paul Beckingham
8e730f2da3 Hooks
- Updated examples to not rely on bash being in /bin.
2015-02-07 10:25:50 -05:00
Paul Beckingham
8b28c36485 Unit Tests
- Modified the test_hooks/* scripts to use /bin/sh, which is portable. When
  using /bin/bash, Cygwin and FreeBSD silently fail.
2015-02-07 10:22:07 -05:00
Paul Beckingham
04be198281 Unit Tests
- Added on-modify hook tests.
2015-02-07 08:58:47 -05:00
Paul Beckingham
1b69ac6ad2 Unit Tests
- The on-modify-misbehave1 test is not useful.
2015-02-07 08:57:27 -05:00
Paul Beckingham
b1081bd510 Unit Tests
- Added hook tests for on-add.
2015-02-07 08:41:02 -05:00
Paul Beckingham
a72322b9db Unit Test
- Added tests for on-exit hooks.
2015-02-02 12:37:39 -05:00
Paul Beckingham
82e6574d30 Unit Tests
- Added tests for on-launch hooks.
2015-02-01 18:37:18 -05:00
Paul Beckingham
1f14454be7 Merge branch '2.4.1' of ssh://git.tasktools.org/tm/task into 2.4.1
Conflicts:
	test/template.t
2015-02-01 17:01:58 -05:00
Paul Beckingham
384ca82292 Unit Tests
- Hooks snapshot prior to pull.
2015-02-01 17:00:39 -05:00
Renato Alves
066143d939 Unittest - template.t use docstring for proper test description on execution 2015-02-01 20:39:38 +00:00
Renato Alves
e845a25ea6 Unittest - Replace the timestamp function on wrapper.sh
* %N is not supported by /bin/date on BSD systems
2015-02-01 20:35:11 +00:00
Renato Alves
75a2b11638 Unittest - Update template.t to use Hook.assert* functions 2015-02-01 19:33:08 +00:00
Renato Alves
6a3edc88a1 Unittest - properly implement Hook.assert* functions 2015-02-01 19:33:08 +00:00
Renato Alves
bb3555f217 Unittest - Bad exception formatting 2015-02-01 19:33:08 +00:00
Paul Beckingham
5de80eedeb Unit Tests
- Typos in template.t.
2015-02-01 12:36:54 -05:00
Paul Beckingham
10c1b5f902 Merge branch '2.4.1' of ssh://git.tasktools.org/tm/task into 2.4.1 2015-02-01 11:53:11 -05:00
Renato Alves
049ed04471 Unittest - Document the magic line in wrapper.sh 2015-02-01 06:23:34 +00:00
Paul Beckingham
3ff42af9c7 Unit Tests
- Added sample hooks that behave/misbehave in various ways.
2015-01-31 18:34:25 -05:00
Paul Beckingham
1cfdfbae52 Hooks
- Removed the ability for hooks to add tasks, or modify tasks that are outside
  the context of the current event. This makes hooks a local mechanism that
  operates only on local changes. Modifications/additions coming in via sync
  command are not processed by hooks.
2015-01-31 17:47:58 -05:00
Paul Beckingham
61291e4d1e C++
- ColumnDate::~ColumnDate should be virtual.
2015-01-31 13:23:45 -05:00
Tomas Babej
77ec56dcd0 Tests: Add test case for disabled recurrence mechanism 2015-01-25 16:06:26 -05:00
Paul Beckingham
d0f74c4a80 Unit Tests
- Fixed a broken test that returns different values are different times of the
  year/month.
- Removed silly tests that were looking at color values, which is a bad idea.
2015-01-25 16:00:43 -05:00
Paul Beckingham
4bdee56fa7 Configuration
- New 'recurrence' configuration setting can disable recurring task generation.
2015-01-25 15:41:31 -05:00
Paul Beckingham
8323407242 TW-1504
- TW-1504 On-modify hook does not accept correct JSON format (thanks to Tomas
          Babej).
2015-01-25 14:51:07 -05:00
Paul Beckingham
6626207ad1 TW-1522
- TW-1522 Date format doesn't like hyphens (thanks to Scott Carter).
2015-01-25 14:49:02 -05:00
Paul Beckingham
4865269630 Hooks
- Modified loop so it no longer walks the whole list unnecessarily.
- Minor style tweaks.
2015-01-25 10:33:03 -05:00
Tomas Babej
8683574b18 Hooks: Make sure that original task is properly detected
On modify event uses UUID of the original task being modified
to determine which line should be interpreted as modification
of the task.

This was achieved by searching by a substring in a specific JSON
format, which, consenquently, failed on JSON strings of other (valid)
formats.
2015-01-25 10:28:04 -05:00
Paul Beckingham
5e90510530 Merge branch '2.4.1' of ssh://git.tasktools.org/tm/task into 2.4.1 2015-01-24 10:12:43 -05:00
Tomas Babej
a8bab90c34 Documentation
- Update the man page with the correct description of behaviour of
  rc.confirmation and rc.bulk variables
2015-01-24 10:12:32 -05:00
Renato Alves
87c2a9b5a5 Unittest - README clarifications
* Add one line command to run all tests
* Clarify that only tests ending with .t and execute bit set are run
2015-01-21 12:13:19 +00:00
Paul Beckingham
cba5948a1d Unit Tests
- Took the tw-1481.t test offline, because the bug will not be fixed in the
  next release.
2015-01-20 22:06:46 -05:00
Paul Beckingham
f4a6ec6f97 Documentation
- Updated README.
2015-01-20 22:05:11 -05:00
Paul Beckingham
a3490966c0 Documentation
- Added README to explain the test suite.
2015-01-20 21:52:17 -05:00
Paul Beckingham
855537b975 TW-1517
- TW-1517 Hook performance should be measured individually for each hook (thanks
          to Tomas Babej).
2015-01-20 20:33:31 -05:00
Paul Beckingham
473019c1f0 TW-1519
- TW-1519 Testing suite forces taskd.trust="ignore hostname" (thanks to Renato
          Alves).
2015-01-20 20:18:13 -05:00
Renato Alves
d1698eab2d Fix usage of taskd.trust=strict on the test suite
* This reverts commit 67cb30fdce.
* Code also now tests if taskd is listening on IPv4 or IPv6 interfaces.
2015-01-20 11:56:53 +00:00
Paul Beckingham
73b7b21b81 Certs
- Replaced all the certs for testing.  This may not help, but it does mean
  there were recreated using the current PKI scripts, and are all consistent.
2015-01-19 18:25:21 -05:00
Paul Beckingham
44f2c0c98c Unit Tests
- Added JSON test which includes spaces.
2015-01-19 18:09:54 -05:00
Tomas Babej
654159b2fd Hooks: Add per-hook time measurement 2015-01-19 16:07:34 -05:00
Renato Alves
67cb30fdce Unittest - default to taskd.trust="ignore hostname"
* The currently available taskd testing certificates fail if
taskd.trust is set to strict. See also: TW-1519
2015-01-19 15:07:06 +00:00
Renato Alves
7d75547f44 Ignore taskd in src folder (for running taskd tests) 2015-01-19 15:00:02 +00:00
Renato Alves
d68fa7ea8a Unittest - Template updated to include hook test examples 2015-01-19 14:58:06 +00:00
Renato Alves
db78851b40 Unittest - Hook testing, fixed a few mistakes 2015-01-19 14:54:11 +00:00
Tomas Babej
6fdf0738a7 Hooks: Improve debugging messages for on-exit hooks 2015-01-18 13:27:32 -05:00
Paul Beckingham
41003fc78b Code Cleanup
- Removed whitespace at EOL.
2015-01-17 19:05:09 -05:00
Wilhelm Schuermann
d2928dc4e4 TW-1516 Hook input not ended with EOF
- Made execute() send EOF when all input is written.
- Minor code cleanup.
2015-01-17 19:04:31 -05:00
Wilhelm Schuermann
61deb7ce7e CMake
- Fix CMAKE_CXX_FLAGS change to preserve previous flags.
2015-01-17 18:58:38 -05:00
Renato Alves
0311ea6689 GnuTLS optionally compiled - defaults to yes
* Allow optionally disabling GnuTLS via config var (USE_GNUTLS)
2015-01-14 13:17:25 +00:00
Paul Beckingham
0b0ddbfbc4 TW-1491
- TW-1491 Regression in deleting due dates (thanks to Jens Erat).
2015-01-12 15:52:15 -05:00
Jens Erat
cd31335742 TW-1491 - TW-1491 Regression in deleting due dates 2015-01-12 15:42:58 -05:00
Tomas Babej
5a3037f257 Tests: Fix error in export.t and add test for urgency 2015-01-12 15:38:44 -05:00
Paul Beckingham
a22d173b9b TW-1487
- TW-1487 Task export exports some numeric attributes as strings (thanks to
          Tomas Babej).
2015-01-11 09:07:04 -05:00
Paul Beckingham
134d201cb0 TW-1457
- TW-1457 Non-existant attributes are not properly handled (thanks to Tomas
          Babej).
2015-01-10 15:53:55 -05:00
Paul Beckingham
547d9edb55 TW-1484
- TW-1484 The 'history' and 'ghistory' reports do not obey rc.color.label.
2015-01-10 15:49:42 -05:00
Paul Beckingham
cdde747733 TW-1498
- TW-1498 Filtering for presence of UDA matches all tasks (thanks to Ralph Bean).
2015-01-10 14:36:21 -05:00
Paul Beckingham
588009d679 TW-1501
- TW-1501 Calc can't handle multi-digit numbers in some expressions (thanks to
          Jeremy John Reeder).
2015-01-08 20:40:29 -05:00
Paul Beckingham
adf9f25289 Unit Tests
- Removed failing tests, as there is no plan to address all these now.
2015-01-07 23:43:11 -05:00
Paul Beckingham
ea0397f542 TW-1495
- TW-1495 German translation for taskwarrior (thanks to Jens Erat).
2015-01-07 23:23:25 -05:00
Paul Beckingham
411fab3a27 Hooks
- Added debug output on startup, if a hook script is found and does not have
  a valid name.
2015-01-07 22:54:55 -05:00
Paul Beckingham
da6a57b203 Hooks
- The 'diag' command should indicate misnamed hook scripts (thanks to Tomas
  Babej).
2015-01-07 18:43:14 -05:00
Tomas Babej
235e4ef047 Tests: Add negative tests for parsing time 2015-01-07 17:14:49 -05:00
Tomas Babej
1dbb0a57a8 Tests: Add negative tests for parsing dates 2015-01-06 19:14:04 -05:00
Paul Beckingham
5a7117630e Unit Tests
- Typo.
2015-01-05 20:04:26 -05:00
Paul Beckingham
e9f9f6a86e Unit Tests
- Added copyright and removed whitespace at EOL.
2015-01-05 19:52:17 -05:00
Tomas Babej
8ea1563944 Tests: Add basic coverage for the types of attributes in the export command 2015-01-05 19:48:52 -05:00
Wilhelm Schuermann
e522c1980a TW-1424
- Fixed tw-1424.t (mostly).
2015-01-05 06:53:51 -05:00
Paul Beckingham
845fe047cc C++11
- Converted one source file to use an actual C++11 feature. If no one notices
  we can move forward and start using supported featues. If it's a problem,
  this commit gets rolled back.

  GCC 4.6 (released March 2011), and Clang 3.0 (releasd November 2011) both
  support N2930 (range-based for) which is the feature being tried here.
2015-01-04 22:01:22 -05:00
Paul Beckingham
5932d9f90b Portability
- More STDOUT_FILENO conversions.
2015-01-04 22:00:08 -05:00
Paul Beckingham
a8ff7655ef Portability
- Properly detects Cygwin.  version 2.
2015-01-04 21:37:47 -05:00
Paul Beckingham
79cc9d8ed9 Portability
- Properly detects Cygwin.
2015-01-04 21:29:46 -05:00
Paul Beckingham
b83dc8a29e Portability
- Added '-std=gnu++0x' for Cygwin.
2015-01-04 20:39:42 -05:00
Paul Beckingham
99ebf82c3a Context
- Eliminated fileno() by using unistd.h STDOUT_FILENO. This is because fileno()
  is not visible with '--std=c++11'.
2015-01-04 20:25:25 -05:00
Paul Beckingham
231e8ca913 Portability
- Missing include on Cygwin only.  Odd.
2015-01-04 20:17:56 -05:00
Paul Beckingham
9bd9a3b285 C++
- Enabling C++11, as a test.  Let's see if anything blows up.
2015-01-04 20:11:32 -05:00
Paul Beckingham
b882cd151e Build
- Added code to set poicy CMP0037 to "OLD", which eliminates the warnings about
  the 'test' target.
2015-01-04 18:59:09 -05:00
Paul Beckingham
a3b0d5c6a6 Unit Tests
- Added copyright to tests that were missing it.
2015-01-04 10:55:01 -05:00
Paul Beckingham
d1664b3f55 Unit Tests
- Re-enabled bug.982.t and fixed the regex so it is right. This test was created
  for a parsing bug which is now fixed.
2015-01-04 10:40:21 -05:00
Paul Beckingham
1cac14f3f8 Unit Tests
- This disabled test is verifying 'Total Active Time' functionality that has
  itself been removed.
2015-01-04 10:35:57 -05:00
Paul Beckingham
507e2d5807 Unit Tests
- Added copyright, fixed test name.
2015-01-04 10:30:10 -05:00
Tomas Babej
c664d62c2f Tests: Add coverage for TW-1452 2015-01-04 10:23:38 -05:00
Paul Beckingham
f32c4d1f73 TW-1492
- TW-1492 compiling v2.4.0 using musl(libc) (thanks to V.Krishn).
2015-01-04 10:14:15 -05:00
Paul Beckingham
9bf7dfda4f AUTHORS
- Upgrade Tomas to the dev section.
2015-01-03 20:25:30 -05:00
Tomas Babej
2a782b8f01 Tests: Add coverage for TW-1481 2015-01-03 20:21:46 -05:00
Paul Beckingham
3c07510a43 Unit Tests
- Added copyright to template.
2015-01-03 20:20:30 -05:00
Paul Beckingham
07eff0f3c1 Bug
- Changed assorted reports so they do not use '.age' format for dates that are
  in the future, because those are never shown with this format.
2015-01-03 17:56:20 -05:00
Paul Beckingham
dad0ac0c27 TW-1486
- TW-1486 task wait shows completed tasks which has a wait attribute (thanks to
          Sujeevan Vijayakumaran).
2015-01-03 09:31:54 -05:00
Paul Beckingham
2c986d6e6b Unit Tests
- Fixed typo in comment.
2015-01-03 09:24:07 -05:00
Paul Beckingham
1e8f83cab9 Themes
- Removed 'bold' from a 256-color definition.
2015-01-02 08:55:18 -05:00
Paul Beckingham
15f00452c2 Themes
- Increased contrast for 'color.blocking'.
2015-01-02 08:54:50 -05:00
Paul Beckingham
6a3b13dbfc Documentation
- Initial project version doc updates.
2015-01-02 00:01:32 -05:00
Federico Hernandez
8180b94b1b Bumped version number in task reference pdf 2015-01-02 01:05:03 +01:00
Federico Hernandez
6aafa9f04e Bumped version number to 2.4.1 2015-01-02 00:44:49 +01:00
Federico Hernandez
fe07f62214 Added SHA1 of tagged release commit 2015-01-02 00:39:40 +01:00
254 changed files with 10913 additions and 5042 deletions

1
.gitignore vendored
View File

@@ -2,6 +2,7 @@ cmake.h
commit.h
Makefile
src/task
src/taskd
src/libtask.a
src/commands/libcommands.a
src/columns/libcolumns.a

10
AUTHORS
View File

@@ -13,6 +13,7 @@ contributions of the following people:
Louis-Claude Canon (Contributing Author)
Scott Kostyshak (Contributing Author)
Renato Alves (Contributing Author)
Tomas Babej (Contributing Author)
The following submitted code, packages or analysis, and deserve special thanks:
@@ -112,6 +113,8 @@ The following submitted code, packages or analysis, and deserve special thanks:
Jeremy John Reeder
Roman Inflianskas
Łukasz Panek
V.Krishn
Jens Erat
Thanks to the following, who submitted detailed bug reports and excellent
suggestions:
@@ -233,10 +236,13 @@ suggestions:
dev-zero
Petteri
Black Ops Testing
Jens Erat
Leon Feng
Tomas Babej
Nick Person
Arnoud K
Ozgur Akgun
David Costa
Sujeevan Vijayakumaran
Scott Carter
Taisuke Hachimura
Martin
Alexandre de Verteuil

View File

@@ -1,5 +1,8 @@
cmake_minimum_required (VERSION 2.8)
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
if(POLICY CMP0037)
cmake_policy(SET CMP0037 OLD)
endif()
include (CheckFunctionExists)
include (CheckStructHasMember)
@@ -7,12 +10,40 @@ include (CheckStructHasMember)
set (HAVE_CMAKE true)
project (task)
set (PROJECT_VERSION "2.4.0")
set (PROJECT_VERSION "2.4.2")
OPTION(USE_GNUTLS "Build gnutls support." ON)
message ("CMAKE_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}")
include (CheckCXXCompilerFlag)
# NOTE: If we are to actually use C++11 features, we should either require
# a compiler that supports the -std=c++11 flag or check for the
# features used.
# Relying on -std=c++0x or even -std=gnu++0x is highly volatile.
CHECK_CXX_COMPILER_FLAG("-std=c++11" _HAS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" _HAS_CXX0X)
CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" _HAS_GNU0X)
if (_HAS_CXX11)
set (_CXX11_FLAGS "-std=c++11")
elseif (_HAS_CXX0X)
message (WARNING "Enabling -std=c++0x draft compile flag. Your compiler does not support the standard '-std=c++11' option. Consider upgrading.")
set (_CXX11_FLAGS "-std=c++0x")
elseif (_HAS_GNU0X)
message (WARNING "Enabling -std=gnu++0x draft compile flag. Your compiler does not support the standard '-std=c++11' option. Consider upgrading.")
set (_CXX11_FLAGS "-std=gnu++0x")
else (_HAS_CXX11)
message (FATAL_ERROR "C++11 support missing. Try upgrading your C++ compiler. If you have a good reason for using an outdated compiler, please let us know at support@taskwarrior.org.")
endif (_HAS_CXX11)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set (LINUX true)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (DARWIN true)
set (_CXX11_FLAGS "${_CXX11_FLAGS} -stdlib=libc++")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "kFreeBSD")
set (KFREEBSD true)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
@@ -25,10 +56,18 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
set (SOLARIS true)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "GNU")
set (GNUHURD true)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "CYGWIN")
set (CYGWIN true)
# NOTE: Not setting -std=gnu++0x leads to compile errors even with
# GCC 4.8.3, and debugging those leads to insanity. Adding this
# workaround instead of fixing Cygwin.
set (_CXX11_FLAGS "-std=gnu++0x")
else (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set (UNKNOWN true)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set (CMAKE_CXX_FLAGS "${_CXX11_FLAGS} ${CMAKE_CXX_FLAGS}")
if (NETBSD)
# Since readline, etc likely to be in /usr/pkg/lib, not standard library
# Otherwise will remove links during install
@@ -65,23 +104,15 @@ set (PACKAGE_TARNAME "${PACKAGE}")
set (PACKAGE_VERSION "${VERSION}")
set (PACKAGE_STRING "${PACKAGE} ${VERSION}")
message ("-- Looking for GnuTLS")
find_package (GnuTLS)
if (GNUTLS_FOUND)
set (HAVE_LIBGNUTLS true)
set (TASK_INCLUDE_DIRS ${TASK_INCLUDE_DIRS} ${GNUTLS_INCLUDE_DIR})
set (TASK_LIBRARIES ${TASK_LIBRARIES} ${GNUTLS_LIBRARIES})
endif (GNUTLS_FOUND)
#message ("-- Looking for pthread")
#find_path (PTHREAD_INCLUDE_DIR pthread.h)
#find_library (PTHREAD_LIBRARY NAMES pthread)
#if (PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
# message ("-- Found pthread: ${PTHREAD_LIBRARY}")
# set (HAVE_LIBPTHREAD true)
# set (TASK_INCLUDE_DIRS ${TASK_INCLUDE_DIRS} ${PTHREAD_INCLUDE_DIR})
# set (TASK_LIBRARIES ${TASK_LIBRARIES} ${PTHREAD_LIBRARIES})
#endif (PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
if (USE_GNUTLS)
message ("-- Looking for GnuTLS")
find_package (GnuTLS)
if (GNUTLS_FOUND)
set (HAVE_LIBGNUTLS true)
set (TASK_INCLUDE_DIRS ${TASK_INCLUDE_DIRS} ${GNUTLS_INCLUDE_DIR})
set (TASK_LIBRARIES ${TASK_LIBRARIES} ${GNUTLS_LIBRARIES})
endif (GNUTLS_FOUND)
endif (USE_GNUTLS)
check_function_exists (timegm HAVE_TIMEGM)
check_function_exists (get_current_dir_name HAVE_GET_CURRENT_DIR_NAME)

View File

@@ -1,10 +1,89 @@
2.4.0 (2015-01-01) -
2.4.2 (2015-03-15) -
- TW-41 Tasks in subprojects are not counted in project completion (thanks
to Renato Alves).
- TW-1450 Projects command should trigger running garbage collector (thanks to
Tomas Babej).
- TW-1535 move default listing-break from list to ls (thanks to David Patrick).
- TW-1545 cc1plus: error: unrecognized command line option '-std=c++11' (thanks
to Petteri).
- TW-1546 column type due.remaining breaks colors on due tasks (thanks to
Renato Alves).
- TW-1547 Recur column is always shown even if no recurring task is displayed
(thanks to Renato Alves).
- TW-1549 task annotate hangs with specific text pattern (thanks to Alexandre
de Verteuil).
- TW-1550 _contexts helper-command (thanks to David Patrick).
- TW-1551 Unable to get a UDA value from DOM (thanks to Tomas Babej).
- Eliminated some code that is not UTF8-safe.
- Removed pthreads linkage.
- Implemented the context feature.
- Closed dangling pipes in execute (), resolving problems when a hook script
forks (thanks to Jens Erat).
- Re-enabled hook script feedback when exiting with 0 exit status.
- The 'info' command now shows virtual tags.
- Fixed major on-modify hooks regression where hooks could no longer modify
the tasks handed to them.
- 'task _version' now outputs "2.4.2 (git-ref)" when built from git. "2.4.2"
when built from release tarballs (thanks to Renato Alves).
------ current release ---------------------------
2.4.1 (2015-02-16) 82e019a4a8b20de63d53b51d59b8d1c89d3c05b2
- TW-1457 Non-existent attributes are not properly handled (thanks to Tomas
Babej).
- TW-1484 The 'history' and 'ghistory' reports do not obey rc.color.label.
- TW-1486 task wait shows completed tasks which has a wait attribute (thanks to
Sujeevan Vijayakumaran).
- TW-1487 Task export exports some numeric attributes as strings (thanks to
Tomas Babej).
- TW-1491 Regression in deleting due dates (thanks to Jens Erat).
- TW-1492 compiling v2.4.0 using musl(libc) (thanks to V.Krishn).
- TW-1495 German translation for taskwarrior (thanks to Jens Erat).
- TW-1498 Filtering for presence of UDA matches all tasks (thanks to Ralph
Bean).
- TW-1501 Calc can't handle multi-digit numbers in some expressions (thanks to
Jeremy John Reeder).
- TW-1502 Successful on-add hook with no output confuses TW (thanks to Tomas
Babej).
- TW-1504 On-modify hook does not accept correct JSON format (thanks to Tomas
Babej).
- TW-1505 completely ignore mis-named hook scripts (thanks to Tomas Babej,
David Patrick).
- TW-1509 Hooks modifications performed on sync not sycning back (thanks to
Tomas Babej).
- TW-1510 Task can save empty value in the data backlog (thanks to Tomas Babej).
- TW-1517 Hook performance should be measured individually for each hook (thanks
to Tomas Babej).
- TW-1518 Misbehaving hooks silently break task processing (thanks to Wim
Schuermann).
- TW-1519 Testing suite forces taskd.trust="ignore hostname" (thanks to Renato
Alves).
- TW-1522 Date format doesn't like hyphens (thanks to Scott Carter).
- TW-1524 Build Broken (thanks to Jack).
- TW-1530 Multiple on-add hooks generating new tasks are ignored (thanks to
Tomas Babej).
- TW-1531 'task export' should handle recurrence (thanks to Tomas Babej).
- TW-1532 Hooks does not execute any script on Cygwin (thanks to Taisuke
Hachimura).
- TW-1534 Urgency coefficient for user project disables 'info' output (thanks to
Martin).
- TW-1542 Large numeric UDA values get rendered in scientific notation on export
(thanks to Ralph Bean).
- Fixed assorted color theme problems.
- Changed assorted reports so they do not use '.age' format for dates that are
in the future, because those are never shown with this format (thanks to
Sujeevan Vijayakumaran).
- New 'recurrence' configuration setting can disable recurring task generation.
2.4.0 (2015-01-01) 670102842c39bdc62ef84ae4b679a8f5a2d89523
- TD-42 Cannot compile taskd - GNUTLS_VERSION undefined in diag.cpp (thanks
to Michele Vetturi).
- TD-45 Fix preprocessor define (thanks to Jochen Sprickerhof).
- TD-55 TLSServer/Client need to include <errno.h> on Solaris (thanks to Tatjana
Heuser). Also applied to NetBSD.
- TD-55 TLSServer/Client need to include <errno.h> on Solaris (thanks to
Tatjana Heuser). Also applied to NetBSD.
- TD-56 File.cpp needs to include <string.h> on Solaris (thanks to Tatjana
Heuѕer).
- TD-57 taskdctl script assumes /bin/sh is /bin/bash (thanks to Tatjana Heuser).
@@ -45,6 +124,7 @@
- TW-52 "task add ... recur:2 months" interpreted as "2s" (thanks to jwhisnant).
- TW-55 Bulk edit recurring tasks without answering yes/no for each? (thanks to
Max Muller).
- TW-63 indicators for UDAs (thanks to David Patrick).
- TW-71 task ls/list/long/etc. should match contents of projects too (thanks to
Cory Donnelly).
- TW-72 extend info report with urgency column.
@@ -286,8 +366,6 @@
- Supports 'debug.parser' configuration setting.
- Supports 'color.label.sort' for column labels of sort columns.
------ current release ---------------------------
2.3.0 (2014-01-15) c4eb46507031b7dee839dcb932bb2a22b2f0d3a2
Features

View File

@@ -1,9 +1,16 @@
How to Build Taskwarrior
Satisfy the Requirements:
- gcc 4.4 or later, clang 2.9 or later or equivalent. This is because 2.4.1
marks the first step towards using modern C++11. Initially this involves
only feature N1984.
- libuuid
- gnutls (optional)
Obtain and build code:
$ git clone https://git.tasktools.org/scm/tm/task.git task.git
$ cd task.git
$ git checkout 2.4.0 # Latest dev branch
$ git checkout 2.4.2 # Latest dev branch
$ cmake -DCMAKE_BUILD_TYPE=debug . # debug or release. Default: neither.
$ make VERBOSE=1 # Shows details
@@ -18,8 +25,9 @@ How to Build Taskwarrior
current development branch. The source tarballs do not reflect HEAD, and do
not contain the test suite.
If you send us a patch, make sure that patch is made against git HEAD. We
cannot apply patches made against the tarball source.
If you send a patch (support@taskwarrior.org), make sure that patch is made
against git HEAD on the development branch. We cannot apply patches made
against the tarball source, or master.
General Statement
This file is intended to convey the current efforts, priorities and needs of
@@ -181,12 +189,11 @@ Work in Progress
Current Codebase Condition
'master' branch:
- 2.3.0 Current release, locked.
- 2.4.1 Current release, locked.
'2.4.0' branch:
- Current development branch with new command line parser, expressions,
and heading for beta soon.
'2.4.2' branch:
- Current development branch no plans yet.
---
2014-10-12 Updated for 2.4.0
2015-02-14 Updated for 2.4.1

View File

@@ -24,7 +24,7 @@ Command Line Parsing
determines whether subsequent arguments are interpreted as part of a filter or
set of modifications.
The Parser object is fed command line arguments, then through a succession of
The CLI object is fed command line arguments, then through a succession of
calls builds and annotates a parse tree. To help with this, the Lexer is
used to break up strings into tokens.

20
INSTALL
View File

@@ -8,9 +8,17 @@ Pre-requisites
--------------
You will need the CMake build system installed in order to build taskwarrior
from source.
from source. More information on cmake can be obtained at http://cmake.org
More information on cmake can be obtained at http://cmake.org
You will need a C++ compiler that supports C++11 N1984, which includes:
- gcc 4.4 (released 2009-04-21)
- clang 2.9 (released 2011-04-06)
In addition:
- uuid lib
- gnutls (optional - for syncing)
It is HIGHLY RECOMMENDED that you build with a library that provides uuid_*
functions, such as libuuid.
@@ -92,10 +100,12 @@ Currently the defined languages are:
eng_USA 1
esp_ESP 2
deu_DEU 3
fra_FRA 4
ita_ITA 5
por_PRT 6
epo_RUS 7
pol_POL 8
Uninstallation
--------------
@@ -131,9 +141,7 @@ Cygwin
Darwin, 32bit
The taskwarrior packages will not work on a 32-bit OSX installation on Core
Duo hardware. You will need to build Taskwarrior from source, and use this
configure command:
Taskwarrior needs to be built from source, and use this configure command:
cmake -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_EXE_LINKER_FLAGS=-m32 .

110
NEWS
View File

@@ -1,98 +1,50 @@
New Features in taskwarrior 2.4.0
New Features in taskwarrior 2.4.2
- The 'show' command displays default configuration values, when appropriate.
- Removed deprecated commands 'push', 'pull' and 'merge'.
- Portuguese (por-PRT), French (fra-FRA), Esperanto (epo-RUS) and Polish
(pol-POL) localizations.
- Better handling for deletion of recurring tasks.
- New virtual tags: YESTERDAY, TOMORROW, READY, PENDING, COMPLETED, DELETED,
TAGGED.
- The '_get' command properly uses exit codes.
- Regular expressions are now enabled by default.
- The 'filter' verbosity token shows the complete filter used for the last
command.
- The 'new-uuid' verbosity token shows the UUID of newly created tasks.
- The 'info' report now breaks down urgency values.
- New 'color.until' color rule.
- Using a non-zero 'urgency.inherit.coefficient' value means a task inherits
the urgency values of the dependency chain.
- Listing breaks now supported. See 'man taskrc'.
- New fish shell completion script.
- The filter form 'name:value' now maps to the partial match operator '=',
rather than the exact match operator, '=='. This means that dates now
match on the day by default, not the time also.
- UDA indicator format.
- Hooks.
- New and updated holidays.rc files.
- Ability to set context, which serves as a permanent user-defined filter.
- The 'info' command now shows virtual tags.
New commands in taskwarrior 2.4.0
New commands in taskwarrior 2.4.2
- New 'calc' command (and standalone utility) for quick command line
calculations.
- The 'context' command has been added, along with it subcommands 'define',
'delete', 'show', 'list' and 'none'.
New configuration options in taskwarrior 2.4.0
New configuration options in taskwarrior 2.4.2
- The 'taskd.trust' setting is now a tri-state, supporting values 'strict',
'ignore hostname' and 'allow all', for server certificate validation.
- New theme: dark-gray-blue-256.theme
- The 'allow.empty.filter' setting can be set to 'no' to disallow the
potentially dangerous combination of write commands and empty filters.
- New truncated_count column style for the description field which as the
name says is a combination of the existing truncated and count styles.
- New 'hooks' setting is a master control switch for hook processing.
- New 'debug.hooks' for debugging hook scripts.
- New 'debug.parser' for debugging parser issues scripts.
- New 'color.label.sort' is used to color the column label of sort columns.
- New 'urgency.uda.<name>.<value>' allows specific UDA values to affect
urgency.
- New 'recurrence.confirmation' which allows bypassing confirmation for
changes to recurring tasks, by accepting, rejecting or prompting.
- New 'uda.<name>.indicator' to override the UDA indicator.
- 'context' to store the current context applied.
- 'context.<name>' to store the definition of context 'name'
Newly deprecated features in taskwarrior 2.4.0
Newly deprecated features in taskwarrior 2.4.2
- The alias '_query' is deprecated.
- Bare word search terms are deprecated, so 'task pattern list' will not
be supported in future releases, instead requiring 'task /pattern/ list'.
- The 'limit' pseudo attribute will change to 'rc.limit' in a future release.
- None
Removed features in 2.4.0
Removed features in 2.4.2
- Version 1.x column names no longer supported.
- Version 1.x sort columns no longer supported.
- Old-style color names including underscores are no longer supported.
- Removed priority counts from the 'projects' commands.
- Removed the unused 'locale' configuration variable.
- Removed the unused 'patterns' confguration variable.
- Removed the obsolete 'task-faq.5' man page.
- Removed the obsolete 'task-tutorial.5' man page.
- Removed the obsolete 'tasksh.1' man page.
- Removed the 'tasksh' program from the Taskwarrior distribution. It is now
a separate project.
- Removed the 'complete.all.projects' setting that was not used.
- Removed support for 'report.X.limit', which can now be set in the report
filter 'limit:N'.
- The 'total active time' information is removed from the 'info' report.
This was being misinterpreted as support for time tracking.
- The 'shadow file' feature is removed, but replaced with an example hook
script that performs the same function..
- None
Known Issues
- On Cygwin, case-insensitive regex searches are broken. The default is
now case-sensitive for Cygwin only.
- https://bug.tasktools.org
- If you upgraded from Taskwarrior 2.3.0, you will need one of the following
settings to allow continued syncing to a Taskserver:
$ task config taskd.trust strict
$ task config taskd.trust 'ignore hostname'
$ task config taskd.trust 'allow all'
These are presented in order of preference from most to least secure, and
depend on how your certs were generated.
- https://bug.tasktools.org/
Taskwarrior has been built and tested on the following configurations:
* OS X 10.10 Yosemite, 10.9 Mavericks
* Fedora 20 Heisenbug
* Ubuntu 14.04 Trusty Tahr
* Debian 7.0 Wheezy (stable)
* Arch 2014.05
* FreeBSD 10
* Cygwin 1.7.29, 1.7.32
* OS X
* Fedora
* Ubuntu
* Debian
* Arch
* FreeBSD
* Cygwin
---

View File

@@ -1,4 +1,4 @@
.TH task-color 5 2015-01-01 "${PACKAGE_STRING}" "User Manuals"
.TH task-color 5 2015-03-15 "${PACKAGE_STRING}" "User Manuals"
.SH NAME
task-color \- A color tutorial for the taskwarrior command line todo manager.

View File

@@ -1,4 +1,4 @@
.TH task-sync 5 2015-01-01 "${PACKAGE_STRING}" "User Manuals"
.TH task-sync 5 2015-03-15 "${PACKAGE_STRING}" "User Manuals"
.SH NAME
task-sync \- A discussion and tutorial for the various task(1) data

View File

@@ -1,4 +1,4 @@
.TH task 1 2015-01-01 "${PACKAGE_STRING}" "User Manuals"
.TH task 1 2015-03-15 "${PACKAGE_STRING}" "User Manuals"
.SH NAME
task \- A command line todo manager.
@@ -396,6 +396,46 @@ Finally, this command removes any 'name=...' entry from the .taskrc file:
task config name
.TP
.B task context <name>
Sets the currectly active context. See the CONTEXT section.
Example:
task context work
.TP
.B task context delete <name>
Deletes the context with the name <name>. If the context being deleted is currently
set as active, it will be unset.
Example:
task context delete work
.TP
.B task context define <name> <filter>
Defines a new context with name <name> and definition <filter>. This command
does not affect the currently set context, just adds a new context definition.
Examples:
task context define work project:Work
task context define home project:Home or +home
task context define superurgent due:today and +urgent
.TP
.B task context list
Outputs a list of available contexts along with their definitions.
.TP
.B task context none
Unsets the currently active context, if any was set.
.TP
.B task context show
Shows the currently active context, along with its definition.
.TP
.B task diagnostics
Shows diagnostic information, of the kind needed when reporting a problem.
@@ -474,6 +514,10 @@ Generates a list of all commands, for autocompletion purposes.
.B task _config
Lists all supported configuration variables, for completion purposes.
.TP
.B task _context
Lists all available context variables, for completion purposes.
.TP
.B task <filter> _ids
Shows only the IDs of matching tasks, in the form of a list.
@@ -962,6 +1006,66 @@ biannual, biyearly, 2yr
Every two years.
.RE
.SH CONTEXT
Context is a user-defined filter, which is automatically applied to all commands
that filter the task list. In particular, any report command will have its
result affected by the current active context.
$ task list
ID Age Project Description Urg
1 2d Sport Run 5 miles 1.42
2 1d Home Clean the dishes 1.14
$ task context home
Context 'home' set. Use 'task context none' to remove.
$ task list
ID Age Project Description Urg
2 1d Home Clean the dishes 1.14
Context 'home' set. Use 'task context none' to remove.
As seen in the example above, context is applied by specifying its name to the
"context" command. To change the currently applied context, just pass the
new context's name to the 'context' command.
To unset any context, use the 'none' subcommand.
$ task context none
Context unset.
$ task list
ID Age Project Description Urg
1 2d Sport Run 5 miles 1.42
2 1d Home Clean the dishes 1.14
Context can be defined using the 'define' subcommand, specifying both the name
of the new context, and it's assigned filter.
$ task context define home
Are you sure you want to add 'context.home' with a value of 'project:Home'? (yes/no) yes
Context 'home' successfully defined.
To remove the definition, use the 'delete' subcommand.
$ task context delete home
Are you sure you want to remove 'context.home'? (yes/no) yes
Context 'home' successfully undefined.
To check what is the currently active context, use the 'show' subcommand.
$ task context show
Context 'home' with filter 'project:Home' is currently applied.
Contexts can store arbitrarily complex filters.
$ task context define family project:Family or +paul or +nancy
Are you sure you want to add 'context.home' with a value of 'project:Family or +paul or +nancy'? (yes/no) yes
Context 'family' successfully defined.
Contexts are permanent, and the currently set context name is stored in the
"context" configuration variable. The context definition is stored in the
"context.<name>" configuration variable.
.SH COMMAND ABBREVIATION
All taskwarrior commands may be abbreviated as long as a unique prefix is used,
for example:
@@ -1057,11 +1161,11 @@ the 'data.location' configuration setting of the task data directory.
For examples please see the online documentation starting at
.RS
<http://taskwarrior.org/projects/taskwarrior/wiki>
<http://taskwarrior.org/docs>
.RE
Note that the online documentation is more detailed and more current than this
man page.
Note that the online documentation can be more detailed and more current than
this man page.
.SH FILES

View File

@@ -1,4 +1,4 @@
.TH taskrc 5 2015-01-01 "${PACKAGE_STRING}" "User Manuals"
.TH taskrc 5 2015-03-15 "${PACKAGE_STRING}" "User Manuals"
.SH NAME
taskrc \- Configuration details for the task(1) command
@@ -282,9 +282,8 @@ and project. The others are sent to standard output.
.TP
.B confirmation=yes
May be "yes" or "no", and determines whether taskwarrior will ask for
confirmation before deleting a task, performing bulk changes, or the undo
command. The default value is "yes". Consider leaving this setting as "yes",
for safety.
confirmation before deleting a task or performing the undo command. The default
value is "yes". Consider leaving this setting as "yes", for safety.
.TP
.B allow.empty.filter=yes
@@ -313,9 +312,9 @@ Controls padding between columns of the report output. Default is "1".
.TP
.B bulk=3
Is a number, defaulting to 3. When this number or greater of tasks are modified
in a single command, confirmation will be required, unless the
in a single command, confirmation will be required, regardless of the value of
.B confirmation
variable is "no".
variable.
This is useful for preventing large-scale unintended changes.
@@ -412,6 +411,11 @@ The character or string to show in the depends.indicator column. Defaults to +.
.B uda.<name>.indicator=U
The character or string to show in the <uda>.indicator column. Defaults to U.
.TP
.B recurrence=yes
Controls whether recurrence is enable, and whether recurring tasks continue to
generate new task instances. Defaults to 'yes'.
.TP
.B recurrence.confirmation=prompt
Controls whether changes to recurring tasks propagates to other child tasks with
@@ -616,6 +620,10 @@ field that is set. Otherwise, they are set to the corresponding values of
.RE
.RE
.TP
.B date.iso=yes
Enables ISO-8601 date support. The default value is "yes".
.TP
.B weekstart=Sunday
Determines the day a week starts. Valid values are Sunday or Monday only. The
@@ -1343,6 +1351,26 @@ of a task.
.B uda.estimate.values=trivial,small,medium,large,huge
.RE
.SS CONTEXT
Context setting is a mechanism which allows the user to set a permanent filter,
thus avoiding the need to specify one filter repeatedly. More details on usage
can be found in the task(1) manpage.
The current context is stored in the taskrc file, along with definitions for
all user provided contexts.
.TP
.B context=<name>
.RS
Stores the value of the currently active context.
.RE
.TP
.B context.<name>=<filter>
.RS
Stores the definition of the context with the name <name>.
.RE
.SS SYNC
These configuration settings are used to connect and sync tasks with the task

View File

@@ -1,15 +1,24 @@
Themes
To generate samples of themes, first execute the 'run' script to generate the
To generate samples of themes, first execute the 'setup' script to generate the
sample data. Note that this data may need to be tweaked to include qualities
that need to be illustrated in theme sample.
Then edit the 'rc' file to include the desired theme file.
Using a dark-background terminal (black recommended), run the following:
Then run 'per' to run a few commands for each theme.
run.dark
Note that this will require that the terminal window be switched between a black
and white background to properly show the light and dark themes.
Using a light-background terminal, run the following:
run.light
Using a solarized dark terminal, run the following:
run.solar.dark
Using a solarized light terminal, run the following:
run.solar.light
Note that for the solarized themes, the terminal color palette needs to be set
to specific colors.

View File

@@ -1,23 +0,0 @@
for theme in $PWD/../../rc/*.theme
do
cat <<EOF >>x
data.location=.
confirmation=off
_forcecolor=on
include $theme
EOF
echo "--- $theme -----------------------------------------------------"
echo '$ task list'
task rc:x list
echo '$ task summary'
task rc:x summary
echo '$ task ghistory'
task rc:x ghistory
echo '$ task calendar'
task rc:x calendar
echo '$ task burndown.daily'
task rc:x burndown.daily
done

View File

@@ -21,6 +21,8 @@ include $theme
EOF
echo "--- $theme -----------------------------------------------------"
echo '$ task color legend'
task rc:x color legend
echo '$ task list'
task rc:x list
echo '$ task summary'

24
doc/misc/themes/run.default Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
cat <<EOF >x
data.location=.
confirmation=off
detection=off
_forcecolor=on
default.height=24
verbose=off
EOF
echo "--- DEFAULT -----------------------------------------------------"
echo '$ task color legend'
task rc:x color legend
echo '$ task list'
task rc:x list
echo '$ task summary'
task rc:x summary
echo '$ task ghistory'
task rc:x ghistory
echo '$ task calendar'
task rc:x calendar
echo '$ task burndown.daily'
task rc:x burndown.daily

View File

@@ -14,6 +14,8 @@ include $theme
EOF
echo "--- $theme -----------------------------------------------------"
echo '$ task color legend'
task rc:x color legend
echo '$ task list'
task rc:x list
echo '$ task summary'

View File

@@ -13,6 +13,8 @@ include $theme
EOF
echo "--- $theme -----------------------------------------------------"
echo '$ task color legend'
task rc:x color legend
echo '$ task list'
task rc:x list
echo '$ task summary'

View File

@@ -13,6 +13,8 @@ include $theme
EOF
echo "--- $theme -----------------------------------------------------"
echo '$ task color legend'
task rc:x color legend
echo '$ task list'
task rc:x list
echo '$ task summary'

View File

@@ -33,15 +33,15 @@ color.alternate=
color.header=yellow
color.footnote=yellow
color.warning=bold red
color.error=yellow
color.debug=yellow
color.error=white on red
color.debug=blue
# Task state
color.completed=green on white
color.deleted=red on white
color.completed=
color.deleted=
color.active=black on bright green
color.recurring=magenta
color.scheduled=on green
color.scheduled=white on green
color.until=
color.blocked=black on white
color.blocking=black on bright white

View File

@@ -29,22 +29,22 @@ rule.precedence.color=deleted,completed,active,keyword.,tag.,uda.,project.,overd
# General decoration
color.label=
color.label.sort=
color.alternate=on gray1
color.alternate=on gray2
color.header=color3
color.footnote=color3
color.warning=bold red
color.error=color3
color.debug=color3
color.error=white on red
color.debug=color4
# Task state
color.completed=rgb010 on white
color.deleted=rgb100 on white
color.completed=
color.deleted=
color.active=rgb555 on rgb410
color.recurring=rgb013
color.scheduled=on rgb001
color.until=
color.blocked=white on color8
color.blocking=white on color15
color.blocking=black on color15
# Project
color.project.none=

View File

@@ -29,19 +29,19 @@ rule.precedence.color=deleted,completed,active,keyword.,tag.,uda.,project.,overd
# General decoration
color.label=
color.label.sort=
color.alternate=on gray1
color.alternate=on gray2
color.header=rgb013
color.footnote=rgb013
color.warning=bold red
color.error=rgb013
color.error=white on red
color.debug=rgb013
# Task state
color.completed=rgb001 on white
color.deleted=rgb100 on white
color.completed=
color.deleted=
color.active=rgb045 on rgb015
color.recurring=rgb115
color.scheduled=on rgb011
color.scheduled=on rgb012
color.until=
color.blocked=white on rgb001
color.blocking=white on rgb002
@@ -76,8 +76,8 @@ color.history.delete=color0 on rgb035
color.history.done=color0 on rgb025
# Report: summary
color.summary.background=white on color0
color.summary.bar=white on rgb003
color.summary.background=on rgb001
color.summary.bar=on rgb114
# Command: calendar
color.calendar.due.today=color0 on color252

View File

@@ -29,16 +29,16 @@ rule.precedence.color=deleted,completed,active,keyword.,tag.,uda.,project.,overd
# General decoration
color.label=
color.label.sort=
color.alternate=on gray1
color.alternate=on gray2
color.header=color0 on gray11
color.footnote=on gray5
color.warning=bold red
color.error=red on white
color.debug=black on white
color.error=white on red
color.debug=blue
# Task state
color.completed=black on white
color.deleted=black on white
color.completed=
color.deleted=
color.active=black on gray18
color.recurring=
color.scheduled=on gray8
@@ -61,7 +61,7 @@ color.tag.none=
color.tagged=
# Due
color.due=on gray2
color.due=on gray3
color.due.today=on gray4
color.overdue=on gray6
@@ -76,12 +76,12 @@ color.history.delete=black on gray10
color.history.done=gray5 on gray23
# Report: summary
color.summary.bar=on gray15
color.summary.background=on black
color.summary.bar=on gray12
color.summary.background=on gray5
# Command: calendar
color.calendar.due=on gray8
color.calendar.due.today=on gray15
color.calendar.due.today=black on gray15
color.calendar.holiday=black on gray20
color.calendar.overdue=gray2 on gray10
color.calendar.today=bold white
@@ -89,7 +89,7 @@ color.calendar.weekend=on gray2
color.calendar.weeknumber=gray6
# Command: sync
color.sync.add=gray15 on gray5
color.sync.added=gray15 on gray5
color.sync.changed=black on gray10
color.sync.rejected=gray5 on gray23

View File

@@ -29,12 +29,12 @@ rule.precedence.color=deleted,completed,active,keyword.,tag.,uda.,project.,overd
# General decoration
color.label=
color.label.sort=
color.alternate=on gray0
color.alternate=on gray2
color.header=gray10
color.footnote=gray10
color.warning=
color.error=rgb500
color.debug=rgb500
color.error=white on red
color.debug=blue
# Task state
color.completed=
@@ -44,7 +44,7 @@ color.recurring=
color.scheduled=
color.until=
color.blocked=bold gray10 on gray4
color.blocking=bold gray18 on gray6
color.blocking=gray18 on gray6
# Project
color.project.none=
@@ -66,18 +66,18 @@ color.due.today=color0 on rgb024
color.overdue=color0 on rgb035
# Report: burndown
color.burndown.pending=on gray9
color.burndown.started=on gray16
color.burndown.done=on rgb013
color.burndown.pending=white on gray9
color.burndown.started=black on gray16
color.burndown.done=white on rgb013
# Report: history
color.history.add=on gray9
color.history.delete=black on gray23
color.history.done=black on rgb013
color.history.add=white on gray6
color.history.delete=black on gray18
color.history.done=black on rgb024
# Report: summary
color.summary.bar=on rgb012
color.summary.background=on color0
color.summary.background=on gray2
# Command: calendar
color.calendar.due=color0 on gray10
@@ -94,6 +94,6 @@ color.sync.changed=gray15
color.sync.rejected=gray23
# Command: undo
color.undo.before=green
color.undo.after=red
color.undo.before=rgb013
color.undo.after=rgb035

View File

@@ -29,19 +29,19 @@ rule.precedence.color=deleted,completed,active,keyword.,tag.,uda.,project.,overd
# General decoration
color.label=
color.label.sort=
color.alternate=on gray1
color.alternate=on gray2
color.header=rgb031
color.footnote=rgb031
color.warning=bold red
color.error=rgb031
color.debug=rgb031
color.warning=rgb020
color.error=white on red
color.debug=blue
# Task state
color.completed=rgb020 on white
color.deleted=rgb200 on white
color.completed=
color.deleted=
color.active=rgb050 on rgb010
color.recurring=rgb151
color.scheduled=on rgb011
color.scheduled=black on rgb031
color.until=
color.blocked=white on rgb010
color.blocking=white on rgb020
@@ -76,7 +76,7 @@ color.history.delete=color0 on rgb050
color.history.done=color0 on rgb030
# Report: summary
color.summary.background=white on color0
color.summary.background=white on gray3
color.summary.bar=white on rgb030
# Command: calendar
@@ -95,4 +95,4 @@ color.sync.rejected=rgb010
# Command: undo
color.undo.after=rgb053
color.undo.before=rgb031
color.undo.before=rgb021

View File

@@ -29,19 +29,19 @@ rule.precedence.color=deleted,completed,active,keyword.,tag.,uda.,project.,overd
# General decoration
color.label=
color.label.sort=
color.alternate=on gray1
color.alternate=on gray2
color.header=rgb100
color.footnote=rgb100
color.warning=bold red
color.error=rgb100
color.debug=rgb100
color.warning=red
color.error=white on red
color.debug=blue
# Task state
color.completed=rgb020 on white
color.deleted=rgb200 on white
color.completed=
color.deleted=
color.active=rgb500 on rgb100
color.recurring=rgb511
color.scheduled=on rgb201
color.scheduled=white on rgb311
color.until=
color.blocked=white on rgb100
color.blocking=white on rgb200
@@ -56,7 +56,7 @@ color.pri.M=rgb400
color.pri.none=
# Tags
color.tag.next=rgb440
color.tag.next=rgb511
color.tag.none=
color.tagged=color246
@@ -94,6 +94,6 @@ color.sync.changed=rgb411
color.sync.rejected=rgb200
# Command: undo
color.undo.after=rgb503
color.undo.before=rgb301
color.undo.after=rgb511
color.undo.before=rgb200

View File

@@ -33,15 +33,15 @@ color.alternate=on gray2
color.header=rgb013
color.footnote=rgb013
color.warning=
color.error=rgb013
color.debug=rgb013
color.error=white on red
color.debug=blue
# Task state
color.completed=
color.deleted=
color.active=rgb445 on rgb213
color.recurring=rgb115
color.scheduled=
color.scheduled=white on rgb113
color.until=
color.blocked=white on rgb101
color.blocking=white on rgb202
@@ -61,9 +61,9 @@ color.tag.none=
color.tagged=rgb334
# Due
color.due=rgb055
color.due.today=rgb533
color.overdue=color9
color.due=rgb015
color.due.today=rgb125
color.overdue=color5
# Report: burndown
color.burndown.pending=on rgb103
@@ -76,14 +76,14 @@ color.history.done=color0 on rgb205
color.history.delete=color0 on rgb305
# Report: summary
color.summary.bar=white on rgb103
color.summary.background=white on color0
color.summary.bar=white on rgb104
color.summary.background=white on rgb001
# Command: calendar
color.calendar.due=color0 on rgb325
color.calendar.due.today=color0 on rgb404
color.calendar.holiday=color15 on rgb022
color.calendar.overdue=color0 on color9
color.calendar.holiday=color15 on rgb102
color.calendar.overdue=color0 on color5
color.calendar.today=color15 on rgb103
color.calendar.weekend=gray12 on gray3
color.calendar.weeknumber=rgb104

View File

@@ -33,15 +33,15 @@ color.alternate=on gray2
color.header=rgb031
color.footnote=rgb031
color.warning=
color.error=rgb031
color.debug=rgb031
color.error=white on red
color.debug=blue
# Task state
color.completed=
color.deleted=
color.active=rgb451 on rgb310
color.active=rgb451 on rgb320
color.recurring=rgb343
color.scheduled=
color.scheduled=black on rgb441
color.until=
color.blocked=white on rgb110
color.blocking=white on rgb220
@@ -61,9 +61,9 @@ color.tag.none=
color.tagged=rgb342
# Due
color.due=rgb420
color.due.today=rgb410
color.overdue=rgb400
color.due=rgb440
color.due.today=rgb430
color.overdue=rgb420
# Report: burndown
color.burndown.pending=on rgb110
@@ -71,19 +71,19 @@ color.burndown.started=on rgb430
color.burndown.done=on gray4
# Report: history
color.history.add=color0 on rgb010
color.history.done=color0 on rgb030
color.history.delete=color0 on rgb050
color.history.add=color0 on rgb110
color.history.done=color0 on rgb430
color.history.delete=white on gray4
# Report: summary
color.summary.bar=white on rgb030
color.summary.background=white on color0
color.summary.bar=white on rgb330
color.summary.background=white on rgb110
# Command: calendar
color.calendar.due=color0 on rgb430
color.calendar.due.today=color0 on rgb410
color.calendar.due=color0 on rgb440
color.calendar.due.today=color0 on rgb430
color.calendar.holiday=rgb151 on rgb020
color.calendar.overdue=color0 on rgb400
color.calendar.overdue=color0 on rgb420
color.calendar.today=color15 on rgb110
color.calendar.weekend=on color235
color.calendar.weeknumber=rgb110
@@ -94,6 +94,6 @@ color.sync.changed=rgb430
color.sync.rejected=rgb110
# Command: undo
color.undo.before=rgb031
color.undo.after=rgb053
color.undo.before=rgb021
color.undo.after=rgb042

View File

@@ -33,12 +33,12 @@ color.alternate=
color.header=bold white on bright black
color.footnote=bold cyan on bright black
color.warning=bold red
color.error=red on white
color.debug=white on black
color.error=white on red
color.debug=blue
# Task state
color.completed=green on black
color.deleted=red on black
color.completed=
color.deleted=
color.active=bold yellow on bright black
color.recurring=
color.scheduled=on bright cyan
@@ -63,17 +63,17 @@ color.tagged=
# Due
color.due=on bright green
color.due.today=on bright yellow
color.overdue=on bright magenta
color.overdue=on bright red
# Report: burndown
color.burndown.pending=on bright green
color.burndown.pending=on bright red
color.burndown.started=on bright yellow
color.burndown.done=on green
# Report: history
color.history.add=blue on bright yellow
color.history.done=green on bright green
color.history.delete=black on red
color.history.add=black on bright red
color.history.done=black on bright green
color.history.delete=black on yellow
# Report: summary
color.summary.bar=on bright green
@@ -82,11 +82,11 @@ color.summary.background=on white
# Command: calendar
color.calendar.due=on bright green
color.calendar.due.today=blue on bright yellow
color.calendar.holiday=yellow
color.calendar.overdue=on bright magenta
color.calendar.holiday=on yellow
color.calendar.overdue=on bright red
color.calendar.today=blue
color.calendar.weekend=on white
color.calendar.weeknumber=white on bright black
color.calendar.weeknumber=blue
# Command: sync
color.sync.added=green

View File

@@ -33,13 +33,13 @@ color.alternate=on gray22
color.header=color15 on gray8
color.footnote=on gray18
color.warning=color9
color.error=red on white
color.debug=color7 on color0
color.error=white on red
color.debug=rgb025
# Task state
color.completed=rgb353 on rgb000
color.deleted=rgb533 on rgb000
color.active=rgb420
color.completed=
color.deleted=
color.active=rgb510
color.recurring=
color.scheduled=on rgb345
color.until=
@@ -53,7 +53,7 @@ color.project.none=
color.pri.H=gray0
color.pri.M=gray5
color.pri.L=gray10
color.pri.none=gray5
color.pri.none=
# Tags
color.tag.next=rgb420
@@ -66,14 +66,14 @@ color.due.today=on rgb353
color.overdue=on rgb544
# Report: burndown
color.burndown.pending=on rgb141
color.burndown.started=on rgb440
color.burndown.pending=on rgb411
color.burndown.started=on rgb550
color.burndown.done=on rgb151
# Report: history
color.history.add=rgb005 on rgb440
color.history.done=rgb020 on rgb343
color.history.delete=rgb300 on rgb533
color.history.add=color0 on rgb411
color.history.done=color0 on rgb151
color.history.delete=color0 on rgb550
# Report: summary
color.summary.bar=on rgb141
@@ -82,7 +82,7 @@ color.summary.background=on gray20
# Command: calendar
color.calendar.due=on rgb343
color.calendar.due.today=on rgb353
color.calendar.holiday=rgb420
color.calendar.holiday=color0 on rgb530
color.calendar.overdue=on rgb533
color.calendar.today=rgb005
color.calendar.weekend=on gray21

View File

@@ -83,14 +83,14 @@ color.due.today=color1
color.overdue=color5
# Report: burndown
color.burndown.done=color0 on color4
color.burndown.done=color0 on color6
color.burndown.pending=color0 on color1
color.burndown.started=color0 on color9
color.burndown.started=color0 on color3
# Report: history
color.history.add=color0 on color1
color.history.delete=color0 on color3
color.history.done=color0 on color10
color.history.done=color0 on color6
# Report: summary
color.summary.background=on color0

View File

@@ -46,7 +46,7 @@ rule.precedence.color=deleted,completed,active,keyword.,tag.,uda.,project.,overd
# General decoration
color.label=
color.label.sort=
color.alternate=on white #color7 (allows bold for alternate rows)
color.alternate=on color7
color.header=color2
color.footnote=color2
color.warning=
@@ -56,20 +56,20 @@ color.debug=color3
# Task state
color.completed=
color.deleted=
color.active=bold red #color9
color.active=color9
color.recurring=color4
color.scheduled=
color.until=
color.blocked=on color14
color.blocking=on color14
color.blocked=color0 on color14
color.blocking=color15 on color0
# Project
color.project.none=
# Priority
color.pri.H=bold black #color0
color.pri.M=bold yellow #color11
color.pri.L=bold cyan #color14
color.pri.H=bold color0
color.pri.M=bold color11
color.pri.L=bold color14
color.pri.none=
# Tags
@@ -83,14 +83,14 @@ color.due.today=color1
color.overdue=color5
# Report: burndown
color.burndown.done=color0 on color4
color.burndown.done=color0 on color6
color.burndown.pending=color0 on color1
color.burndown.started=color0 on color9
color.burndown.started=color0 on color3
# Report: history
color.history.add=color0 on color1
color.history.delete=color0 on color3
color.history.done=color14 on color0
color.history.done=color0 on color6
# Report: summary
color.summary.background=on color7

Binary file not shown.

Binary file not shown.

View File

@@ -68,7 +68,13 @@ _task_offer_projects() {
COMPREPLY=( $(compgen -W "$($taskcommand _projects)" -- ${cur/*:/}) )
}
_task()
_task_offer_contexts() {
COMPREPLY=( $(compgen -W "$($taskcommand _context) define delete list none show" -- $cur) )
}
_task_context_alias=$($taskcommand show | grep alias.*context | cut -d' ' -f1 | cut -d. -f2)
_task()
{
local cur prev opts base
@@ -91,6 +97,10 @@ _task()
opts="$commands_aliases $($taskcommand _columns)"
case "${prev}" in
$_task_context_alias|cont|conte|contex|context)
_task_offer_contexts
return 0
;;
:)
case "${prev2}" in
pri|prior|priori|priorit|priority)

View File

@@ -1,20 +1,19 @@
#!/bin/bash
#!/bin/sh
# The on-add event is triggered separately for each task added
# The on-add event is triggered separately for each task added. This hook
# script can accept/reject the addition. Processing will continue.
# Input:
# - line of JSON for the task added
# Output:
# - all emitted JSON lines are added/modified as tasks, if the exit code is
# zero, otherwise ignored.
# - minimal new task: {"description":"Buy milk"}
# - to modify a task include complete JSON
# - all emitted non-JSON lines are considered feedback messages if the exit
# code is zero, otherwise they are considered errors.
# - Line of JSON for proposed new task.
read new_task
# Output:
# - JSON, modified or unmodified.
# - Optional feedback/error.
echo $new_task
echo 'on-add'
# Status:
# - 0: JSON accepted, non-JSON is feedback.
# - non-0: JSON ignored, non-JSON is error.
exit 0

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
read new_task

View File

@@ -1,20 +1,20 @@
#!/bin/bash
#!/bin/sh
# The on-exit event is triggered once, after all processing is complete, i.e.
# last
# The on-exit event is triggered once, after all processing is complete.
# This hooks script has no effect on processing.
# Input:
# - read-only line of JSON for each task added/modified
# Output:
# - any emitted JSON is ignored
# - all emitted non-JSON lines are considered feedback messages if the exit
# code is zero, otherwise they are considered errors.
while read -t 1 modified_task
# - Read-only line of JSON for each task added/modified
while read modified_task
do
# Scan task
echo $modified_task
done
# Output:
# - Optional feedback/error.
echo 'on-exit'
# Status:
# - 0: JSON ignored, non-JSON is feedback.
# - non-0: JSON ignored, non-JSON is error.
exit 0

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# This hook script replaces the shadow file feature, found in Taskwarrior
# prior to version 2.4.0.

View File

@@ -1,18 +1,17 @@
#!/bin/bash
#!/bin/sh
# The on-launch event is triggered once, after initialization, before any
# processing occurs, i.e first
# processing occurs. This hooks script has no effect on processing.
# Input:
# - none
# - None
# Output:
# - all emitted JSON lines are added/modified as tasks, if the exit code is
# zero, otherwise ignored.
# - minimal new task: {"description":"Buy milk"}
# - to modify a task include complete JSON
# - all emitted non-JSON lines are considered feedback messages if the exit
# code is zero, otherwise they are considered errors.
# - Optional feedback/error.
echo 'on-launch'
# Status:
# - 0: JSON ignored, non-JSON is feedback.
# - non-0: JSON ignored, non-JSON is error.
exit 0

View File

@@ -1,22 +1,21 @@
#!/bin/bash
#!/bin/sh
# The on-modify event is triggered separately for each task added or modified
# The on-modify event is triggered separately for each task modified. This hook
# script can accept/reject the modification. Processing will continue.
# Input:
# - line of JSON for the original task
# - line of JSON for the modified task, the diff being the modification
# Output:
# - all emitted JSON lines are added/modified as tasks, if the exit code is
# zero, otherwise ignored.
# - minimal new task: {"description":"Buy milk"}
# - to modify a task include complete JSON
# - all emitted non-JSON lines are considered feedback messages if the exit
# code is zero, otherwise they are considered errors.
read original_task
read modified_task
# Output:
# - JSON, modified or unmodified.
# - Optional feedback/error.
echo $modified_task
echo 'on-modify'
# Status:
# - 0: JSON accepted, non-JSON is feedback.
# - non-0: JSON ignored, non-JSON is error.
exit 0

View File

@@ -374,6 +374,64 @@ void CLI::add (const std::string& arg)
analyze ();
}
////////////////////////////////////////////////////////////////////////////////
void CLI::addContextFilter ()
{
// Detect if any context is set, and bail out if not
std::string contextName = context.config.get ("context");
if (contextName == "")
{
context.debug("No context applied.");
return;
}
// Detect if UUID or ID is set, and bail out
if (_args.size ())
{
std::vector <A>::const_iterator a;
for (a = _args.begin (); a != _args.end (); ++a)
{
if (a->hasTag ("FILTER") &&
a->hasTag ("ATTRIBUTE") &&
! a->hasTag ("TERMINATED") &&
! a->hasTag ("WORD") &&
(a->attribute ("raw") == "id" || a->attribute ("raw") == "uuid"))
{
context.debug(format("UUID/ID lexeme found '{1}', not applying context.", a->attribute ("raw")));
return;
}
}
}
// Apply context
context.debug("Applying context: " + contextName);
std::string contextFilter = context.config.get ("context." + contextName);
if (contextFilter == "")
context.debug("Context '" + contextName + "' not defined!");
else
{
addRawFilter("( " + contextFilter + " )");
if (context.verbose ("context"))
context.footnote (format("Context '{1}' set. Use 'task context none' to remove.", contextName));
}
}
////////////////////////////////////////////////////////////////////////////////
// Process raw string into parsed filter.
//
void CLI::addRawFilter (const std::string& arg)
{
std::string lexeme;
Lexer::Type type;
Lexer lex (arg);
lex.ambiguity (false);
while (lex.token (lexeme, type))
add (lexeme);
}
////////////////////////////////////////////////////////////////////////////////
// Intended to be called after ::initialize() and ::add(), to perform the final
// analysis. Analysis is also performed directly after the above, because there
@@ -474,8 +532,14 @@ void CLI::applyOverrides ()
////////////////////////////////////////////////////////////////////////////////
// Extract all the FILTER-tagged items.
const std::string CLI::getFilter ()
const std::string CLI::getFilter (bool applyContext /* = true */)
{
// Handle context setting
// Commands that don't want to respect current context should leverage
// the applyContext argument
if (applyContext)
addContextFilter ();
std::string filter = "";
if (_args.size ())
{
@@ -500,6 +564,7 @@ const std::string CLI::getFilter ()
filter = "( " + filter + " )";
}
context.debug("Derived filter: '" + filter + "'");
return filter;
}

View File

@@ -77,9 +77,11 @@ public:
void entity (const std::string&, const std::string&);
void initialize (int, const char**);
void add (const std::string&);
void addContextFilter ();
void addRawFilter (const std::string& arg);
void analyze (bool parse = true, bool strict = false);
void applyOverrides ();
const std::string getFilter ();
const std::string getFilter (bool applyContext = true);
const std::vector <std::string> getWords ();
bool canonicalize (std::string&, const std::string&, const std::string&) const;
std::string getBinary () const;

View File

@@ -82,6 +82,7 @@ std::string Config::_defaults =
"# # Comma-separated list. May contain any subset of:\n"
"#verbose=blank,header,footnote,label,new-id,new-uuid,affected,edit,special,project,sync,filter\n"
"confirmation=yes # Confirmation on delete, big changes\n"
"recurrence=yes # Enable recurrence\n"
"recurrence.confirmation=prompt # Confirmation for propagating changes among recurring tasks (yes/no/prompt)\n"
"allow.empty.filter=yes # An empty filter gets a warning and requires confirmation\n"
"indent.annotation=2 # Indent spaces for annotations\n"
@@ -116,6 +117,7 @@ std::string Config::_defaults =
"dateformat.info=Y-M-D H:N:S # Preferred display date format for information\n"
"dateformat.report= # Preferred display date format for reports\n"
"dateformat.annotation= # Preferred display date format for annotations\n"
"date.iso=yes # Enable ISO date support\n"
"weekstart="
STRING_DATE_SUNDAY_LONG
" # Sunday or Monday only\n"
@@ -163,29 +165,29 @@ std::string Config::_defaults =
"\n"
"# Color controls.\n"
"color=on # Enable color\n"
#ifdef LINUX
#if defined(LINUX) || defined(DARWIN)
"\n"
"rule.precedence.color=deleted,completed,active,keyword.,tag.,uda.,project.,overdue,scheduled,due.today,due,blocked,blocking,recurring,tagged,pri.\n"
"\n"
"# General decoration\n"
"color.label=\n"
"color.label.sort=\n"
"color.alternate=on gray1\n"
"color.alternate=on gray2\n"
"color.header=color3\n"
"color.footnote=color3\n"
"color.warning=bold red\n"
"color.error=color3\n"
"color.debug=color3\n"
"color.error=white on red\n"
"color.debug=color4\n"
"\n"
"# Task state\n"
"color.completed=rgb010 on white\n"
"color.deleted=rgb100 on white\n"
"color.completed=\n"
"color.deleted=\n"
"color.active=rgb555 on rgb410\n"
"color.recurring=rgb013\n"
"color.scheduled=on rgb001\n"
"color.until=\n"
"color.blocked=white on color8\n"
"color.blocking=white on color15\n"
"color.blocking=black on color15\n"
"\n"
"# Project\n"
"color.project.none=\n"
@@ -249,15 +251,15 @@ std::string Config::_defaults =
"color.header=yellow\n"
"color.footnote=yellow\n"
"color.warning=bold red\n"
"color.error=yellow\n"
"color.debug=yellow\n"
"color.error=white on red\n"
"color.debug=blue\n"
"\n"
"# Task state\n"
"color.completed=green on white\n"
"color.deleted=red on white\n"
"color.completed=\n"
"color.deleted=\n"
"color.active=black on bright green\n"
"color.recurring=magenta\n"
"color.scheduled=on green\n"
"color.scheduled=white on green\n"
"color.until=\n"
"color.blocked=black on white\n"
"color.blocking=black on bright white\n"
@@ -358,19 +360,19 @@ std::string Config::_defaults =
"\n"
"report.long.description=All details of tasks\n"
"report.long.labels=ID,A,Created,Mod,Deps,P,Project,Tags,Recur,Wait,Sched,Due,Until,Description\n"
"report.long.columns=id,start.active,entry,modified.age,depends,priority,project,tags,recur,wait.age,scheduled,due,until,description\n"
"report.long.columns=id,start.active,entry,modified.age,depends,priority,project,tags,recur,wait.remaining,scheduled,due,until,description\n"
"report.long.filter=status:pending\n"
"report.long.sort=modified-\n"
"\n"
"report.list.description=Most details of tasks\n"
"report.list.labels=ID,Active,Age,D,P,Project,Tags,R,Sch,Due,Until,Description,Urg\n"
"report.list.columns=id,start.age,entry.age,depends.indicator,priority,project,tags,recur.indicator,scheduled.countdown,due,until.age,description.count,urgency\n"
"report.list.columns=id,start.age,entry.age,depends.indicator,priority,project,tags,recur.indicator,scheduled.countdown,due,until.remaining,description.count,urgency\n"
"report.list.filter=status:pending\n"
"report.list.sort=start-,due+,project+/,urgency-\n"
"report.list.sort=start-,due+,project+,urgency-\n"
"\n"
"report.ls.description=Few details of tasks\n"
"report.ls.labels=ID,A,D,Project,Tags,R,Wait,S,Due,Until,Description\n"
"report.ls.columns=id,start.active,depends.indicator,project,tags,recur.indicator,wait.age,scheduled.countdown,due.countdown,until.countdown,description.count\n"
"report.ls.columns=id,start.active,depends.indicator,project,tags,recur.indicator,wait.remaining,scheduled.countdown,due.countdown,until.countdown,description.count\n"
"report.ls.filter=status:pending\n"
"report.ls.sort=start-,description+\n"
"\n"
@@ -382,13 +384,13 @@ std::string Config::_defaults =
"\n"
"report.newest.description=Newest tasks\n"
"report.newest.labels=ID,Active,Created,Age,Mod,D,P,Project,Tags,R,Wait,Sch,Due,Until,Description\n"
"report.newest.columns=id,start.age,entry,entry.age,modified.age,depends.indicator,priority,project,tags,recur.indicator,wait.age,scheduled.countdown,due,until.age,description\n"
"report.newest.columns=id,start.age,entry,entry.age,modified.age,depends.indicator,priority,project,tags,recur.indicator,wait.remaining,scheduled.countdown,due,until.age,description\n"
"report.newest.filter=(status:pending or status:waiting) and recur.none:\n"
"report.newest.sort=entry-\n"
"\n"
"report.oldest.description=Oldest tasks\n"
"report.oldest.labels=ID,Active,Created,Age,Mod,D,P,Project,Tags,R,Wait,Sch,Due,Until,Description\n"
"report.oldest.columns=id,start.age,entry,entry.age,modified.age,depends.indicator,priority,project,tags,recur.indicator,wait.age,scheduled.countdown,due,until.age,description\n"
"report.oldest.columns=id,start.age,entry,entry.age,modified.age,depends.indicator,priority,project,tags,recur.indicator,wait.remaining,scheduled.countdown,due,until.age,description\n"
"report.oldest.filter=(status:pending or status:waiting)\n"
"report.oldest.sort=entry+\n"
"\n"
@@ -400,7 +402,7 @@ std::string Config::_defaults =
"\n"
"report.active.description=Active tasks\n"
"report.active.labels=ID,Started,Active,Age,D,P,Project,Tags,Recur,W,Sch,Due,Until,Description\n"
"report.active.columns=id,start,start.age,entry.age,depends.indicator,priority,project,tags,recur,wait.indicator,scheduled.age,due,until,description\n"
"report.active.columns=id,start,start.age,entry.age,depends.indicator,priority,project,tags,recur,wait.indicator,scheduled.remaining,due,until,description\n"
"report.active.filter=status:pending and +ACTIVE\n"
"report.active.sort=project+,start+\n"
"\n"
@@ -412,30 +414,30 @@ std::string Config::_defaults =
"\n"
"report.recurring.description=Recurring Tasks\n"
"report.recurring.labels=ID,Active,Age,D,P,Project,Tags,Recur,Sch,Due,Until,Description,Urg\n"
"report.recurring.columns=id,start.age,entry.age,depends.indicator,priority,project,tags,recur,scheduled.countdown,due,until.age,description,urgency\n"
"report.recurring.columns=id,start.age,entry.age,depends.indicator,priority,project,tags,recur,scheduled.countdown,due,until.remaining,description,urgency\n"
"report.recurring.filter=(status:pending or status:waiting) and (+PARENT or +CHILD)\n"
"report.recurring.sort=due+,urgency-,entry+\n"
"\n"
"report.waiting.description=Waiting (hidden) tasks\n"
"report.waiting.labels=ID,A,Age,D,P,Project,Tags,R,Wait,for,Sched,Due,Until,Description\n"
"report.waiting.columns=id,start.active,entry.age,depends.indicator,priority,project,tags,recur.indicator,wait,wait.age,scheduled,due,until,description\n"
"report.waiting.columns=id,start.active,entry.age,depends.indicator,priority,project,tags,recur.indicator,wait,wait.remaining,scheduled,due,until,description\n"
"report.waiting.filter=+WAITING\n"
"report.waiting.sort=due+,wait+,entry+\n"
"\n"
"report.all.description=All tasks\n"
"report.all.labels=ID,St,UUID,A,Age,Done,D,P,Project,Tags,R,Wait,Sch,Due,Until,Description\n"
"report.all.columns=id,status.short,uuid.short,start.active,entry.age,end.age,depends.indicator,priority,project.parent,tags.count,recur.indicator,wait.age,scheduled.age,due,until.age,description\n"
"report.all.columns=id,status.short,uuid.short,start.active,entry.age,end.age,depends.indicator,priority,project.parent,tags.count,recur.indicator,wait.remaining,scheduled.remaining,due,until.remaining,description\n"
"report.all.sort=entry-\n"
"\n"
"report.next.description=Most urgent tasks\n"
"report.next.labels=ID,Active,Age,Deps,P,Project,Tag,Recur,S,Due,Until,Description,Urg\n"
"report.next.columns=id,start.age,entry.age,depends,priority,project,tags,recur,scheduled.countdown,due.age,until.age,description,urgency\n"
"report.next.columns=id,start.age,entry.age,depends,priority,project,tags,recur,scheduled.countdown,due.remaining,until.remaining,description,urgency\n"
"report.next.filter=status:pending limit:page\n"
"report.next.sort=start-,urgency-\n"
"report.next.sort=urgency-\n"
"\n"
"report.ready.description=Most urgent actionable tasks\n"
"report.ready.labels=ID,Active,Age,D,P,Project,Tags,R,S,Due,Until,Description,Urg\n"
"report.ready.columns=id,start.age,entry.age,depends.indicator,priority,project,tags,recur.indicator,scheduled.countdown,due.countdown,until.age,description,urgency\n"
"report.ready.columns=id,start.age,entry.age,depends.indicator,priority,project,tags,recur.indicator,scheduled.countdown,due.countdown,until.remaining,description,urgency\n"
"report.ready.filter=+READY\n"
"report.ready.sort=start-,urgency-\n"
"\n"
@@ -453,7 +455,7 @@ std::string Config::_defaults =
"\n"
"report.blocking.description=Blocking tasks\n"
"report.blocking.labels=ID,UUID,A,Deps,Project,Tags,R,W,Sch,Due,Until,Description,Urg\n"
"report.blocking.columns=id,uuid.short,start.active,depends,project,tags,recur,wait.indicator,scheduled.age,due.age,until.age,description.count,urgency\n"
"report.blocking.columns=id,uuid.short,start.active,depends,project,tags,recur,wait.indicator,scheduled.remaining,due.remaining,until.remaining,description.count,urgency\n"
"report.blocking.sort=urgency-,due+,entry+\n"
"report.blocking.filter= status:pending +BLOCKING\n"
"\n";

View File

@@ -275,7 +275,7 @@ int Context::initialize (int argc, const char** argv)
////////////////////////////////////////////////////////////////////////////
//
// [8] Run on.launch hooks.
// [8] Initialize hooks.
//
////////////////////////////////////////////////////////////////////////////
@@ -504,7 +504,7 @@ bool Context::color ()
use_color = config.getBoolean ("color");
// Only tty's support color.
if (! isatty (fileno (stdout)))
if (! isatty (STDOUT_FILENO))
{
// No ioctl.
config.set ("detection", "off");
@@ -658,6 +658,7 @@ void Context::staticInitialization ()
Task::searchCaseSensitive = Variant::searchCaseSensitive = config.getBoolean ("search.case.sensitive");
Task::regex = Variant::searchUsingRegex = config.getBoolean ("regex");
Lexer::dateFormat = Variant::dateFormat = config.get ("dateformat");
Lexer::isoEnabled = Variant::isoEnabled = config.getBoolean ("date.iso");
std::map <std::string, Column*>::iterator i;
for (i = columns.begin (); i != columns.end (); ++i)
@@ -770,7 +771,7 @@ void Context::clear ()
// this output?'.
void Context::updateXtermTitle ()
{
if (config.getBoolean ("xterm.title") && isatty (fileno (stdout)))
if (config.getBoolean ("xterm.title") && isatty (STDOUT_FILENO))
{
std::string command = cli.getCommand ();
std::string title;

View File

@@ -240,6 +240,12 @@ bool DOM::get (const std::string& name, const Task& task, Variant& value)
Column* column = context.columns[canonical];
if (column)
{
if (column->is_uda () && ! task.has (canonical))
{
value = Variant ("''");
return true;
}
if (column->type () == "date")
value = Variant (task.get_date (canonical), Variant::type_date);
else if (column->type () == "duration" || canonical == "recur")
@@ -307,6 +313,12 @@ bool DOM::get (const std::string& name, const Task& task, Variant& value)
Column* column = context.columns[canonical];
if (column)
{
if (column->is_uda () && ! ref.has (canonical))
{
value = Variant ("''");
return true;
}
if (column->type () == "date")
value = Variant (ref.get_date (canonical), Variant::type_date);
else if (column->type () == "duration")

View File

@@ -61,31 +61,48 @@ static struct
{"fortnight", 14 * DAY, true},
{"hours", 1 * HOUR, false},
{"hour", 1 * HOUR, true},
{"hrs", 1 * HOUR, true},
{"hr", 1 * HOUR, true},
{"h", 1 * HOUR, false},
{"minutes", 1 * MINUTE, false},
{"minute", 1 * MINUTE, false},
{"mins", 1 * MINUTE, false},
{"min", 1 * MINUTE, false},
{"monthly", 30 * DAY, true},
{"months", 30 * DAY, false},
{"month", 30 * DAY, true},
{"mnths", 30 * DAY, false},
{"mths", 30 * DAY, false},
{"mth", 30 * DAY, false},
{"mos", 30 * DAY, false},
{"mo", 30 * DAY, false},
{"m", 30 * DAY, false},
{"quarterly", 91 * DAY, true},
{"quarters", 91 * DAY, false},
{"quarter", 91 * DAY, true},
{"qrtrs", 91 * DAY, false},
{"qtrs", 91 * DAY, false},
{"qtr", 91 * DAY, false},
{"q", 91 * DAY, false},
{"semiannual", 183 * DAY, true},
{"sennight", 14 * DAY, false},
{"seconds", 1 * SECOND, false},
{"second", 1 * SECOND, true},
{"secs", 1 * SECOND, true},
{"sec", 1 * SECOND, true},
{"s", 1 * SECOND, false},
{"weekdays", 1 * DAY, true},
{"weekly", 7 * DAY, true},
{"weeks", 7 * DAY, false},
{"week", 7 * DAY, true},
{"wks", 7 * DAY, true},
{"wk", 7 * DAY, true},
{"w", 7 * DAY, false},
{"yearly", 365 * DAY, true},
{"years", 365 * DAY, false},
{"year", 365 * DAY, true},
{"yrs", 365 * DAY, true},
{"yr", 365 * DAY, true},
{"y", 365 * DAY, false},
};

View File

@@ -67,7 +67,7 @@ Filter::~Filter ()
////////////////////////////////////////////////////////////////////////////////
// Take an input set of tasks and filter into a subset.
void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output)
void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output, bool applyContext /* = true */)
{
context.timer_filter.start ();
_startCount = (int) input.size ();
@@ -75,7 +75,7 @@ void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output
if (context.config.getInteger ("debug.parser") >= 1)
context.debug (context.cli.dump ("Filter::subset"));
std::string filterExpr = context.cli.getFilter ();
std::string filterExpr = context.cli.getFilter (applyContext);
if (filterExpr.length ())
{
Eval eval;
@@ -111,7 +111,7 @@ void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output
////////////////////////////////////////////////////////////////////////////////
// Take the set of all tasks and filter into a subset.
void Filter::subset (std::vector <Task>& output)
void Filter::subset (std::vector <Task>& output, bool applyContext /* = true */)
{
context.timer_filter.start ();
@@ -119,7 +119,7 @@ void Filter::subset (std::vector <Task>& output)
context.debug (context.cli.dump ("Filter::subset"));
bool shortcut = false;
std::string filterExpr = context.cli.getFilter ();
std::string filterExpr = context.cli.getFilter (applyContext);
if (filterExpr.length ())
{
context.timer_filter.stop ();

View File

@@ -40,8 +40,8 @@ public:
Filter ();
~Filter ();
void subset (const std::vector <Task>&, std::vector <Task>&);
void subset (std::vector <Task>&);
void subset (const std::vector <Task>&, std::vector <Task>&, bool applyContext = true);
void subset (std::vector <Task>&, bool applyContext = true);
bool pendingOnly ();
void safety ();

View File

@@ -38,8 +38,10 @@
#include <Context.h>
#include <JSON.h>
#include <Hooks.h>
#include <Timer.h>
#include <text.h>
#include <util.h>
#include <i18n.h>
extern Context context;
@@ -73,7 +75,17 @@ void Hooks::initialize ()
{
std::vector <std::string>::iterator i;
for (i = _scripts.begin (); i != _scripts.end (); ++i)
context.debug ("Found hook script " + *i);
{
Path p (*i);
std::string name = p.name ();
if (name.substr (0, 6) == "on-add" ||
name.substr (0, 9) == "on-modify" ||
name.substr (0, 9) == "on-launch" ||
name.substr (0, 7) == "on-exit")
context.debug ("Found hook script " + *i);
else
context.debug ("Found misnamed hook script " + *i);
}
}
}
else if (_debug >= 1)
@@ -98,8 +110,7 @@ bool Hooks::enable (bool value)
// - none
//
// Output:
// - all emitted JSON lines are added/modified as tasks, if the exit code is
// zero, otherwise ignored.
// - JSON not allowed.
// - all emitted non-JSON lines are considered feedback or error messages
// depending on the status code.
//
@@ -120,29 +131,28 @@ void Hooks::onLaunch ()
std::vector <std::string> output;
int status = callHookScript (*script, input, output);
std::vector <std::string>::iterator line;
for (line = output.begin (); line != output.end (); ++line)
{
if (isJSON (*line))
{
if (status == 0)
{
// Only 'add' is possible.
Task newTask (*line);
context.tdb2.add (newTask);
}
}
else
{
if (status == 0)
context.header (*line);
else
context.error (*line);
}
}
std::vector <std::string> outputJSON;
std::vector <std::string> outputFeedback;
separateOutput (output, outputJSON, outputFeedback);
assertNTasks (outputJSON, 0);
if (status == 0)
{
std::vector <std::string>::iterator message;
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
context.footnote (*message);
}
else
{
assertFeedback (outputFeedback);
std::vector <std::string>::iterator message;
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
context.error (*message);
if (status)
throw 0; // This is how hooks silently terminate processing.
}
}
}
@@ -157,7 +167,7 @@ void Hooks::onLaunch ()
// - read-only line of JSON for each task added/modified
//
// Output:
// - any emitted JSON is ignored
// - all emitted JSON is ignored
// - all emitted non-JSON lines are considered feedback or error messages
// depending on the status code.
//
@@ -188,24 +198,28 @@ void Hooks::onExit ()
std::vector <std::string> output;
int status = callHookScript (*script, input, output);
std::vector <std::string>::iterator line;
for (line = output.begin (); line != output.end (); ++line)
{
if (isJSON (*line))
{
context.error ("JSON output ignored: {1}");
}
else
{
if (status == 0)
context.footnote (*line);
else
context.error (*line);
}
}
std::vector <std::string> outputJSON;
std::vector <std::string> outputFeedback;
separateOutput (output, outputJSON, outputFeedback);
assertNTasks (outputJSON, 0);
if (status == 0)
{
std::vector <std::string>::iterator message;
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
context.footnote (*message);
}
else
{
assertFeedback (outputFeedback);
std::vector <std::string>::iterator message;
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
context.error (*message);
if (status)
throw 0; // This is how hooks silently terminate processing.
}
}
}
@@ -219,14 +233,14 @@ void Hooks::onExit ()
// - line of JSON for the task added
//
// Output:
// - all emitted JSON lines are added/modified as tasks, if the exit code is
// zero, otherwise ignored.
// - emitted JSON for the input task is added, if the exit code is zero,
// otherwise ignored.
// - all emitted non-JSON lines are considered feedback or error messages
// depending on the status code.
//
void Hooks::onAdd (std::vector <Task>& tasks)
void Hooks::onAdd (Task& task)
{
if (! _enabled || tasks.size () < 1)
if (! _enabled)
return;
context.timer_hooks.start ();
@@ -234,9 +248,9 @@ void Hooks::onAdd (std::vector <Task>& tasks)
std::vector <std::string> matchingScripts = scripts ("on-add");
if (matchingScripts.size ())
{
// Convert vector of tasks to a vector of strings.
// Convert task to a vector of strings.
std::vector <std::string> input;
input.push_back (tasks[0].composeJSON ());
input.push_back (task.composeJSON ());
// Call the hook scripts.
std::vector <std::string>::iterator script;
@@ -245,33 +259,37 @@ void Hooks::onAdd (std::vector <Task>& tasks)
std::vector <std::string> output;
int status = callHookScript (*script, input, output);
input.clear ();
std::vector <std::string>::iterator line;
for (line = output.begin (); line != output.end (); ++line)
{
if (isJSON (*line))
{
if (status == 0)
input.push_back (*line);
}
else
{
if (status == 0)
context.footnote (*line);
else
context.error (*line);
}
}
std::vector <std::string> outputJSON;
std::vector <std::string> outputFeedback;
separateOutput (output, outputJSON, outputFeedback);
if (status == 0)
{
assertNTasks (outputJSON, 1);
assertValidJSON (outputJSON);
assertSameTask (outputJSON, task);
// Propagate forward to the next script.
input[0] = outputJSON[0];
std::vector <std::string>::iterator message;
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
context.footnote (*message);
}
else
{
assertFeedback (outputFeedback);
std::vector <std::string>::iterator message;
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
context.error (*message);
if (status)
throw 0; // This is how hooks silently terminate processing.
}
}
// Transfer the modified task lines back to the original task list.
tasks.clear ();
std::vector <std::string>::iterator i;
for (i = input.begin (); i != input.end (); ++i)
tasks.push_back (Task (*i));
// Transfer the modified task back to the original task.
task = Task (input[0]);
}
context.timer_hooks.stop ();
@@ -285,14 +303,14 @@ void Hooks::onAdd (std::vector <Task>& tasks)
// - line of JSON for the modified task, the diff being the modification
//
// Output:
// - all emitted JSON lines are added/modified as tasks, if the exit code is
// zero, otherwise ignored.
// - emitted JSON for the input task is saved, if the exit code is zero,
// otherwise ignored.
// - all emitted non-JSON lines are considered feedback or error messages
// depending on the status code.
//
void Hooks::onModify (const Task& before, std::vector <Task>& tasks)
void Hooks::onModify (const Task& before, Task& after)
{
if (! _enabled || tasks.size () < 1)
if (! _enabled)
return;
context.timer_hooks.start ();
@@ -300,61 +318,48 @@ void Hooks::onModify (const Task& before, std::vector <Task>& tasks)
std::vector <std::string> matchingScripts = scripts ("on-modify");
if (matchingScripts.size ())
{
// Prepare invariants.
std::string beforeJSON = before.composeJSON ();
std::string uuidPattern = "\"uuid\":\"" + before.get ("uuid") + "\"";
// Convert vector of tasks to a vector of strings.
std::vector <std::string> input;
input.push_back (beforeJSON); // [0] original, never changes
input.push_back (tasks[0].composeJSON ()); // [1] original'
input.push_back (before.composeJSON ()); // [line 0] original, never changes
input.push_back (after.composeJSON ()); // [line 1] modified
// Call the hook scripts.
std::vector <std::string>::iterator script;
for (script = matchingScripts.begin (); script != matchingScripts.end (); ++script)
{
std::vector <std::string> firstTwoOnly;
firstTwoOnly.push_back (input[0]);
firstTwoOnly.push_back (input[1]);
std::vector <std::string> output;
int status = callHookScript (*script, firstTwoOnly, output);
int status = callHookScript (*script, input, output);
// Start from scratch.
input[1] = ""; // [1] placeholder for original'
std::vector <std::string> outputJSON;
std::vector <std::string> outputFeedback;
separateOutput (output, outputJSON, outputFeedback);
std::vector <std::string>::iterator line;
for (line = output.begin (); line != output.end (); ++line)
if (status == 0)
{
if (isJSON (*line))
{
if (status == 0)
{
if (line->find (uuidPattern) != std::string::npos)
input[1] = *line; // [1] original'
else
input.push_back (*line); // [n > 1] extras
}
}
else
{
if (status == 0)
context.footnote (*line);
else
context.error (*line);
}
}
assertNTasks (outputJSON, 1);
assertValidJSON (outputJSON);
assertSameTask (outputJSON, before);
// Propagate accepted changes forward to the next script.
input[1] = outputJSON[0];
std::vector <std::string>::iterator message;
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
context.footnote (*message);
}
else
{
assertFeedback (outputFeedback);
std::vector <std::string>::iterator message;
for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message)
context.error (*message);
if (status)
throw 0; // This is how hooks silently terminate processing.
}
}
// Transfer the modified task lines back to the original task list.
tasks.clear ();
std::vector <std::string>::iterator i;
for (i = input.begin (); i != input.end (); ++i)
if (i != input.begin ())
tasks.push_back (Task (*i));
after = Task (input[1]);
}
context.timer_hooks.stop ();
@@ -384,65 +389,135 @@ std::vector <std::string> Hooks::scripts (const std::string& event)
return matching;
}
////////////////////////////////////////////////////////////////////////////////
void Hooks::separateOutput (
const std::vector <std::string>& output,
std::vector <std::string>& json,
std::vector <std::string>& feedback) const
{
std::vector <std::string>::const_iterator i;
for (i = output.begin (); i != output.end (); ++i)
{
if (isJSON (*i))
json.push_back (*i);
else
feedback.push_back (*i);
}
}
////////////////////////////////////////////////////////////////////////////////
bool Hooks::isJSON (const std::string& input) const
{
// Does it even look like JSON? {...}
if (input.length () > 2 &&
input[0] == '{' &&
input[input.length () - 1] == '}')
return input.length () > 2 &&
input[0] == '{' &&
input[input.length () - 1] == '}';
}
////////////////////////////////////////////////////////////////////////////////
void Hooks::assertValidJSON (const std::vector <std::string>& input) const
{
std::vector <std::string>::const_iterator i;
for (i = input.begin (); i != input.end (); i++)
{
if (i->length () < 3 ||
(*i)[0] != '{' ||
(*i)[i->length () - 1] != '}')
{
context.error (STRING_HOOK_ERROR_OBJECT);
throw 0;
}
try
{
// The absolute minimum a task needs is:
bool foundDescription = false;
// Parse the whole thing.
json::value* root = json::parse (input);
if (root->type () == json::j_object)
json::value* root = json::parse (*i);
if (root->type () != json::j_object)
{
json::object* root_obj = (json::object*)root;
// For each object element...
json_object_iter i;
for (i = root_obj->_data.begin ();
i != root_obj->_data.end ();
++i)
{
// If the attribute is a recognized column.
std::string type = Task::attributes[i->first];
if (type == "string" && i->first == "description")
foundDescription = true;
}
context.error (STRING_HOOK_ERROR_OBJECT);
throw 0;
}
else
throw std::string ("Object expected.");
// It's JSON, but is it a task?
if (! foundDescription)
throw std::string ("Missing 'description' attribute, of type 'string'.");
if (((json::object*)root)->_data.find ("description") == ((json::object*)root)->_data.end ())
{
context.error (STRING_HOOK_ERROR_NODESC);
throw 0;
}
// Yep, looks like a JSON task.
return true;
if (((json::object*)root)->_data.find ("uuid") == ((json::object*)root)->_data.end ())
{
context.error (STRING_HOOK_ERROR_NOUUID);
throw 0;
}
}
catch (const std::string& e)
{
if (_debug >= 1)
context.error ("Hook output looks like JSON, but is not a valid task.");
if (_debug >= 2)
context.error ("JSON " + e);
context.error (format (STRING_HOOK_ERROR_SYNTAX, *i));
if (_debug)
context.error (STRING_HOOK_ERROR_JSON + e);
throw 0;
}
catch (...)
{
if (_debug >= 1)
context.error ("Hook output looks like JSON, but fails to parse.");
context.error (STRING_HOOK_ERROR_NOPARSE + *i);
throw 0;
}
}
}
return false;
////////////////////////////////////////////////////////////////////////////////
void Hooks::assertNTasks (const std::vector <std::string>& input, int n) const
{
if (input.size () != n)
{
context.error (format (STRING_HOOK_ERROR_BAD_NUM, n, (int) input.size ()));
throw 0;
}
}
////////////////////////////////////////////////////////////////////////////////
void Hooks::assertSameTask (const std::vector <std::string>& input, const Task& task) const
{
std::string uuid = task.get ("uuid");
std::vector <std::string>::const_iterator i;
for (i = input.begin (); i != input.end (); i++)
{
json::object* root_obj = (json::object*)json::parse (*i);
// If there is no UUID at all.
json_object_iter u = root_obj->_data.find ("uuid");
if (u == root_obj->_data.end () ||
u->second->type () != json::j_string)
{
context.error (format (STRING_HOOK_ERROR_SAME1, uuid));
throw 0;
}
json::string* up = (json::string*) u->second;
std::string json_uuid = json::decode (unquoteText (up->dump ()));
if (json_uuid != uuid)
{
context.error (format (STRING_HOOK_ERROR_SAME2, uuid, json_uuid));
throw 0;
}
}
}
////////////////////////////////////////////////////////////////////////////////
void Hooks::assertFeedback (const std::vector <std::string>& input) const
{
bool foundSomething = false;
std::vector <std::string>::const_iterator i;
for (i = input.begin (); i != input.end (); ++i)
if (nontrivial (*i))
foundSomething = true;
if (! foundSomething)
{
context.error (STRING_HOOK_ERROR_NOFEEDBACK);
throw 0;
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -452,11 +527,11 @@ int Hooks::callHookScript (
std::vector <std::string>& output)
{
if (_debug >= 1)
context.debug ("Hooks: Calling " + script);
context.debug ("Hook: Calling " + script);
if (_debug >= 2)
{
context.debug ("Hooks: input");
context.debug ("Hook: input");
std::vector <std::string>::const_iterator i;
for (i = input.begin (); i != input.end (); ++i)
context.debug (" " + *i);
@@ -469,19 +544,30 @@ int Hooks::callHookScript (
std::string outputStr;
std::vector <std::string> args;
int status = execute (script, args, inputStr, outputStr);
int status;
// Measure time for each hook if running in debug
if (_debug >= 2)
{
Timer timer_per_hook("Hooks::execute (" + script + ")");
timer_per_hook.start();
status = execute (script, args, inputStr, outputStr);
}
else
status = execute (script, args, inputStr, outputStr);
split (output, outputStr, '\n');
if (_debug >= 2)
{
context.debug ("Hooks: output");
context.debug ("Hook: output");
std::vector <std::string>::iterator i;
for (i = output.begin (); i != output.end (); ++i)
if (*i != "")
context.debug (" " + *i);
context.debug (format ("Hooks: Completed with status {1}", status));
context.debug (format ("Hook: Completed with status {1}", status));
context.debug (" "); // Blank line
}

View File

@@ -44,14 +44,19 @@ public:
void onLaunch ();
void onExit ();
void onAdd (std::vector <Task>&);
void onModify (const Task&, std::vector <Task>&);
void onAdd (Task&);
void onModify (const Task&, Task&);
std::vector <std::string> list ();
private:
std::vector <std::string> scripts (const std::string&);
void separateOutput (const std::vector <std::string>&, std::vector <std::string>&, std::vector <std::string>&) const;
bool isJSON (const std::string&) const;
void assertValidJSON (const std::vector <std::string>&) const;
void assertNTasks (const std::vector <std::string>&, int) const;
void assertSameTask (const std::vector <std::string>&, const Task&) const;
void assertFeedback (const std::vector <std::string>&) const;
int callHookScript (const std::string&, const std::vector <std::string>&, std::vector <std::string>&);
private:

View File

@@ -702,7 +702,7 @@ void ISO8601d::resolve ()
t.tm_min = (seconds % 3600) / 60;
t.tm_sec = seconds % 60;
_value = utc ? timegm (&t) : timelocal (&t);
_value = utc ? timegm (&t) : mktime (&t);
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -34,6 +34,7 @@
#include <i18n.h>
std::string Lexer::dateFormat = "";
bool Lexer::isoEnabled = true;
////////////////////////////////////////////////////////////////////////////////
Lexer::Lexer (const std::string& input)
@@ -386,6 +387,12 @@ bool Lexer::token (std::string& result, Type& type)
result += utf8_character (_n0);
shift ();
}
else
{
result += utf8_character (hex_to_int (_n0, _n1, _n2, _n3));
shift ();
type = quote ? typeString : typeIdentifier;
}
break;
case typeExponent:
@@ -732,15 +739,18 @@ void Lexer::dequote (std::string& input)
bool Lexer::is_date (std::string& result)
{
// Try an ISO date parse.
std::string::size_type iso_i = 0;
std::string iso_result;
ISO8601d iso;
iso.ambiguity (_ambiguity);
if (iso.parse (_input.substr (_shift_counter), iso_i))
if (isoEnabled)
{
result = _input.substr (_shift_counter, iso_i);
while (iso_i--) shift ();
return true;
std::string::size_type iso_i = 0;
std::string iso_result;
ISO8601d iso;
iso.ambiguity (_ambiguity);
if (iso.parse (_input.substr (_shift_counter), iso_i))
{
result = _input.substr (_shift_counter, iso_i);
while (iso_i--) shift ();
return true;
}
}
// Try a legacy rc.dateformat parse here.

View File

@@ -34,6 +34,7 @@ class Lexer
{
public:
static std::string dateFormat;
static bool isoEnabled;
enum Type
{

View File

@@ -403,33 +403,6 @@ bool Nibbler::getInt (int& result)
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::getHex (int& result)
{
std::string::size_type i = _cursor;
if (i < _length)
{
if (_input[i] == '-')
++i;
else if (_input[i] == '+')
++i;
}
// TODO Potential for use of find_first_not_of
while (i < _length && isxdigit (_input[i]))
++i;
if (i > _cursor)
{
result = strtoimax (_input.substr (_cursor, i - _cursor).c_str (), NULL, 16);
_cursor = i;
return true;
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::getUnsignedInt (int& result)
{

View File

@@ -68,7 +68,6 @@ public:
bool getDigit3 (int&);
bool getDigit2 (int&);
bool getInt (int&);
bool getHex (int&);
bool getUnsignedInt (int&);
bool getNumber (std::string&);
bool getNumber (double&);

View File

@@ -567,12 +567,12 @@ void TDB2::add (Task& task, bool add_to_backlog /* = true */)
if (!verifyUniqueUUID (uuid))
throw format (STRING_TDB2_UUID_NOT_UNIQUE, uuid);
// Create a vector tasks, as hooks can cause them to multiply.
std::vector <Task> changes;
changes.push_back (task);
context.hooks.onAdd (changes);
// Only locally-added tasks trigger hooks. This means that tasks introduced
// via 'sync' do not trigger hooks.
if (add_to_backlog)
context.hooks.onAdd (task);
update (uuid, task, add_to_backlog, changes);
update (uuid, task, add_to_backlog, true);
}
////////////////////////////////////////////////////////////////////////////////
@@ -580,19 +580,17 @@ void TDB2::modify (Task& task, bool add_to_backlog /* = true */)
{
// Ensure the task is consistent, and provide defaults if necessary.
task.validate (false);
task.upgradeLegacyValues ();
std::string uuid = task.get ("uuid");
// Get the unmodified task as reference, so the hook can compare.
Task original;
get (uuid, original);
if (add_to_backlog)
{
Task original;
get (uuid, original);
context.hooks.onModify (original, task);
}
// Create a vector tasks, as hooks can cause them to multiply.
std::vector <Task> changes;
changes.push_back (task);
context.hooks.onModify (original, changes);
update (uuid, task, add_to_backlog, changes);
update (uuid, task, add_to_backlog);
}
////////////////////////////////////////////////////////////////////////////////
@@ -600,61 +598,50 @@ void TDB2::update (
const std::string& uuid,
Task& task,
const bool add_to_backlog,
std::vector <Task>& changes)
const bool addition)
{
std::vector <Task>::iterator i;
for (i = changes.begin (); i != changes.end (); ++i)
// Validate to add metadata.
task.validate (false);
// If the task already exists, it is a modification, else addition.
Task original;
if (not addition && get (task.get ("uuid"), original))
{
// Validate to add metadata.
i->validate (false);
// Update the task, wherever it is.
if (!pending.modify_task (task))
completed.modify_task (task);
// If the task already exists, it is a modification, else addition.
Task original;
if (get (i->get ("uuid"), original))
{
// Update the task, wherever it is.
if (!pending.modify_task (*i))
completed.modify_task (*i);
// time <time>
// old <task>
// new <task>
// ---
undo.add_line ("time " + Date ().toEpochString () + "\n");
undo.add_line ("old " + original.composeF4 () + "\n");
undo.add_line ("new " + i->composeF4 () + "\n");
undo.add_line ("---\n");
}
else
{
// Re-validate to add default values.
i->validate ();
// Add new task to either pending or completed.
std::string status = i->get ("status");
if (status == "completed" ||
status == "deleted")
completed.add_task (*i);
else
pending.add_task (*i);
// Add undo data lines:
// time <time>
// new <task>
// ---
undo.add_line ("time " + Date ().toEpochString () + "\n");
undo.add_line ("new " + i->composeF4 () + "\n");
undo.add_line ("---\n");
}
// Add task to backlog.
if (add_to_backlog)
backlog.add_line (i->composeJSON () + "\n");
// The original task may be further referenced by the caller.
if (i->get ("uuid") == uuid)
task = *i;
// time <time>
// old <task>
// new <task>
// ---
undo.add_line ("time " + Date ().toEpochString () + "\n");
undo.add_line ("old " + original.composeF4 () + "\n");
undo.add_line ("new " + task.composeF4 () + "\n");
undo.add_line ("---\n");
}
else
{
// Add new task to either pending or completed.
std::string status = task.get ("status");
if (status == "completed" ||
status == "deleted")
completed.add_task (task);
else
pending.add_task (task);
// Add undo data lines:
// time <time>
// new <task>
// ---
undo.add_line ("time " + Date ().toEpochString () + "\n");
undo.add_line ("new " + task.composeF4 () + "\n");
undo.add_line ("---\n");
}
// Add task to backlog.
if (add_to_backlog)
backlog.add_line (task.composeJSON () + "\n");
}
////////////////////////////////////////////////////////////////////////////////
@@ -979,6 +966,9 @@ void TDB2::show_diff (
view.add (Column::factory ("string", STRING_TDB2_UNDO_PRIOR));
view.add (Column::factory ("string", STRING_TDB2_UNDO_CURRENT));
Color label (context.config.get ("color.label"));
view.colorHeader (label);
Task after (current);
if (prior != "")
@@ -1189,18 +1179,21 @@ int TDB2::gc ()
// Allowed as an override, but not recommended.
if (context.config.getBoolean ("gc"))
{
std::vector <Task> pending_tasks = pending.get_tasks ();
std::vector <Task> pending_tasks = pending.get_tasks ();
// TODO Thread.
std::vector <Task> completed_tasks = completed.get_tasks ();
// TODO Assume pending < completed, therefore there is room here to process
// data before joining with the completed.data thread.
bool pending_changes = false;
bool completed_changes = false;
std::vector <Task> pending_tasks_after;
std::vector <Task> completed_tasks_after;
// Reduce unnecessary allocation/copies.
pending_tasks_after.reserve (pending_tasks.size ());
completed_tasks_after.reserve (completed_tasks.size ());
// Scan all pending tasks, looking for any that need to be relocated to
// completed, or need to be 'woken'.
@@ -1237,6 +1230,11 @@ int TDB2::gc ()
}
}
// TODO Join completed.data thread.
// Reduce unnecessary allocation/copies.
completed_tasks_after.reserve (completed_tasks.size ());
// Scan all completed tasks, looking for any that need to be relocated to
// pending.
for (task = completed_tasks.begin ();

View File

@@ -128,7 +128,7 @@ public:
private:
void gather_changes ();
void update (const std::string&, Task&, const bool, std::vector <Task>&);
void update (const std::string&, Task&, const bool, const bool addition = false);
bool verifyUniqueUUID (const std::string&);
void show_diff (const std::string&, const std::string&, const std::string&);
void revert_undo (std::vector <std::string>&, std::string&, std::string&, std::string&, std::string&);

View File

@@ -565,7 +565,6 @@ void Task::parse (const std::string& input)
nl.getQuoted ('"', value))
{
legacyAttributeMap (name);
legacyValueMap (name, value);
if (name.substr (0, 11) == "annotation_")
++annotation_count;
@@ -586,8 +585,6 @@ void Task::parse (const std::string& input)
parseJSON (copy);
else
throw std::string (STRING_RECORD_NOT_FF4);
upgradeLegacyValues ();
}
catch (const std::string&)
@@ -636,8 +633,9 @@ void Task::parseJSON (const std::string& line)
// Dates are converted from ISO to epoch.
else if (type == "date")
{
Date d (unquoteText (i->second->dump ()));
set (i->first, d.toEpochString ());
std::string text = unquoteText (i->second->dump ());
Date d (text);
set (i->first, text == "" ? "" : d.toEpochString ());
}
// Tags are an array of JSON strings.
@@ -718,8 +716,6 @@ void Task::parseJSON (const std::string& line)
}
}
}
upgradeLegacyValues ();
}
}
@@ -804,6 +800,10 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
if (i->first.substr (0, 11) == "annotation_")
continue;
// If value is an empty string, do not ever output it
if (i->second == "")
continue;
if (attributes_written)
out << ",";
@@ -815,16 +815,22 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
if (type == "date")
{
Date d (i->second);
if (i->first == "modification")
out << "\"modified\":\""
<< d.toISO ()
<< "\"";
else
out << "\""
<< i->first
<< "\":\""
<< d.toISO ()
<< "\"";
out << "\""
<< (i->first == "modification" ? "modified" : i->first)
<< "\":\""
// Date was deleted, do not export parsed empty string
<< (i->second == "" ? "" : d.toISO ())
<< "\"";
++attributes_written;
}
else if (type == "numeric")
{
out << "\""
<< i->first
<< "\":"
<< i->second;
++attributes_written;
}
@@ -847,6 +853,8 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
}
out << "]";
++attributes_written;
}
// Everything else is a quoted value.
@@ -894,9 +902,8 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
// Include urgency.
if (decorate)
out << ","
<< "\"urgency\":\""
<< urgency_c ()
<<"\"";
<< "\"urgency\":"
<< urgency_c ();
#endif
out << "}";
@@ -1093,6 +1100,7 @@ int Task::getTagCount () const
bool Task::hasTag (const std::string& tag) const
{
// Synthetic tags - dynamically generated, but do not occupy storage space.
// Note: This list must match that in CmdInfo::execute.
if (tag == "BLOCKED") return is_blocked;
if (tag == "UNBLOCKED") return !is_blocked;
if (tag == "BLOCKING") return is_blocking;
@@ -1112,10 +1120,10 @@ bool Task::hasTag (const std::string& tag) const
if (tag == "SCHEDULED") return has ("scheduled");
if (tag == "CHILD") return has ("parent");
if (tag == "UNTIL") return has ("until");
if (tag == "WAITING") return has ("wait");
if (tag == "ANNOTATED") return hasAnnotations ();
if (tag == "TAGGED") return has ("tags");
if (tag == "PARENT") return has ("mask");
if (tag == "WAITING") return get ("status") == "waiting";
if (tag == "PENDING") return get ("status") == "pending";
if (tag == "COMPLETED") return get ("status") == "completed";
if (tag == "DELETED") return get ("status") == "deleted";
@@ -2068,9 +2076,6 @@ void Task::modify (modType type, bool text_required /* = false */)
if (v.type () == Variant::type_string)
throw format (STRING_UDA_NUMERIC, v.get_string ());
v.cast (Variant::type_real);
v.cast (Variant::type_string);
set (name, v);
++modCount;
}
@@ -2209,78 +2214,3 @@ void Task::modify (modType type, bool text_required /* = false */)
}
////////////////////////////////////////////////////////////////////////////////
void Task::upgradeLegacyValues ()
{
// 2.4.0 Update recurrence values.
if (has ("recur"))
{
std::string value = get ("recur");
if (value != "")
{
std::string new_value = value;
upgradeLegacyValue (new_value);
if (new_value != value)
{
set ("recur", new_value);
context.debug (format ("Legacy upgrade: recur {1} --> {2}", value, new_value));
}
}
}
// 2.4.0 Update UDA duration values.
Config::const_iterator name;
for (name = context.config.begin (); name != context.config.end (); ++name)
{
if (name->first.substr (0, 4) == "uda." &&
name->first.find (".type") != std::string::npos)
{
if (name->second == "duration")
{
std::string::size_type period = name->first.find ('.', 4);
if (period != std::string::npos)
{
std::string uda = name->first.substr (4, period - 4);
std::string value = get (uda);
std::string new_value = value;
upgradeLegacyValue (new_value);
if (new_value != value)
{
set ("recur", new_value);
context.debug (format ("Legacy upgrade: UDA {1}, {2} --> {3}", uda, value, new_value));
}
}
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
void Task::upgradeLegacyValue (std::string& value)
{
std::string::size_type len = value.length ();
std::string::size_type p;
if (value == "-") value = "0s";
else if ((p = value.find ("hr")) != std::string::npos && p == len - 2) value = value.substr (0, p) + "h";
else if ((p = value.find ("hrs")) != std::string::npos && p == len - 3) value = value.substr (0, p) + "h";
else if ((p = value.find ("mins")) != std::string::npos && p == len - 4) value = value.substr (0, p) + "min";
else if ((p = value.find ("mnths")) != std::string::npos && p == len - 5) value = value.substr (0, p) + "mo";
else if ((p = value.find ("mos")) != std::string::npos && p == len - 3) value = value.substr (0, p) + "mo";
else if ((p = value.find ("mth")) != std::string::npos && p == len - 3) value = value.substr (0, p) + "mo";
else if ((p = value.find ("mths")) != std::string::npos && p == len - 4) value = value.substr (0, p) + "mo";
else if ((p = value.find ("qrtrs")) != std::string::npos && p == len - 5) value = value.substr (0, p) + "q";
else if ((p = value.find ("qtr")) != std::string::npos && p == len - 3) value = value.substr (0, p) + "q";
else if ((p = value.find ("qtrs")) != std::string::npos && p == len - 4) value = value.substr (0, p) + "q";
else if ((p = value.find ("sec")) != std::string::npos && p == len - 3) value = value.substr (0, p) + "s";
else if ((p = value.find ("secs")) != std::string::npos && p == len - 4) value = value.substr (0, p) + "s";
else if ((p = value.find ("wk")) != std::string::npos && p == len - 2) value = value.substr (0, p) + "w";
else if ((p = value.find ("wks")) != std::string::npos && p == len - 3) value = value.substr (0, p) + "w";
else if ((p = value.find ("yr")) != std::string::npos && p == len - 2) value = value.substr (0, p) + "y";
else if ((p = value.find ("yrs")) != std::string::npos && p == len - 3) value = value.substr (0, p) + "y";
// It is not an error to have a non-legacy value.
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -154,7 +154,6 @@ public:
enum modType {modReplace, modPrepend, modAppend, modAnnotate};
void modify (modType, bool text_required = false);
void upgradeLegacyValues ();
private:
int determineVersion (const std::string&);
@@ -163,7 +162,6 @@ private:
void validate_before (const std::string&, const std::string&);
const std::string encode (const std::string&) const;
const std::string decode (const std::string&) const;
void upgradeLegacyValue (std::string&);
public:
float urgency_priority () const;

View File

@@ -41,6 +41,7 @@
std::string Variant::dateFormat = "";
bool Variant::searchCaseSensitive = true;
bool Variant::searchUsingRegex = true;
bool Variant::isoEnabled = true;
////////////////////////////////////////////////////////////////////////////////
Variant::Variant ()
@@ -2065,7 +2066,8 @@ void Variant::cast (const enum type new_type)
ISO8601d iso;
std::string::size_type pos = 0;
if (iso.parse (_string, pos) &&
if (isoEnabled &&
iso.parse (_string, pos) &&
pos == _string.length ())
{
_date = (time_t) iso;

View File

@@ -37,6 +37,7 @@ public:
static std::string dateFormat;
static bool searchCaseSensitive;
static bool searchUsingRegex;
static bool isoEnabled;
enum type {type_unknown, type_boolean, type_integer, type_real, type_string,
type_date, type_duration};

View File

@@ -57,7 +57,7 @@ int main (int argc, char** argv)
try
{
bool infix = true;
bool ambiguous = true;
bool ambiguous = false;
// Add a source for constants.
Eval e;
@@ -77,8 +77,8 @@ int main (int argc, char** argv)
<< " -d|--debug Debug mode\n"
<< " -i|--infix Infix expression (default)\n"
<< " -p|--postfix Postfix expression\n"
<< " -a|--ambiguous Choose dates over numbers when ambiguous (default)\n"
<< " -n|--noambiguous Choose numbers over dates when ambiguous\n"
<< " -a|--ambiguous Choose dates over numbers when ambiguous\n"
<< " -n|--noambiguous Choose numbers over dates when ambiguous (default)\n"
<< "\n";
exit (1);
}

View File

@@ -207,8 +207,6 @@ void ColumnDate::render (
color.colorize (
rightJustify (
Duration (date - now).format (), width)));
else
lines.push_back (rightJustify ("", width));
}
}
}

View File

@@ -37,7 +37,7 @@ class ColumnDate : public Column
{
public:
ColumnDate ();
~ColumnDate ();
virtual ~ColumnDate ();
virtual bool validate (std::string&);
virtual void measure (Task&, unsigned int&, unsigned int&);

View File

@@ -62,11 +62,16 @@ bool ColumnIMask::validate (std::string& value)
// Set the minimum and maximum widths for the value.
void ColumnIMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = task.get ("imask").length ();
minimum = maximum = 0;
if (_style != "default" &&
_style != "number")
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
if (task.has (_name))
{
minimum = maximum = task.get ("imask").length ();
if (_style != "default" &&
_style != "number")
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -76,7 +81,8 @@ void ColumnIMask::render (
int width,
Color& color)
{
lines.push_back (color.colorize (rightJustify (task.get ("imask"), width)));
if (task.has (_name))
lines.push_back (color.colorize (rightJustify (task.get ("imask"), width)));
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -62,10 +62,14 @@ bool ColumnMask::validate (std::string& value)
// Set the minimum and maximum widths for the value.
void ColumnMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = task.get ("mask").length ();
minimum = maximum = 0;
if (task.has (_name))
{
minimum = maximum = task.get ("mask").length ();
if (_style != "default")
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
if (_style != "default")
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -75,7 +79,8 @@ void ColumnMask::render (
int width,
Color& color)
{
lines.push_back (color.colorize (task.get ("mask")));
if (task.has (_name))
lines.push_back (color.colorize (task.get ("mask")));
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -62,12 +62,17 @@ bool ColumnParent::validate (std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnParent::measure (Task&, unsigned int& minimum, unsigned int& maximum)
void ColumnParent::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
if (_style == "default" || _style == "long") minimum = maximum = 36;
else if (_style == "short") minimum = maximum = 8;
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
minimum = maximum = 0;
if (task.has (_name))
{
if (_style == "default" || _style == "long") minimum = maximum = 36;
else if (_style == "short") minimum = maximum = 8;
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -77,20 +82,23 @@ void ColumnParent::render (
int width,
Color& color)
{
// f30cb9c3-3fc0-483f-bfb2-3bf134f00694 default
// 34f00694 short
if (_style == "default" ||
_style == "long")
if (task.has (_name))
{
lines.push_back (color.colorize (leftJustify (task.get (_name), width)));
}
// f30cb9c3-3fc0-483f-bfb2-3bf134f00694 default
// 34f00694 short
if (_style == "default" ||
_style == "long")
{
lines.push_back (color.colorize (leftJustify (task.get (_name), width)));
}
else if (_style == "short")
{
if (task.has (_name))
lines.push_back (color.colorize (leftJustify (task.get (_name).substr (28), width)));
else
lines.push_back (color.colorize (leftJustify ("", width)));
else if (_style == "short")
{
if (task.has (_name))
lines.push_back (color.colorize (leftJustify (task.get (_name).substr (28), width)));
else
lines.push_back (color.colorize (leftJustify ("", width)));
}
}
}

View File

@@ -53,17 +53,14 @@ ColumnPriority::~ColumnPriority ()
}
////////////////////////////////////////////////////////////////////////////////
// Allow lower case, but implicitly convert.
bool ColumnPriority::validate (std::string& value)
{
value = upperCase (value);
if (value == "h") { value = "H"; return true; }
else if (value == "m") { value = "M"; return true; }
else if (value == "l") { value = "L"; return true; }
if (value == "H" ||
value == "M" ||
value == "L" ||
value == "")
return true;
return false;
return value == "H" || value == "M" || value == "L" || value == "";
}
////////////////////////////////////////////////////////////////////////////////
@@ -81,22 +78,26 @@ void ColumnPriority::setStyle (const std::string& value)
// Set the minimum and maximum widths for the value.
void ColumnPriority::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
std::string priority = task.get (_name);
if (priority == "")
minimum = maximum = 0;
else
minimum = maximum = 1;
if (_style == "long")
minimum = maximum = 0;
if (task.has (_name))
{
if (priority == "H") minimum = maximum = 4;
else if (priority == "M") minimum = maximum = 6;
else if (priority == "L") minimum = maximum = 3;
std::string priority = task.get (_name);
if (priority == "")
minimum = maximum = 0;
else
minimum = maximum = 1;
if (_style == "long")
{
if (priority == "H") minimum = maximum = 4;
else if (priority == "M") minimum = maximum = 6;
else if (priority == "L") minimum = maximum = 3;
}
else if (_style != "default" &&
_style != "short")
throw format (STRING_COLUMN_BAD_FORMAT, "priority", _style);
}
else if (_style != "default" &&
_style != "short")
throw format (STRING_COLUMN_BAD_FORMAT, "priority", _style);
}
////////////////////////////////////////////////////////////////////////////////
@@ -106,21 +107,28 @@ void ColumnPriority::render (
int width,
Color& color)
{
std::string priority = task.get (_name);
if (_style == "long")
if (task.has (_name))
{
if (priority == "H") priority = "High";
else if (priority == "M") priority = "Medium";
else if (priority == "L") priority = "Low";
}
std::string priority = task.get (_name);
if (_style == "long")
{
if (priority == "H") priority = "High";
else if (priority == "M") priority = "Medium";
else if (priority == "L") priority = "Low";
}
lines.push_back (color.colorize (leftJustify (priority, width)));
lines.push_back (color.colorize (leftJustify (priority, width)));
}
}
////////////////////////////////////////////////////////////////////////////////
std::string ColumnPriority::modify (std::string& value)
{
return upperCase (value);
if (value == "h") value = "H";
else if (value == "m") value = "M";
else if (value == "l") value = "L";
return value;
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -68,25 +68,30 @@ bool ColumnProject::validate (std::string& value)
// Set the minimum and maximum widths for the value.
void ColumnProject::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
std::string project = task.get (_name);
minimum = maximum = 0;
if (_style == "parent")
if (task.has (_name))
{
std::string::size_type period = project.find ('.');
if (period != std::string::npos)
project = project.substr (0, period);
}
else if (_style == "indented")
{
project = indentProject (project, " ", '.');
}
else if (_style != "default" &&
_style != "full" &&
_style != "indented")
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
std::string project = task.get (_name);
minimum = longestWord (project);
maximum = utf8_width (project);
if (_style == "parent")
{
std::string::size_type period = project.find ('.');
if (period != std::string::npos)
project = project.substr (0, period);
}
else if (_style == "indented")
{
project = indentProject (project, " ", '.');
}
else if (_style != "default" &&
_style != "full" &&
_style != "indented")
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
minimum = longestWord (project);
maximum = utf8_width (project);
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -96,24 +101,27 @@ void ColumnProject::render (
int width,
Color& color)
{
std::string project = task.get (_name);
if (_style == "parent")
if (task.has (_name))
{
std::string::size_type period = project.find ('.');
if (period != std::string::npos)
project = project.substr (0, period);
}
else if (_style == "indented")
{
project = indentProject (project, " ", '.');
}
std::string project = task.get (_name);
if (_style == "parent")
{
std::string::size_type period = project.find ('.');
if (period != std::string::npos)
project = project.substr (0, period);
}
else if (_style == "indented")
{
project = indentProject (project, " ", '.');
}
std::vector <std::string> raw;
wrapText (raw, project, width, _hyphenate);
std::vector <std::string> raw;
wrapText (raw, project, width, _hyphenate);
std::vector <std::string>::iterator i;
for (i = raw.begin (); i != raw.end (); ++i)
lines.push_back (color.colorize (leftJustify (*i, width)));
std::vector <std::string>::iterator i;
for (i = raw.begin (); i != raw.end (); ++i)
lines.push_back (color.colorize (leftJustify (*i, width)));
}
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -79,18 +79,23 @@ void ColumnRecur::setStyle (const std::string& value)
// Set the minimum and maximum widths for the value.
void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
if (_style == "default" ||
_style == "duration")
minimum = maximum = 0;
if (task.has (_name))
{
minimum = maximum = Duration (task.get ("recur")).formatISO ().length ();
if (_style == "default" ||
_style == "duration")
{
minimum = maximum = Duration (task.get ("recur")).formatISO ().length ();
}
else if (_style == "indicator")
{
if (task.has (_name))
minimum = maximum = utf8_width (context.config.get ("recurrence.indicator"));
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
else if (_style == "indicator")
{
if (task.has (_name))
minimum = maximum = utf8_width (context.config.get ("recurrence.indicator"));
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
////////////////////////////////////////////////////////////////////////////////
@@ -108,8 +113,7 @@ void ColumnRecur::render (
lines.push_back (
color.colorize (
rightJustify (
Duration (task.get ("recur")).formatISO (),
width)));
Duration (task.get ("recur")).formatISO (), width)));
}
else if (_style == "indicator")
{

View File

@@ -71,6 +71,8 @@ void ColumnString::setReport (const std::string& value)
//
void ColumnString::measure (const std::string& value, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;
if (_style == "left" ||
_style == "right" ||
_style == "default")

View File

@@ -84,30 +84,34 @@ void ColumnTags::setStyle (const std::string& value)
// Set the minimum and maximum widths for the value.
void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
if (_style == "indicator") minimum = maximum = utf8_width (context.config.get ("tag.indicator"));
else if (_style == "count") minimum = maximum = 3;
else if (_style == "default" ||
_style == "list")
{
std::string tags = task.get (_name);
minimum = 0;
maximum = utf8_width (tags);
minimum = maximum = 0;
if (maximum)
if (task.has (_name))
{
if (_style == "indicator") minimum = maximum = utf8_width (context.config.get ("tag.indicator"));
else if (_style == "count") minimum = maximum = 3;
else if (_style == "default" ||
_style == "list")
{
std::vector <std::string> all;
split (all, tags, ',');
std::vector <std::string>::iterator i;
for (i = all.begin (); i != all.end (); ++i)
std::string tags = task.get (_name);
maximum = utf8_width (tags);
if (maximum)
{
unsigned int length = utf8_width (*i);
if (length > minimum)
minimum = length;
std::vector <std::string> all;
split (all, tags, ',');
std::vector <std::string>::iterator i;
for (i = all.begin (); i != all.end (); ++i)
{
unsigned int length = utf8_width (*i);
if (length > minimum)
minimum = length;
}
}
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
////////////////////////////////////////////////////////////////////////////////
@@ -117,9 +121,9 @@ void ColumnTags::render (
int width,
Color& color)
{
std::string tags = task.get (_name);
if (tags != "")
if (task.has (_name))
{
std::string tags = task.get (_name);
if (_style == "default" ||
_style == "list")
{

View File

@@ -80,49 +80,52 @@ void ColumnUDA::measure (Task& task, unsigned int& minimum, unsigned int& maximu
{
minimum = maximum = 0;
if (_style == "default")
if (task.has (_name))
{
std::string value = task.get (_name);
if (value != "")
if (_style == "default")
{
if (_type == "date")
std::string value = task.get (_name);
if (value != "")
{
// Determine the output date format, which uses a hierarchy of definitions.
// rc.report.<report>.dateformat
// rc.dateformat.report
// rc.dateformat
Date date ((time_t) strtol (value.c_str (), NULL, 10));
std::string format = context.config.get ("report." + _report + ".dateformat");
if (format == "")
format = context.config.get ("dateformat.report");
if (format == "")
format = context.config.get ("dateformat");
if (_type == "date")
{
// Determine the output date format, which uses a hierarchy of definitions.
// rc.report.<report>.dateformat
// rc.dateformat.report
// rc.dateformat
Date date ((time_t) strtol (value.c_str (), NULL, 10));
std::string format = context.config.get ("report." + _report + ".dateformat");
if (format == "")
format = context.config.get ("dateformat.report");
if (format == "")
format = context.config.get ("dateformat");
minimum = maximum = Date::length (format);
}
else if (_type == "duration")
{
minimum = maximum = utf8_width (Duration (value).formatISO ());
}
else if (_type == "string")
{
std::string stripped = Color::strip (value);
maximum = longestLine (stripped);
minimum = longestWord (stripped);
}
else if (_type == "numeric")
{
minimum = maximum = utf8_width (value);
minimum = maximum = Date::length (format);
}
else if (_type == "duration")
{
minimum = maximum = utf8_width (Duration (value).formatISO ());
}
else if (_type == "string")
{
std::string stripped = Color::strip (value);
maximum = longestLine (stripped);
minimum = longestWord (stripped);
}
else if (_type == "numeric")
{
minimum = maximum = utf8_width (value);
}
}
}
else if (_style == "indicator")
{
if (task.has (_name))
minimum = maximum = utf8_width (context.config.get ("uda." + _name + ".indicator"));
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
else if (_style == "indicator")
{
if (task.has (_name))
minimum = maximum = utf8_width (context.config.get ("uda." + _name + ".indicator"));
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
////////////////////////////////////////////////////////////////////////////////
@@ -132,11 +135,11 @@ void ColumnUDA::render (
int width,
Color& color)
{
if (_style == "default")
if (task.has (_name))
{
std::string value = task.get (_name);
if (value != "")
if (_style == "default")
{
std::string value = task.get (_name);
if (_type == "date")
{
// Determine the output date format, which uses a hierarchy of definitions.
@@ -177,13 +180,13 @@ void ColumnUDA::render (
lines.push_back (color.colorize (rightJustify (value, width)));
}
}
}
else if (_style == "indicator")
{
if (task.has (_name))
lines.push_back (
color.colorize (
rightJustify (context.config.get ("uda." + _name + ".indicator"), width)));
else if (_style == "indicator")
{
if (task.has (_name))
lines.push_back (
color.colorize (
rightJustify (context.config.get ("uda." + _name + ".indicator"), width)));
}
}
}

View File

@@ -18,6 +18,7 @@ set (commands_SRCS Command.cpp Command.h
CmdColor.cpp CmdColor.h
CmdColumns.cpp CmdColumns.h
CmdConfig.cpp CmdConfig.h
CmdContext.cpp CmdContext.h
CmdCount.cpp CmdCount.h
CmdCustom.cpp CmdCustom.h
CmdDelete.cpp CmdDelete.h

View File

@@ -284,6 +284,7 @@ int CmdCalendar::execute (std::string& output)
Color color_weekend (context.config.get ("color.calendar.weekend"));
Color color_holiday (context.config.get ("color.calendar.holiday"));
Color color_weeknumber (context.config.get ("color.calendar.weeknumber"));
Color color_label (context.config.get ("color.label"));
if (context.color () && context.config.getBoolean ("calendar.legend"))
out << "Legend: "
@@ -342,7 +343,6 @@ int CmdCalendar::execute (std::string& output)
executable = executable.substr (0, cal) + PACKAGE;
std::vector <std::string> args;
args.push_back (executable);
args.push_back ("rc:" + context.rc_file._data);
args.push_back ("rc.due:0");
args.push_back ("rc.verbose:label,affected,blank");
@@ -363,6 +363,7 @@ int CmdCalendar::execute (std::string& output)
holTable.width (context.getWidth ());
holTable.add (Column::factory ("string", STRING_CMD_CAL_LABEL_DATE));
holTable.add (Column::factory ("string", STRING_CMD_CAL_LABEL_HOL));
holTable.colorHeader (color_label);
Config::const_iterator it;
std::map <time_t, std::vector<std::string> > hm; // we need to store multiple holidays per day
@@ -426,7 +427,10 @@ std::string CmdCalendar::renderMonths (
throw std::string (STRING_CMD_CAL_SUN_MON);
// Build table for the number of months to be displayed.
Color label (context.config.get ("color.label"));
ViewText view;
view.colorHeader (label);
view.width (context.getWidth ());
for (int i = 0 ; i < (monthsPerLine * 8); i += 8)
{

View File

@@ -70,6 +70,9 @@ int CmdColumns::execute (std::string& output)
formats.add (Column::factory ("string", STRING_COLUMN_LABEL_STYLES));
formats.add (Column::factory ("string", STRING_COLUMN_LABEL_EXAMPLES));
Color label (context.config.get ("color.label"));
formats.colorHeader (label);
Color alternate (context.config.get ("color.alternate"));
formats.colorOdd (alternate);
formats.intraColorOdd (alternate);

View File

@@ -46,6 +46,107 @@ CmdConfig::CmdConfig ()
_displays_id = false;
}
////////////////////////////////////////////////////////////////////////////////
bool CmdConfig::setConfigVariable (std::string name, std::string value, bool confirmation /* = false */)
{
// Read .taskrc (or equivalent)
std::vector <std::string> contents;
File::read (context.config._original_file, contents);
bool found = false;
bool change = false;
std::vector <std::string>::iterator line;
for (line = contents.begin (); line != contents.end (); ++line)
{
// If there is a comment on the line, it must follow the pattern.
std::string::size_type comment = line->find ("#");
std::string::size_type pos = line->find (name + "=");
if (pos != std::string::npos &&
(comment == std::string::npos ||
comment > pos))
{
found = true;
if (!confirmation ||
confirm (format (STRING_CMD_CONFIG_CONFIRM, name, context.config.get (name), value)))
{
if (comment != std::string::npos)
*line = name + "=" + json::encode (value) + " " + line->substr (comment);
else
*line = name + "=" + json::encode (value);
change = true;
}
}
}
// Not found, so append instead.
if (!found &&
(!confirmation ||
confirm (format (STRING_CMD_CONFIG_CONFIRM2, name, value))))
{
contents.push_back (name + "=" + json::encode (value));
change = true;
}
if (change)
File::write (context.config._original_file, contents);
return change;
}
////////////////////////////////////////////////////////////////////////////////
int CmdConfig::unsetConfigVariable (std::string name, bool confirmation /* = false */)
{
// Read .taskrc (or equivalent)
std::vector <std::string> contents;
File::read (context.config._original_file, contents);
bool found = false;
bool change = false;
std::vector <std::string>::iterator line;
for (line = contents.begin (); line != contents.end (); )
{
bool lineDeleted = false;
// If there is a comment on the line, it must follow the pattern.
std::string::size_type comment = line->find ("#");
std::string::size_type pos = line->find (name + "=");
if (pos != std::string::npos &&
(comment == std::string::npos ||
comment > pos))
{
found = true;
// Remove name
if (!confirmation ||
confirm (format (STRING_CMD_CONFIG_CONFIRM3, name)))
{
// vector::erase method returns a valid iterator to the next object
line = contents.erase (line);
lineDeleted = true;
change = true;
}
}
if (! lineDeleted)
line++;
}
if (change)
File::write (context.config._original_file, contents);
if ( change && found )
return 0;
else if ( found )
return 1;
else
return 2;
}
////////////////////////////////////////////////////////////////////////////////
int CmdConfig::execute (std::string& output)
{
@@ -62,10 +163,13 @@ int CmdConfig::execute (std::string& output)
if (words.size ())
{
bool confirmation = context.config.getBoolean ("confirmation");
bool change = false;
bool found = false;
std::string name = words[0];
std::string value = "";
// Join the remaining words into config variable's value
if (words.size () > 1)
{
for (unsigned int i = 1; i < words.size (); ++i)
@@ -81,85 +185,30 @@ int CmdConfig::execute (std::string& output)
{
bool change = false;
// Read .taskrc (or equivalent)
std::vector <std::string> contents;
File::read (context.config._original_file, contents);
// task config name value
// task config name ""
if (words.size () > 1)
{
bool found = false;
std::vector <std::string>::iterator line;
for (line = contents.begin (); line != contents.end (); ++line)
{
// If there is a comment on the line, it must follow the pattern.
std::string::size_type comment = line->find ("#");
std::string::size_type pos = line->find (name + "=");
if (pos != std::string::npos &&
(comment == std::string::npos ||
comment > pos))
{
found = true;
if (!confirmation ||
confirm (format (STRING_CMD_CONFIG_CONFIRM, name, context.config.get (name), value)))
{
if (comment != std::string::npos)
*line = name + "=" + json::encode (value) + " " + line->substr (comment);
else
*line = name + "=" + json::encode (value);
change = true;
}
}
}
// Not found, so append instead.
if (!found &&
(!confirmation ||
confirm (format (STRING_CMD_CONFIG_CONFIRM2, name, value))))
{
contents.push_back (name + "=" + json::encode (value));
change = true;
}
}
change = setConfigVariable(name, value, confirmation);
// task config name
else
{
bool found = false;
std::vector <std::string>::iterator line;
for (line = contents.begin (); line != contents.end (); ++line)
rc = unsetConfigVariable(name, confirmation);
if (rc == 0)
{
// If there is a comment on the line, it must follow the pattern.
std::string::size_type comment = line->find ("#");
std::string::size_type pos = line->find (name + "=");
if (pos != std::string::npos &&
(comment == std::string::npos ||
comment > pos))
{
found = true;
// Remove name
if (!confirmation ||
confirm (format (STRING_CMD_CONFIG_CONFIRM3, name)))
{
*line = "";
change = true;
}
}
change = true;
found = true;
}
else if (rc == 1)
found = true;
if (!found)
throw format (STRING_CMD_CONFIG_NO_ENTRY, name);
}
// Write .taskrc (or equivalent)
// Show feedback depending on whether .taskrc has been rewritten
if (change)
{
File::write (context.config._original_file, contents);
out << format (STRING_CMD_CONFIG_FILE_MOD,
context.config._original_file._data)
<< "\n";

View File

@@ -34,6 +34,8 @@ class CmdConfig : public Command
{
public:
CmdConfig ();
static bool setConfigVariable (std::string name, std::string value, bool confirmation = false);
static int unsetConfigVariable (std::string name, bool confirmation = false);
int execute (std::string&);
};

379
src/commands/CmdContext.cpp Normal file
View File

@@ -0,0 +1,379 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// http://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#include <cmake.h>
#include <Context.h>
#include <Filter.h>
#include <sstream>
#include <algorithm>
#include <i18n.h>
#include <util.h>
#include <text.h>
#include <CmdContext.h>
#include <CmdConfig.h>
extern Context context;
////////////////////////////////////////////////////////////////////////////////
CmdContext::CmdContext ()
{
_keyword = "context";
_usage = "task context [<name> | subcommand]";
_description = STRING_CMD_CONTEXT_USAGE;
_read_only = true;
_displays_id = false;
}
////////////////////////////////////////////////////////////////////////////////
int CmdContext::execute (std::string& output)
{
int rc = 0;
std::stringstream out;
// Get the non-attribute, non-fancy command line arguments.
std::vector <std::string> words = context.cli.getWords ();
if (words.size () > 0)
{
std::string subcommand = words[0];
if (subcommand == "define")
rc = defineContext (words, out);
else if (subcommand == "delete")
rc = deleteContext (words, out);
else if (subcommand == "list")
rc = listContexts (words, out);
else if (subcommand == "none")
rc = unsetContext (words, out);
else if (subcommand == "show")
rc = showContext (words, out);
else
rc = setContext (words, out);
}
output = out.str ();
return rc;
}
////////////////////////////////////////////////////////////////////////////////
// Joins all the words in the specified interval <from, to) to one string,
// which is then returned.
//
// If to is specified as 0 (default value), all the remaining words will be joined.
//
std::string CmdContext::joinWords (std::vector <std::string>& words, unsigned int from, unsigned int to /* = 0 */)
{
std::string value = "";
if (to == 0)
to = words.size();
for (unsigned int i = from; i < to; ++i)
{
if (i > from)
value += " ";
value += words[i];
}
return value;
}
////////////////////////////////////////////////////////////////////////////////
// Returns all user defined contexts.
//
std::vector <std::string> CmdContext::getContexts ()
{
std::vector <std::string> contexts;
Config::const_iterator name;
for (name = context.config.begin (); name != context.config.end (); ++name)
if (name->first.substr (0, 8) == "context.")
contexts.push_back (name->first.substr (8));
return contexts;
}
////////////////////////////////////////////////////////////////////////////////
// Defines a new user-provided context.
// - The context definition is written into .taskrc as a context.<name> variable.
// - Deletion of the context requires confirmation if rc.confirmation=yes.
//
// Returns: 0 if the addition of the config variable was successful, 1 otherwise
//
// Invoked with: task context define <name> <filter>
// Example: task context define home project:Home
//
int CmdContext::defineContext (std::vector <std::string>& words, std::stringstream& out)
{
int rc = 0;
bool confirmation = context.config.getBoolean ("confirmation");
if (words.size () > 2)
{
std::string name = "context." + words[1];
std::string value = joinWords (words, 2);
// Check if the value is a proper filter by filtering current pending.data
Filter filter;
std::vector <Task> filtered;
const std::vector <Task>& pending = context.tdb2.pending.get_tasks ();
try
{
context.cli.addRawFilter ("( " + value + " )");
filter.subset (pending, filtered);
}
catch (std::string exception)
{
throw format (STRING_CMD_CONTEXT_DEF_ABRT2, exception);
}
// Make user explicitly confirm filters that are matching no pending tasks
if (filtered.size () == 0)
if (confirmation &&
! confirm (format (STRING_CMD_CONTEXT_DEF_CONF, value)))
throw std::string (STRING_CMD_CONTEXT_DEF_ABRT);
// Set context definition config variable
bool success = CmdConfig::setConfigVariable (name, value, confirmation);
if (success)
out << format (STRING_CMD_CONTEXT_DEF_SUCC, words[1]) << "\n";
else
{
out << format (STRING_CMD_CONTEXT_DEF_FAIL, words[1]) << "\n";
rc = 1;
}
}
else
{
out << STRING_CMD_CONTEXT_DEF_USAG << "\n";
rc = 1;
}
return rc;
}
////////////////////////////////////////////////////////////////////////////////
// Deletes the specified context.
// - If the deleted context is currently active, unset it.
// - Deletion of the context requires confirmation if rc.confirmation=yes.
//
// Returns: 0 if the removal of the config variable was successful, 1 otherwise
//
// Invoked with: task context delete <name>
// Example: task context delete home
//
int CmdContext::deleteContext (std::vector <std::string>& words, std::stringstream& out)
{
int rc = 0;
if (words.size () > 1)
{
// Delete the specified context
std::string name = "context." + words[1];
bool confirmation = context.config.getBoolean ("confirmation");
rc = CmdConfig::unsetConfigVariable(name, confirmation);
// If the currently set context was deleted, unset it
std::string currentContext = context.config.get ("context");
if (currentContext == words[1])
CmdConfig::unsetConfigVariable("context", false);
// Output feedback
if (rc == 0)
out << format (STRING_CMD_CONTEXT_DEL_SUCC, words[1]) << "\n";
else
out << format (STRING_CMD_CONTEXT_DEL_FAIL, words[1]) << "\n";
}
else
{
out << STRING_CMD_CONTEXT_DEL_USAG << "\n";
rc = 1;
}
return rc;
}
////////////////////////////////////////////////////////////////////////////////
// Render a list of context names and their definitions.
//
// Returns: 0 the resulting list is non-empty, 1 otherwise
//
// Invoked with: task context list
// Example: task context list
//
int CmdContext::listContexts (std::vector <std::string>& words, std::stringstream& out)
{
int rc = 0;
std::vector <std::string> contexts = getContexts();
if (contexts.size ())
{
std::sort (contexts.begin (), contexts.end ());
ViewText view;
view.width (context.getWidth ());
view.add (Column::factory ("string", "Name"));
view.add (Column::factory ("string", "Definition"));
Color label (context.config.get ("color.label"));
view.colorHeader (label);
std::vector <std::string>::iterator userContext;
for (userContext = contexts.begin (); userContext != contexts.end (); ++userContext)
{
std::string definition = context.config.get ("context." + *userContext);
int row = view.addRow ();
view.set (row, 0, *userContext);
view.set (row, 1, definition);
}
out << optionalBlankLine ()
<< view.render ()
<< optionalBlankLine ();
}
else
{
out << STRING_CMD_CONTEXT_LIST_EMPT << "\n";
rc = 1;
}
return rc;
}
////////////////////////////////////////////////////////////////////////////////
// Sets the specified context as currently active.
// - If some other context was active, the value of currently active context
// is replaced, not added.
// - Setting of the context does not require confirmation.
//
// Returns: 0 if the setting of the context was successful, 1 otherwise
//
// Invoked with: task context <name>
// Example: task context home
//
int CmdContext::setContext (std::vector <std::string>& words, std::stringstream& out)
{
int rc = 0;
std::string value = words[0];
std::vector <std::string> contexts = getContexts ();
// Check that the specified context is defined
if (std::find (contexts.begin (), contexts.end (), value) == contexts.end ())
throw format (STRING_CMD_CONTEXT_SET_NFOU, value);
// Set the active context.
// Should always succeed, as we do not require confirmation.
bool success = CmdConfig::setConfigVariable ("context", value, false);
if (success)
out << format (STRING_CMD_CONTEXT_SET_SUCC, value) << "\n";
else
{
out << format (STRING_CMD_CONTEXT_SET_FAIL, value) << "\n";
rc = 1;
}
return rc;
}
////////////////////////////////////////////////////////////////////////////////
// Shows the currently active context.
//
// Returns: Always returns 0.
//
// Invoked with: task context show
// Example: task context show
//
int CmdContext::showContext (std::vector <std::string>& words, std::stringstream& out)
{
std::string currentContext = context.config.get ("context");
if (currentContext == "")
out << STRING_CMD_CONTEXT_SHOW_EMPT << "\n";
else
{
std::string currentFilter = context.config.get ("context." + currentContext);
out << format (STRING_CMD_CONTEXT_SHOW, currentContext, currentFilter) << "\n";
}
return 0;
}
////////////////////////////////////////////////////////////////////////////////
// Unsets the currently active context.
// - Unsetting of the context does not require confirmation.
//
// Returns: 0 if the unsetting of the context was successful, 1 otherwise (also
// returned if no context is currently active)
//
// Invoked with: task context none
// Example: task context none
//
int CmdContext::unsetContext (std::vector <std::string>& words, std::stringstream& out)
{
int rc = 0;
int status = CmdConfig::unsetConfigVariable ("context", false);
if (status == 0)
out << STRING_CMD_CONTEXT_NON_SUCC << "\n";
else
{
out << STRING_CMD_CONTEXT_NON_FAIL << "\n";
rc = 1;
}
return rc;
}
////////////////////////////////////////////////////////////////////////////////
CmdCompletionContext::CmdCompletionContext ()
{
_keyword = "_context";
_usage = "task _context";
_description = STRING_CMD_HCONTEXT_USAGE;
_read_only = true;
_displays_id = false;
}
////////////////////////////////////////////////////////////////////////////////
int CmdCompletionContext::execute (std::string& output)
{
std::vector <std::string> userContexts = CmdContext::getContexts ();
std::vector <std::string>::iterator userContext;
for (userContext = userContexts.begin (); userContext != userContexts.end (); ++userContext)
output += *userContext + "\n";
return 0;
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -24,40 +24,33 @@
//
////////////////////////////////////////////////////////////////////////////////
#include <cmake.h>
#include <iostream>
#include <stdlib.h>
#include <text.h>
#include <test.h>
#ifndef INCLUDED_CMDCONTEXT
#define INCLUDED_CMDCONTEXT
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
#include <string>
#include <Command.h>
class CmdContext : public Command
{
UnitTest t (16);
public:
CmdContext ();
int execute (std::string&);
std::string joinWords (std::vector <std::string>& words, unsigned int from, unsigned int to = 0);
static std::vector <std::string> getContexts ();
int defineContext (std::vector <std::string>& words, std::stringstream& out);
int deleteContext (std::vector <std::string>& words, std::stringstream& out);
int listContexts (std::vector <std::string>& words, std::stringstream& out);
int setContext (std::vector <std::string>& words, std::stringstream& out);
int showContext (std::vector <std::string>& words, std::stringstream& out);
int unsetContext (std::vector <std::string>& words, std::stringstream& out);
};
// Ensure environment has no influence.
unsetenv ("TASKDATA");
unsetenv ("TASKRC");
t.is (mk_wcwidth ('a'), 1, "U+0061 --> 1");
t.is (mk_wcwidth (0x5149), 2, "U+5149 --> 2");
t.is (mk_wcwidth (0x9a8c), 2, "U+9a8c --> 2");
t.is (mk_wcwidth (0x4e70), 2, "U+4e70 --> 2");
t.is (mk_wcwidth (0x94b1), 2, "U+94b1 --> 2");
t.is (mk_wcwidth (0x5305), 2, "U+5305 --> 2");
t.is (mk_wcwidth (0x91cd), 2, "U+91cd --> 2");
t.is (mk_wcwidth (0x65b0), 2, "U+65b0 --> 2");
t.is (mk_wcwidth (0x8bbe), 2, "U+8bbe --> 2");
t.is (mk_wcwidth (0x8ba1), 2, "U+8ba1 --> 2");
t.is (mk_wcwidth (0x5411), 2, "U+5411 --> 2");
t.is (mk_wcwidth (0x4e0a), 2, "U+4e0a --> 2");
t.is (mk_wcwidth (0x4e0b), 2, "U+4e0b --> 2");
t.is (mk_wcwidth (0x7bad), 2, "U+7bad --> 2");
t.is (mk_wcwidth (0x5934), 2, "U+5934 --> 2");
t.is (mk_wcwidth (0xff0c), 2, "U+ff0c --> 2"); // comma
return 0;
}
class CmdCompletionContext : public Command
{
public:
CmdCompletionContext ();
int execute (std::string&);
};
#endif
////////////////////////////////////////////////////////////////////////////////

View File

@@ -82,15 +82,7 @@ int CmdCustom::execute (std::string& output)
validateSortColumns (sortOrder);
// Prepend the argument list with those from the report filter.
std::string lexeme;
Lexer::Type type;
Lexer lex (reportFilter);
lex.ambiguity (false);
while (lex.token (lexeme, type))
context.cli.add (lexeme);
// Reparse after tree change.
context.cli.analyze ();
context.cli.addRawFilter(reportFilter);
// Apply filter.
handleRecurrence ();

View File

@@ -312,7 +312,7 @@ int CmdDiagnostics::execute (std::string& output)
out << bold.colorize (STRING_CMD_DIAG_HOOKS)
<< "\n"
<< " Scripts: "
<< (context.config.getBoolean ("hooks") ? "Enabled" : "Disabled")
<< (context.config.getBoolean ("hooks") ? STRING_CMD_DIAG_HOOK_ENABLE : STRING_CMD_DIAG_HOOK_DISABLE)
<< "\n";
std::vector <std::string> hooks = context.hooks.list ();
@@ -322,15 +322,20 @@ int CmdDiagnostics::execute (std::string& output)
for (h = hooks.begin (); h != hooks.end (); ++h)
{
Path p (*h);
std::string name = p.name ();
out << " "
<< *h
<< (p.executable () ? " (executable)" : " (not executable)")
<< (p.is_link () ? " (symlink)" : "")
<< (p.executable () ? format (" ({1})", STRING_CMD_DIAG_HOOK_EXEC) : format (" ({1})", STRING_CMD_DIAG_HOOK_NO_EXEC))
<< (p.is_link () ? format (" ({1})", STRING_CMD_DIAG_HOOK_SYMLINK) : "")
<< ((name.substr (0, 6) == "on-add" ||
name.substr (0, 9) == "on-modify" ||
name.substr (0, 9) == "on-launch" ||
name.substr (0, 7) == "on-exit") ? "" : format (" ({1})", STRING_CMD_DIAG_HOOK_NAME))
<< "\n";
}
}
else
out << " (none)\n";
out << format (" ({1})\n", STRING_CMD_DIAG_NONE);
out << "\n";

View File

@@ -48,10 +48,13 @@ int CmdExport::execute (std::string& output)
{
int rc = 0;
// Make sure reccurent tasks are generated.
handleRecurrence ();
// Apply filter.
Filter filter;
std::vector <Task> filtered;
filter.subset (filtered);
filter.subset (filtered, false);
// Obey 'limit:N'.
int rows = 0;

View File

@@ -104,6 +104,9 @@ int CmdHistoryMonthly::execute (std::string& output)
view.add (Column::factory ("string.right", STRING_CMD_HISTORY_DEL));
view.add (Column::factory ("string.right", STRING_CMD_HISTORY_NET));
Color label (context.config.get ("color.label"));
view.colorHeader (label);
int totalAdded = 0;
int totalCompleted = 0;
int totalDeleted = 0;
@@ -257,6 +260,9 @@ int CmdHistoryAnnual::execute (std::string& output)
view.add (Column::factory ("string.right", STRING_CMD_HISTORY_DEL));
view.add (Column::factory ("string.right", STRING_CMD_HISTORY_NET));
Color label (context.config.get ("color.label"));
view.colorHeader (label);
int totalAdded = 0;
int totalCompleted = 0;
int totalDeleted = 0;
@@ -411,6 +417,9 @@ int CmdGHistoryMonthly::execute (std::string& output)
Color color_add (context.config.get ("color.history.add"));
Color color_done (context.config.get ("color.history.done"));
Color color_delete (context.config.get ("color.history.delete"));
Color label (context.config.get ("color.label"));
view.colorHeader (label);
// Determine the longest line, and the longest "added" line.
int maxAddedLine = 0;
@@ -603,6 +612,9 @@ int CmdGHistoryAnnual::execute (std::string& output)
Color color_add (context.config.get ("color.history.add"));
Color color_done (context.config.get ("color.history.done"));
Color color_delete (context.config.get ("color.history.delete"));
Color label (context.config.get ("color.label"));
view.colorHeader (label);
// Determine the longest line, and the longest "added" line.
int maxAddedLine = 0;

View File

@@ -32,7 +32,6 @@
#include <Filter.h>
#include <Date.h>
#include <Duration.h>
#include <ViewText.h>
#include <main.h>
#include <text.h>
#include <i18n.h>
@@ -106,6 +105,9 @@ int CmdInfo::execute (std::string& output)
Color alternate (context.config.get ("color.alternate"));
view.colorOdd (alternate);
view.intraColorOdd (alternate);
Color label (context.config.get ("color.label"));
view.colorHeader (label);
}
Date now;
@@ -312,6 +314,40 @@ int CmdInfo::execute (std::string& output)
view.set (row, 1, allTags);
}
// Virtual tags.
{
// Note: This list must match that in Task::hasTag.
std::string virtualTags = "";
if (task->hasTag ("ACTIVE")) virtualTags += "ACTIVE ";
if (task->hasTag ("ANNOTATED")) virtualTags += "ANNOTATED ";
if (task->hasTag ("BLOCKED")) virtualTags += "BLOCKED ";
if (task->hasTag ("BLOCKING")) virtualTags += "BLOCKING ";
if (task->hasTag ("CHILD")) virtualTags += "CHILD ";
if (task->hasTag ("COMPLETED")) virtualTags += "COMPLETED ";
if (task->hasTag ("DELETED")) virtualTags += "DELETED ";
if (task->hasTag ("DUE")) virtualTags += "DUE ";
if (task->hasTag ("DUETODAY")) virtualTags += "DUETODAY ";
if (task->hasTag ("MONTH")) virtualTags += "MONTH ";
if (task->hasTag ("OVERDUE")) virtualTags += "OVERDUE ";
if (task->hasTag ("PARENT")) virtualTags += "PARENT ";
if (task->hasTag ("PENDING")) virtualTags += "PENDING ";
if (task->hasTag ("READY")) virtualTags += "READY ";
if (task->hasTag ("SCHEDULED")) virtualTags += "SCHEDULED ";
if (task->hasTag ("TAGGED")) virtualTags += "TAGGED ";
if (task->hasTag ("TODAY")) virtualTags += "TODAY ";
if (task->hasTag ("TOMORROW")) virtualTags += "TOMORROW ";
if (task->hasTag ("UNBLOCKED")) virtualTags += "UNBLOCKED ";
if (task->hasTag ("UNTIL")) virtualTags += "UNTIL ";
if (task->hasTag ("WAITING")) virtualTags += "WAITING ";
if (task->hasTag ("WEEK")) virtualTags += "WEEK ";
if (task->hasTag ("YEAR")) virtualTags += "YEAR ";
if (task->hasTag ("YESTERDAY")) virtualTags += "YESTERDAY ";
row = view.addRow ();
view.set (row, 0, STRING_CMD_INFO_VIRTUAL_TAGS);
view.set (row, 1, virtualTags);
}
// uuid
row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_UUID);
@@ -321,62 +357,7 @@ int CmdInfo::execute (std::string& output)
// Task::urgency
row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_URGENCY);
std::string urgency =
trimLeft (format (task->urgency (), 4, 4)) + "\n" +
urgencyTerm ("project", task->urgency_project (), Task::urgencyProjectCoefficient) +
urgencyTerm ("priority", task->urgency_priority (), Task::urgencyPriorityCoefficient) +
urgencyTerm ("active", task->urgency_active (), Task::urgencyActiveCoefficient) +
urgencyTerm ("scheduled", task->urgency_scheduled (), Task::urgencyScheduledCoefficient) +
urgencyTerm ("waiting", task->urgency_waiting (), Task::urgencyWaitingCoefficient) +
urgencyTerm ("blocked", task->urgency_blocked (), Task::urgencyBlockedCoefficient) +
urgencyTerm ("blocking", task->urgency_blocking (), Task::urgencyBlockingCoefficient) +
urgencyTerm ("annotations", task->urgency_annotations (), Task::urgencyAnnotationsCoefficient) +
urgencyTerm ("tags", task->urgency_tags (), Task::urgencyTagsCoefficient) +
urgencyTerm ("next", task->urgency_next (), Task::urgencyNextCoefficient) +
urgencyTerm ("due", task->urgency_due (), Task::urgencyDueCoefficient) +
urgencyTerm ("age", task->urgency_age (), Task::urgencyAgeCoefficient);
// Tag, Project- and UDA-specific coefficients.
std::map <std::string, float>::iterator var;
for (var = Task::coefficients.begin (); var != Task::coefficients.end (); ++var)
{
if (var->first.substr (0, 13) == "urgency.user.")
{
// urgency.user.project.<project>.coefficient
std::string::size_type end = std::string::npos;
if (var->first.substr (13, 8) == "project." &&
(end = var->first.find (".coefficient")) != std::string::npos)
{
std::string project = var->first.substr (21, end - 21);
if (task->get ("project").find (project) == 0)
urgency += urgencyTerm ("PROJECT " + project, 1.0, var->second);
}
// urgency.user.tag.<tag>.coefficient
if (var->first.substr (13, 4) == "tag." &&
(end = var->first.find (".coefficient")) != std::string::npos)
{
std::string name = var->first.substr (17, end - 17);
if (task->hasTag (name))
urgency += urgencyTerm ("TAG " + name, 1.0, var->second);
}
}
// urgency.uda.<name>.coefficient
else if (var->first.substr (0, 12) == "urgency.uda.")
{
std::string::size_type end = var->first.find (".coefficient");
if (end != std::string::npos)
{
std::string name = var->first.substr (12, end - 12);
if (task->has (name))
urgency += urgencyTerm ("UDA " + name, 1.0, var->second);
}
}
}
view.set (row, 1, urgency);
view.set (row, 1, format (task->urgency (), 4, 4));
// Show any UDAs
std::vector <std::string> all = task->all ();
@@ -410,6 +391,7 @@ int CmdInfo::execute (std::string& output)
// Show any orphaned UDAs, which are identified by not being represented in
// the context.columns map.
for (att = all.begin (); att != all.end (); ++att)
{
if (att->substr (0, 11) != "annotation_" &&
context.columns.find (*att) == context.columns.end ())
{
@@ -417,8 +399,86 @@ int CmdInfo::execute (std::string& output)
view.set (row, 0, "[" + *att);
view.set (row, 1, task->get (*att) + "]");
}
}
// Create a second table, containing undo log change details.
// Create a second table, containing urgency details.
ViewText urgencyDetails;
if (context.color ())
{
Color alternate (context.config.get ("color.alternate"));
urgencyDetails.colorOdd (alternate);
urgencyDetails.intraColorOdd (alternate);
Color label (context.config.get ("color.label"));
urgencyDetails.colorHeader (label);
}
urgencyDetails.width (context.getWidth ());
urgencyDetails.add (Column::factory ("string", "")); // Attribute
urgencyDetails.add (Column::factory ("string", "")); // Value
urgencyDetails.add (Column::factory ("string", "")); // *
urgencyDetails.add (Column::factory ("string", "")); // Coefficient
urgencyDetails.add (Column::factory ("string", "")); // =
urgencyDetails.add (Column::factory ("string", "")); // Result
urgencyTerm (urgencyDetails, "project", task->urgency_project (), Task::urgencyProjectCoefficient);
urgencyTerm (urgencyDetails, "priority", task->urgency_priority (), Task::urgencyPriorityCoefficient);
urgencyTerm (urgencyDetails, "active", task->urgency_active (), Task::urgencyActiveCoefficient);
urgencyTerm (urgencyDetails, "scheduled", task->urgency_scheduled (), Task::urgencyScheduledCoefficient);
urgencyTerm (urgencyDetails, "waiting", task->urgency_waiting (), Task::urgencyWaitingCoefficient);
urgencyTerm (urgencyDetails, "blocked", task->urgency_blocked (), Task::urgencyBlockedCoefficient);
urgencyTerm (urgencyDetails, "blocking", task->urgency_blocking (), Task::urgencyBlockingCoefficient);
urgencyTerm (urgencyDetails, "annotations", task->urgency_annotations (), Task::urgencyAnnotationsCoefficient);
urgencyTerm (urgencyDetails, "tags", task->urgency_tags (), Task::urgencyTagsCoefficient);
urgencyTerm (urgencyDetails, "next", task->urgency_next (), Task::urgencyNextCoefficient);
urgencyTerm (urgencyDetails, "due", task->urgency_due (), Task::urgencyDueCoefficient);
urgencyTerm (urgencyDetails, "age", task->urgency_age (), Task::urgencyAgeCoefficient);
// Tag, Project- and UDA-specific coefficients.
std::map <std::string, float>::iterator var;
for (var = Task::coefficients.begin (); var != Task::coefficients.end (); ++var)
{
if (var->first.substr (0, 13) == "urgency.user.")
{
// urgency.user.project.<project>.coefficient
std::string::size_type end = std::string::npos;
if (var->first.substr (13, 8) == "project." &&
(end = var->first.find (".coefficient")) != std::string::npos)
{
std::string project = var->first.substr (21, end - 21);
if (task->get ("project").find (project) == 0)
urgencyTerm (urgencyDetails, "PROJECT " + project, 1.0, var->second);
}
// urgency.user.tag.<tag>.coefficient
if (var->first.substr (13, 4) == "tag." &&
(end = var->first.find (".coefficient")) != std::string::npos)
{
std::string name = var->first.substr (17, end - 17);
if (task->hasTag (name))
urgencyTerm (urgencyDetails, "TAG " + name, 1.0, var->second);
}
}
// urgency.uda.<name>.coefficient
else if (var->first.substr (0, 12) == "urgency.uda.")
{
std::string::size_type end = var->first.find (".coefficient");
if (end != std::string::npos)
{
std::string name = var->first.substr (12, end - 12);
if (task->has (name))
urgencyTerm (urgencyDetails, "UDA " + name, 1.0, var->second);
}
}
}
row = urgencyDetails.addRow ();
urgencyDetails.set (row, 5, rightJustify ("------", 6));
row = urgencyDetails.addRow ();
urgencyDetails.set (row, 5, rightJustify (format (task->urgency (), 4, 4), 6));
// Create a third table, containing undo log change details.
ViewText journal;
// If an alternating row color is specified, notify the table.
@@ -427,6 +487,9 @@ int CmdInfo::execute (std::string& output)
Color alternate (context.config.get ("color.alternate"));
journal.colorOdd (alternate);
journal.intraColorOdd (alternate);
Color label (context.config.get ("color.label"));
journal.colorHeader (label);
}
journal.width (context.getWidth ());
@@ -473,6 +536,10 @@ int CmdInfo::execute (std::string& output)
<< view.render ()
<< "\n";
if (urgencyDetails.rows () > 0)
out << urgencyDetails.render ()
<< "\n";
if (journal.rows () > 0)
out << journal.render ()
<< "\n";
@@ -483,24 +550,23 @@ int CmdInfo::execute (std::string& output)
}
////////////////////////////////////////////////////////////////////////////////
std::string CmdInfo::urgencyTerm (
void CmdInfo::urgencyTerm (
ViewText& view,
const std::string& label,
float measure,
float coefficient) const
{
float value = measure * coefficient;
if (fabsf (value) > epsilon)
return std::string (
rightJustify (label, 20) +
" " +
leftJustify (format (measure, 5, 3), 6) +
" * " +
leftJustify (format (coefficient, 4, 2), 4) +
" = " +
leftJustify (format (value, 5, 3), 5) +
"\n");
return "";
if (value != 0.0)
{
int row = view.addRow ();
view.set (row, 0, " " + label);
view.set (row, 1, rightJustify (format (measure, 5, 3), 6));
view.set (row, 2, "+");
view.set (row, 3, rightJustify (format (coefficient, 4, 2), 4));
view.set (row, 4, "=");
view.set (row, 5, rightJustify (format (value, 5, 3), 6));
}
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -29,6 +29,7 @@
#include <string>
#include <Command.h>
#include <ViewText.h>
class CmdInfo : public Command
{
@@ -37,7 +38,7 @@ public:
int execute (std::string&);
private:
std::string urgencyTerm (const std::string&, float, float) const;
void urgencyTerm (ViewText&, const std::string&, float, float) const;
};
#endif

View File

@@ -53,6 +53,9 @@ int CmdProjects::execute (std::string& output)
{
int rc = 0;
// Enforce the garbage collector to show correct task counts
context.tdb2.gc ();
// Get all the tasks.
handleRecurrence ();
std::vector <Task> tasks = context.tdb2.pending.get_tasks ();
@@ -89,8 +92,16 @@ int CmdProjects::execute (std::string& output)
continue;
}
// Increase the count for the project the task belongs to and all
// its super-projects
project = task->get ("project");
unique[project] += 1;
std::vector <std::string> projects = extractParents (project);
projects.push_back (project);
std::vector <std::string>::const_iterator parent;
for (parent = projects.begin (); parent != projects.end (); ++parent)
unique[*parent] += 1;
if (project == "")
no_project = true;
@@ -104,6 +115,9 @@ int CmdProjects::execute (std::string& output)
view.add (Column::factory ("string", STRING_COLUMN_LABEL_PROJECT));
view.add (Column::factory ("string.right", STRING_COLUMN_LABEL_TASKS));
Color label (context.config.get ("color.label"));
view.colorHeader (label);
std::vector <std::string> processed;
std::map <std::string, int>::iterator project;
for (project = unique.begin (); project != unique.end (); ++project)

View File

@@ -85,6 +85,9 @@ int CmdReports::execute (std::string& output)
view.add (Column::factory ("string", STRING_CMD_REPORTS_REPORT));
view.add (Column::factory ("string", STRING_CMD_REPORTS_DESC));
Color label (context.config.get ("color.label"));
view.colorHeader (label);
// If an alternating row color is specified, notify the table.
if (context.color ())
{

View File

@@ -127,6 +127,7 @@ int CmdShow::execute (std::string& output)
" column.padding"
" complete.all.tags"
" confirmation"
" context"
" data.location"
" dateformat"
" dateformat.annotation"
@@ -134,6 +135,7 @@ int CmdShow::execute (std::string& output)
" dateformat.holiday"
" dateformat.info"
" dateformat.report"
" date.iso"
" debug"
" debug.hooks"
" debug.parser"
@@ -171,6 +173,7 @@ int CmdShow::execute (std::string& output)
" monthsperline"
" nag"
" print.empty.columns"
" recurrence"
" recurrence.confirmation"
" recurrence.indicator"
" recurrence.limit"
@@ -228,6 +231,7 @@ int CmdShow::execute (std::string& output)
i->first.substr (0, 14) != "color.project." &&
i->first.substr (0, 10) != "color.tag." &&
i->first.substr (0, 10) != "color.uda." &&
i->first.substr (0, 8) != "context." &&
i->first.substr (0, 8) != "holiday." &&
i->first.substr (0, 7) != "report." &&
i->first.substr (0, 6) != "alias." &&
@@ -260,6 +264,9 @@ int CmdShow::execute (std::string& output)
Color error (context.config.get ("color.error"));
Color warning (context.config.get ("color.warning"));
Color label (context.config.get ("color.label"));
view.colorHeader (label);
bool issue_error = false;
bool issue_warning = false;

View File

@@ -160,6 +160,9 @@ int CmdStats::execute (std::string& output)
view.add (Column::factory ("string", STRING_CMD_STATS_CATEGORY));
view.add (Column::factory ("string", STRING_CMD_STATS_DATA));
Color label (context.config.get ("color.label"));
view.colorHeader (label);
int row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_STAT_PE);
view.set (row, 1, pendingT);

View File

@@ -92,27 +92,34 @@ int CmdSummary::execute (std::string& output)
for (task = filtered.begin (); task != filtered.end (); ++task)
{
std::string project = task->get ("project");
++counter[project];
std::vector <std::string> projects = extractParents (project);
projects.push_back (project);
std::vector <std::string>::const_iterator parent;
for (parent = projects.begin (); parent != projects.end (); ++parent)
++counter[*parent];
if (task->getStatus () == Task::pending ||
task->getStatus () == Task::waiting)
{
++countPending[project];
for (parent = projects.begin (); parent != projects.end (); ++parent)
{
++countPending[*parent];
time_t entry = strtol (task->get ("entry").c_str (), NULL, 10);
if (entry)
sumEntry[project] = sumEntry[project] + (double) (now - entry);
}
time_t entry = strtol (task->get ("entry").c_str (), NULL, 10);
if (entry)
sumEntry[*parent] = sumEntry[*parent] + (double) (now - entry);
}
else if (task->getStatus () == Task::completed)
{
++countCompleted[project];
for (parent = projects.begin (); parent != projects.end (); ++parent)
{
++countCompleted[*parent];
time_t entry = strtol (task->get ("entry").c_str (), NULL, 10);
time_t end = strtol (task->get ("end").c_str (), NULL, 10);
if (entry && end)
sumEntry[project] = sumEntry[project] + (double) (end - entry);
}
time_t entry = strtol (task->get ("entry").c_str (), NULL, 10);
time_t end = strtol (task->get ("end").c_str (), NULL, 10);
if (entry && end)
sumEntry[*parent] = sumEntry[*parent] + (double) (end - entry);
}
}
@@ -127,7 +134,7 @@ int CmdSummary::execute (std::string& output)
Color bar_color (context.config.get ("color.summary.bar"));
Color bg_color (context.config.get ("color.summary.background"));
Color label (context.config.get ("color.label"));
Color label (context.config.get ("color.label"));
view.colorHeader (label);

View File

@@ -96,6 +96,9 @@ int CmdTags::execute (std::string& output)
view.add (Column::factory ("string", STRING_COLUMN_LABEL_TAG));
view.add (Column::factory ("string.right", STRING_COLUMN_LABEL_COUNT));
Color label (context.config.get ("color.label"));
view.colorHeader (label);
Color bold ("bold");
bool special = false;
std::map <std::string, int>::iterator i;

View File

@@ -99,6 +99,9 @@ int CmdTimesheet::execute (std::string& output)
completed.add (Column::factory ("string.right", STRING_COLUMN_LABEL_DUE));
completed.add (Column::factory ("string", STRING_COLUMN_LABEL_DESC));
Color label (context.config.get ("color.label"));
completed.colorHeader (label);
std::vector <Task>::iterator task;
for (task = all.begin (); task != all.end (); ++task)
{
@@ -155,6 +158,7 @@ int CmdTimesheet::execute (std::string& output)
started.add (Column::factory ("string", STRING_COLUMN_LABEL_PROJECT));
started.add (Column::factory ("string.right", STRING_COLUMN_LABEL_DUE));
started.add (Column::factory ("string", STRING_COLUMN_LABEL_DESC));
started.colorHeader (label);
for (task = all.begin (); task != all.end (); ++task)
{

View File

@@ -87,6 +87,9 @@ int CmdUDAs::execute (std::string& output)
view.add (Column::factory ("string", STRING_COLUMN_LABEL_DEFAULT));
view.add (Column::factory ("string", STRING_COLUMN_LABEL_UDACOUNT));
Color label (context.config.get ("color.label"));
view.colorHeader (label);
std::vector <std::string>::iterator uda;
for (uda = udas.begin (); uda != udas.end (); ++uda)
{
@@ -147,6 +150,9 @@ int CmdUDAs::execute (std::string& output)
orphanView.add (Column::factory ("string", STRING_COLUMN_LABEL_ORPHAN));
orphanView.add (Column::factory ("string", STRING_COLUMN_LABEL_UDACOUNT));
Color label (context.config.get ("color.label"));
orphanView.colorHeader (label);
std::map <std::string, int>::iterator o;
for (o = orphans.begin (); o != orphans.end (); ++o)
{

View File

@@ -135,7 +135,10 @@ CmdCompletionVersion::CmdCompletionVersion ()
int CmdCompletionVersion::execute (std::string& output)
{
#ifdef HAVE_COMMIT
output = COMMIT;
output = std::string (VERSION)
+ std::string (" (")
+ std::string (COMMIT)
+ std::string (")");
#else
output = VERSION;
#endif

View File

@@ -46,6 +46,7 @@
#include <CmdColumns.h>
#include <CmdCommands.h>
#include <CmdConfig.h>
#include <CmdContext.h>
#include <CmdCount.h>
#include <CmdCustom.h>
#include <CmdDelete.h>
@@ -109,6 +110,7 @@ void Command::factory (std::map <std::string, Command*>& all)
c = new CmdCompletionColumns (); all[c->keyword ()] = c;
c = new CmdCompletionCommands (); all[c->keyword ()] = c;
c = new CmdCompletionConfig (); all[c->keyword ()] = c;
c = new CmdCompletionContext (); all[c->keyword ()] = c;
c = new CmdCompletionIds (); all[c->keyword ()] = c;
c = new CmdCompletionUDAs (); all[c->keyword ()] = c;
c = new CmdCompletionUuids (); all[c->keyword ()] = c;
@@ -116,6 +118,7 @@ void Command::factory (std::map <std::string, Command*>& all)
c = new CmdCompletionTags (); all[c->keyword ()] = c;
c = new CmdCompletionVersion (); all[c->keyword ()] = c;
c = new CmdConfig (); all[c->keyword ()] = c;
c = new CmdContext (); all[c->keyword ()] = c;
c = new CmdCount (); all[c->keyword ()] = c;
c = new CmdDelete (); all[c->keyword ()] = c;
c = new CmdDenotate (); all[c->keyword ()] = c;
@@ -163,29 +166,27 @@ void Command::factory (std::map <std::string, Command*>& all)
// Instantiate a command object for each custom report.
std::vector <std::string> reports;
Config::const_iterator i;
for (i = context.config.begin (); i != context.config.end (); ++i)
for (auto &i : context.config)
{
if (i->first.substr (0, 7) == "report.")
if (i.first.substr (0, 7) == "report.")
{
std::string report = i->first.substr (7);
std::string report = i.first.substr (7);
std::string::size_type columns = report.find (".columns");
if (columns != std::string::npos)
reports.push_back (report.substr (0, columns));
}
}
std::vector <std::string>::iterator report;
for (report = reports.begin (); report != reports.end (); ++report)
for (auto &report : reports)
{
// Make sure a custom report does not clash with a built-in command.
if (all.find (*report) != all.end ())
throw format (STRING_CMD_CONFLICT, *report);
if (all.find (report) != all.end ())
throw format (STRING_CMD_CONFLICT, report);
c = new CmdCustom (
*report,
"task <filter> " + *report,
context.config.get ("report." + *report + ".description"));
report,
"task <filter> " + report,
context.config.get ("report." + report + ".description"));
all[c->keyword ()] = c;
}

View File

@@ -27,6 +27,7 @@
#include <cmake.h>
#include <sstream>
#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <Context.h>
#include <main.h>
@@ -53,7 +54,7 @@ int Context::getWidth ()
terminal_height == 0)
{
unsigned short buff[4];
if (ioctl (fileno(stdout), TIOCGWINSZ, &buff) != -1)
if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &buff) != -1)
{
terminal_height = buff[0];
terminal_width = buff[1];
@@ -88,7 +89,7 @@ int Context::getHeight ()
terminal_height == 0)
{
unsigned short buff[4];
if (ioctl (fileno(stdout), TIOCGWINSZ, &buff) != -1)
if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &buff) != -1)
{
terminal_height = buff[0];
terminal_width = buff[1];

1032
src/l10n/deu-DEU.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -296,6 +296,7 @@
#define STRING_CMD_INFO_UNTIL "Until"
#define STRING_CMD_INFO_MODIFICATION "Modification"
#define STRING_CMD_INFO_MODIFIED "Last modified"
#define STRING_CMD_INFO_VIRTUAL_TAGS "Virtual tags"
#define STRING_CMD_UNDO_USAGE "Reverts the most recent change to a task"
#define STRING_CMD_UNDO_MODS "The undo command does not allow further task modification."
#define STRING_CMD_STATS_USAGE "Shows task database statistics"
@@ -489,6 +490,8 @@
#define STRING_CMD_SYNC_HANDSHAKE "Handshake failed. {1}"
#define STRING_CMD_SYNC_TRUST_CA "You should either provide a CA certificate or override verification, but not both."
#define STRING_CMD_SYNC_TRUST_OBS "The 'taskd.trust' settings may now only contain a value of 'strict', 'ignore hostname' or 'allow all'."
// STRING_CMD_DIAG_* strings all appear on the 'diag' command output.
#define STRING_CMD_DIAG_USAGE "Platform, build and environment details"
#define STRING_CMD_DIAG_PLATFORM "Platform"
#define STRING_CMD_DIAG_UNKNOWN "<unknown>"
@@ -510,6 +513,13 @@
#define STRING_CMD_DIAG_UUID_NO_DUP "No duplicates found"
#define STRING_CMD_DIAG_NONE "-none-"
#define STRING_CMD_DIAG_HOOKS "Hooks"
#define STRING_CMD_DIAG_HOOK_NAME "unrecognized hook name"
#define STRING_CMD_DIAG_HOOK_SYMLINK "symlink"
#define STRING_CMD_DIAG_HOOK_EXEC "executable"
#define STRING_CMD_DIAG_HOOK_NO_EXEC "not executable"
#define STRING_CMD_DIAG_HOOK_ENABLE "Enabled"
#define STRING_CMD_DIAG_HOOK_DISABLE "Disabled"
#define STRING_CMD_HCOMMANDS_USAGE "Generates a list of all commands, for autocompletion purposes"
#define STRING_CMD_ZSHCOMMANDS_USAGE "Generates a list of all commands, for zsh autocompletion purposes"
#define STRING_CMD_ZSHATTS_USAGE "Generates a list of all attributes, for zsh autocompletion purposes"
@@ -552,6 +562,25 @@
#define STRING_CMD_CONFIG_NO_CHANGE "No changes made."
#define STRING_CMD_CONFIG_NO_NAME "Specify the name of a config variable to modify."
#define STRING_CMD_HCONFIG_USAGE "Lists all supported configuration variables, for completion purposes"
#define STRING_CMD_CONTEXT_USAGE "Set and define contexts (default filters)"
#define STRING_CMD_CONTEXT_DEF_SUCC "Context '{1}' defined."
#define STRING_CMD_CONTEXT_DEF_FAIL "Context '{1}' not defined."
#define STRING_CMD_CONTEXT_DEF_USAG "Both context name and its definition must be provided."
#define STRING_CMD_CONTEXT_DEF_ABRT "Context definiton aborted."
#define STRING_CMD_CONTEXT_DEF_ABRT2 "Filter validation failed: {1}"
#define STRING_CMD_CONTEXT_DEF_CONF "The filter '{1}' matches 0 pending tasks. Do you wish to continue?"
#define STRING_CMD_CONTEXT_DEL_SUCC "Context '{1}' deleted."
#define STRING_CMD_CONTEXT_DEL_FAIL "Context '{1}' not deleted."
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' set. Use 'task context none' to remove."
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
#define STRING_CMD_CONTEXT_NON_SUCC "Context unset."
#define STRING_CMD_CONTEXT_NON_FAIL "Context not unset."
#define STRING_CMD_HCONTEXT_USAGE "Lists all supported contexts, for completion purposes"
#define STRING_CMD_CUSTOM_MISMATCH "There are different numbers of columns and labels for report '{1}'."
#define STRING_CMD_CUSTOM_SHOWN "{1} shown"
#define STRING_CMD_CUSTOM_COUNT "1 task"
@@ -788,6 +817,18 @@
#define STRING_HELPER_PROJECT_REM "({1} of {2} tasks remaining)."
#define STRING_HELPER_PROJECT_REM1 "({1} task remaining)."
// Hooks
#define STRING_HOOK_ERROR_OBJECT "Hook Error: JSON Object '{...}' expected."
#define STRING_HOOK_ERROR_NODESC "Hook Error: JSON Object missing 'description' attribute."
#define STRING_HOOK_ERROR_NOUUID "Hook Error: JSON Object missing 'uuid' attribute."
#define STRING_HOOK_ERROR_SYNTAX "Hook Error: JSON syntax error in: {1}"
#define STRING_HOOK_ERROR_JSON "Hook Error: JSON "
#define STRING_HOOK_ERROR_NOPARSE "Hook Error: JSON failed to parse: "
#define STRING_HOOK_ERROR_BAD_NUM "Hook Error: Expected {1} JSON task(s), found {2}"
#define STRING_HOOK_ERROR_SAME1 "Hook Error: JSON must be for the same task: {1}"
#define STRING_HOOK_ERROR_SAME2 "Hook Error: JSON must be for the same task: {1} != {2}"
#define STRING_HOOK_ERROR_NOFEEDBACK "Hook Error: Expected feedback from a failing hook script."
// JSON
#define STRING_JSON_MISSING_VALUE "Error: missing value after ',' at position {1}"
#define STRING_JSON_MISSING_VALUE2 "Error: missing value at position {1}"
@@ -860,10 +901,6 @@
#define STRING_TDB2_UNDO_SYNCED "Cannot undo change because the task was already synced. Modify the task instead."
#define STRING_TDB2_DIRTY_EXIT "Exiting with unwritten changes to {1}"
// utf8
#define STRING_UTF8_INVALID_CP_REP "Invalid codepoint representation."
#define STRING_UTF8_INVALID_CP "Invalid Unicode codepoint."
// View
#define STRING_VIEW_TOO_SMALL "The report has a minimum width of {1} and does not fit in the available width of {2}."
@@ -970,7 +1007,7 @@
/*
To be included later, before the 'precendence' line.
" + - Addition, subtraction\n" \
" ! Inversion\n" \
" ~ !~ Match, no match\n" \
@@ -990,4 +1027,3 @@
#define STRING_UTIL_BYTES "B"
#endif

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