doing 2.1.16 → 2.1.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.yardoc/checksums +13 -12
  3. data/.yardoc/object_types +0 -0
  4. data/.yardoc/objects/root.dat +0 -0
  5. data/CHANGELOG.md +136 -53
  6. data/Gemfile.lock +11 -11
  7. data/README.md +1 -1
  8. data/Rakefile +10 -4
  9. data/bin/doing +146 -169
  10. data/docs/doc/Array.html +3 -3
  11. data/docs/doc/BooleanTermParser/Clause.html +3 -3
  12. data/docs/doc/BooleanTermParser/Operator.html +3 -3
  13. data/docs/doc/BooleanTermParser/Query.html +3 -3
  14. data/docs/doc/BooleanTermParser/QueryParser.html +3 -3
  15. data/docs/doc/BooleanTermParser/QueryTransformer.html +3 -3
  16. data/docs/doc/BooleanTermParser.html +3 -3
  17. data/docs/doc/Doing/Color.html +8 -4
  18. data/docs/doc/Doing/Completion.html +3 -3
  19. data/docs/doc/Doing/Configuration.html +7 -5
  20. data/docs/doc/Doing/Errors/DoingNoTraceError.html +3 -3
  21. data/docs/doc/Doing/Errors/DoingRuntimeError.html +3 -3
  22. data/docs/doc/Doing/Errors/DoingStandardError.html +3 -3
  23. data/docs/doc/Doing/Errors/EmptyInput.html +3 -3
  24. data/docs/doc/Doing/Errors/NoResults.html +3 -3
  25. data/docs/doc/Doing/Errors/PluginException.html +3 -3
  26. data/docs/doc/Doing/Errors/UserCancelled.html +3 -3
  27. data/docs/doc/Doing/Errors/WrongCommand.html +3 -3
  28. data/docs/doc/Doing/Errors.html +3 -3
  29. data/docs/doc/Doing/Hooks.html +3 -3
  30. data/docs/doc/Doing/Item.html +121 -3
  31. data/docs/doc/Doing/Items.html +3 -3
  32. data/docs/doc/Doing/LogAdapter.html +3 -3
  33. data/docs/doc/Doing/Note.html +3 -3
  34. data/docs/doc/Doing/Pager.html +3 -3
  35. data/docs/doc/Doing/Plugins.html +3 -3
  36. data/docs/doc/Doing/Prompt.html +3 -3
  37. data/docs/doc/Doing/Section.html +3 -3
  38. data/docs/doc/Doing/TemplateString.html +4 -4
  39. data/docs/doc/Doing/Util/Backup.html +3 -3
  40. data/docs/doc/Doing/Util.html +3 -3
  41. data/docs/doc/Doing/WWID.html +66 -8
  42. data/docs/doc/Doing.html +4 -4
  43. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +3 -3
  44. data/docs/doc/GLI/Commands.html +3 -3
  45. data/docs/doc/GLI.html +3 -3
  46. data/docs/doc/Hash.html +3 -3
  47. data/docs/doc/Numeric.html +3 -3
  48. data/docs/doc/PhraseParser/Operator.html +3 -3
  49. data/docs/doc/PhraseParser/PhraseClause.html +3 -3
  50. data/docs/doc/PhraseParser/Query.html +3 -3
  51. data/docs/doc/PhraseParser/QueryParser.html +3 -3
  52. data/docs/doc/PhraseParser/QueryTransformer.html +3 -3
  53. data/docs/doc/PhraseParser/TermClause.html +3 -3
  54. data/docs/doc/PhraseParser.html +3 -3
  55. data/docs/doc/Status.html +3 -3
  56. data/docs/doc/String.html +230 -17
  57. data/docs/doc/Symbol.html +3 -3
  58. data/docs/doc/Time.html +3 -3
  59. data/docs/doc/_index.html +4 -4
  60. data/docs/doc/file.README.html +4 -4
  61. data/docs/doc/frames.html +1 -1
  62. data/docs/doc/index.html +4 -4
  63. data/docs/doc/method_list.html +311 -239
  64. data/docs/doc/top-level-namespace.html +94 -3
  65. data/doing.gemspec +1 -1
  66. data/doing.rdoc +35 -6
  67. data/lib/completion/_doing.zsh +10 -10
  68. data/lib/completion/doing.bash +16 -16
  69. data/lib/completion/doing.fish +97 -15
  70. data/lib/doing/colors.rb +4 -0
  71. data/lib/doing/completion/fish_completion.rb +80 -11
  72. data/lib/doing/configuration.rb +3 -1
  73. data/lib/doing/hash.rb +1 -1
  74. data/lib/doing/item.rb +51 -0
  75. data/lib/doing/items.rb +3 -1
  76. data/lib/doing/log_adapter.rb +2 -2
  77. data/lib/doing/pager.rb +1 -1
  78. data/lib/doing/plugins/export/dayone_export.rb +1 -1
  79. data/lib/doing/plugins/export/markdown_export.rb +1 -1
  80. data/lib/doing/plugins/export/template_export.rb +2 -0
  81. data/lib/doing/prompt.rb +16 -5
  82. data/lib/doing/string.rb +54 -0
  83. data/lib/doing/string_chronify.rb +55 -17
  84. data/lib/doing/types.rb +19 -0
  85. data/lib/doing/version.rb +1 -1
  86. data/lib/doing/wwid.rb +80 -52
  87. data/lib/examples/commands/later.rb +32 -0
  88. data/lib/helpers/threaded_tests.rb +250 -0
  89. metadata +9 -6
@@ -23,28 +23,97 @@ function __fish_doing_using_command
23
23
  and return 0
24
24
  end
25
25
 
26
+ function __fish_doing_cache_timer_expired
27
+ set -l timer __fish_doing_cache_timer_$argv[1]
28
+ if not set -q $timer
29
+ set -g $timer (date '+%s')
30
+ end
31
+
32
+ if test (math (date '+%s') - $$timer) -gt $argv[2]
33
+ set -g $timer (date '+%s')
34
+ return 1
35
+ end
36
+
37
+ return 0
38
+ end
39
+
40
+ function __fish_doing_subcommands
41
+ if not set -q __fish_doing_subcommands_cache
42
+ or __fish_doing_cache_timer_expired subcommands 86400
43
+ set -g -a __fish_doing_subcommands_cache (doing help -c)
44
+ end
45
+ printf '%s
46
+ ' $__fish_doing_subcommands_cache
47
+ end
48
+
26
49
  function __fish_doing_complete_sections
27
- doing sections -c
50
+ if not set -q __fish_doing_sections_cache
51
+ or __fish_doing_cache_timer_expired sections 3600
52
+ set -g -a __fish_doing_sections_cache (doing sections -c)
53
+ end
54
+ printf '%s
55
+ ' $__fish_doing_sections_cache
56
+ __fish_doing_complete_show_tag
28
57
  end
29
58
 
30
59
  function __fish_doing_complete_views
31
- doing views -c
60
+ if not set -q __fish_doing_views_cache
61
+ or __fish_doing_cache_timer_expired views 3600
62
+ set -g -a __fish_doing_views_cache (doing views -c)
63
+ end
64
+ printf '%s
65
+ ' $__fish_doing_views_cache
32
66
  end
33
67
 
34
- function __fish_doing_subcommands
35
- doing help -c
68
+ function __fish_doing_export_plugin
69
+ if not set -q __fish_doing_export_plugin_cache
70
+ or __fish_doing_cache_timer_expired export_plugins 3600
71
+ set -g -a __fish_doing_export_plugin_cache (doing plugins --type export -c)
72
+ end
73
+ printf '%s
74
+ ' $__fish_doing_export_plugin_cache
75
+ end
76
+
77
+ function __fish_doing_import_plugin
78
+ if not set -q __fish_doing_import_plugin_cache
79
+ or __fish_doing_cache_timer_expired import_plugins 3600
80
+ set -g -a __fish_doing_import_plugin_cache (doing plugins --type import -c)
81
+ end
82
+ printf '%s
83
+ ' $__fish_doing_import_plugin_cache
84
+ end
85
+
86
+ function __fish_doing_complete_template
87
+ if not set -q __fish_doing_template_cache
88
+ or __fish_doing_cache_timer_expired template 3600
89
+ set -g -a __fish_doing_template_cache (doing template -c)
90
+ end
91
+ printf '%s
92
+ ' $__fish_doing_template_cache
36
93
  end
37
94
 
38
- function __fish_doing_export_plugins
39
- doing plugins --type export -c
95
+ function __fish_doing_complete_tag
96
+ if not set -q __fish_doing_tag_cache
97
+ or __fish_doing_cache_timer_expired tags 60
98
+ set -g -a __fish_doing_tag_cache (doing tags)
99
+ end
100
+ printf '%s
101
+ ' $__fish_doing_tag_cache
40
102
  end
41
103
 
42
- function __fish_doing_import_plugins
43
- doing plugins --type import -c
104
+ function __fish_doing_complete_show_tag
105
+ if not set -q __fish_doing_tag_cache
106
+ or __fish_doing_cache_timer_expired tags 60
107
+ set -g -a __fish_doing_tag_cache (doing tags)
108
+ end
109
+ printf '@%s
110
+ ' $__fish_doing_tag_cache
44
111
  end
45
112
 
46
- function __fish_doing_complete_templates
47
- doing template -c
113
+ function __fish_doing_complete_args
114
+ for cmd in (doing commands_accepting -c $argv[1])
115
+ complete -x -c doing -l $argv[1] -n "__fish_doing_using_command $cmd" -a "(__fish_doing_complete_$argv[1])"
116
+ end
48
117
  end
49
118
 
50
119
  complete -c doing -f
@@ -57,6 +126,14 @@ complete -f -c doing -s t -l type -x -n '__fish_doing_using_command import' -a '
57
126
 
58
127
  complete -xc doing -n '__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from (doing help -c)' -a "(doing help -c)"
59
128
 
129
+ function __fish_doing_complete_args
130
+ for cmd in (doing commands_accepting -c $argv[1])
131
+ complete -x -c doing -l $argv[1] -n "__fish_doing_using_command $cmd" -a "(__fish_doing_complete_$argv[1])"
132
+ end
133
+ end
134
+
135
+ __fish_doing_complete_args tag
136
+
60
137
  complete -xc doing -n '__fish_doing_needs_command' -a 'add_section' -d Add\ a\ new\ section\ to\ the\ \"doing\"\ file
61
138
  complete -xc doing -n '__fish_doing_needs_command' -a 'again resume' -d Repeat\ last\ entry\ as\ new\ entry
62
139
  complete -xc doing -n '__fish_doing_needs_command' -a 'archive move' -d Move\ entries\ between\ sections
@@ -100,6 +177,7 @@ complete -xc doing -n '__fish_doing_needs_command' -a 'views' -d List\ available
100
177
  complete -xc doing -n '__fish_doing_needs_command' -a 'wiki' -d Output\ a\ tag\ wiki
101
178
  complete -xc doing -n '__fish_doing_needs_command' -a 'yesterday' -d List\ entries\ from\ yesterday
102
179
  complete -c doing -l ask -f -n '__fish_doing_using_command again resume' -d Prompt\ for\ note\ via\ multi-line\ input
180
+ complete -c doing -l started -f -r -n '__fish_doing_using_command again resume' -d Backdate\ start\ date\ by\ interval\ or\ set\ to\ time\ \[4pm\|20m\|2h\|\"yesterday\ noon\"\]
103
181
  complete -c doing -l bool -f -r -n '__fish_doing_using_command again resume' -d Boolean\ used\ to\ combine\ multiple\ tags
104
182
  complete -c doing -l case -f -r -n '__fish_doing_using_command again resume' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
105
183
  complete -c doing -l editor -s e -f -n '__fish_doing_using_command again resume' -d Edit\ duplicated\ entry\ with\ vim\ before\ adding
@@ -159,9 +237,9 @@ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command done did'
159
237
  complete -c doing -l for -f -r -n '__fish_doing_using_command done did' -d Set\ completion\ date\ to\ start\ date\ plus\ interval
160
238
  complete -c doing -l unfinished -s u -f -n '__fish_doing_using_command done did' -d Finish\ last\ entry\ not\ already\ marked\ @done
161
239
  complete -c doing -l archive -s a -f -n '__fish_doing_using_command finish' -d Archive\ entries
162
- complete -c doing -l at -f -r -n '__fish_doing_using_command finish' -d Set\ finish\ date\ to\ specific\ date/time
240
+ complete -c doing -l finished -f -r -n '__fish_doing_using_command finish' -d Set\ finish\ date\ to\ specific\ date/time
163
241
  complete -c doing -l auto -f -n '__fish_doing_using_command finish' -d Auto-generate\ finish\ dates\ from\ next\ entry\'s\ start\ time
164
- complete -c doing -l back -s b -f -r -n '__fish_doing_using_command finish' -d Backdate\ completed\ date\ to\ date\ string\ \[4pm\|20m\|2h\|yesterday\ noon\]
242
+ complete -c doing -l started -f -r -n '__fish_doing_using_command finish' -d Backdate\ completed\ date\ to\ date\ string\ \[4pm\|20m\|2h\|yesterday\ noon\]
165
243
  complete -c doing -l bool -f -r -n '__fish_doing_using_command finish' -d Boolean
166
244
  complete -c doing -l case -f -r -n '__fish_doing_using_command finish' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
167
245
  complete -c doing -l date -f -n '__fish_doing_using_command finish' -d Include\ date
@@ -183,6 +261,7 @@ complete -c doing -l delete -s d -f -n '__fish_doing_using_command grep search'
183
261
  complete -c doing -l duration -f -n '__fish_doing_using_command grep search' -d Show\ elapsed\ time\ on\ entries\ without\ @done\ tag
184
262
  complete -c doing -l editor -s e -f -n '__fish_doing_using_command grep search' -d Edit\ matching\ entries\ with\ vim
185
263
  complete -c doing -l from -f -r -n '__fish_doing_using_command grep search' -d Date\ range\ to\ show
264
+ complete -c doing -l hilite -s h -f -n '__fish_doing_using_command grep search' -d Highlight\ search\ matches\ in\ output
186
265
  complete -c doing -l interactive -s i -f -n '__fish_doing_using_command grep search' -d Display\ an\ interactive\ menu\ of\ results\ to\ perform\ further\ operations
187
266
  complete -c doing -l not -f -n '__fish_doing_using_command grep search' -d Show\ items\ that\ \*don\'t\*\ match\ search\ string
188
267
  complete -c doing -l output -s o -f -r -n '__fish_doing_using_command grep search' -d Output\ to\ export\ format
@@ -213,6 +292,7 @@ complete -c doing -l case -f -r -n '__fish_doing_using_command last' -d Case\ s
213
292
  complete -c doing -l delete -s d -f -n '__fish_doing_using_command last' -d Delete\ the\ last\ entry
214
293
  complete -c doing -l duration -f -n '__fish_doing_using_command last' -d Show\ elapsed\ time\ if\ entry\ is\ not\ tagged\ @done
215
294
  complete -c doing -l editor -s e -f -n '__fish_doing_using_command last' -d Edit\ entry\ with\ vim
295
+ complete -c doing -l hilite -s h -f -n '__fish_doing_using_command last' -d Highlight\ search\ matches\ in\ output
216
296
  complete -c doing -l not -f -n '__fish_doing_using_command last' -d Show\ items\ that\ \*don\'t\*\ match\ search\ string\ or\ tag\ filter
217
297
  complete -c doing -l section -s s -f -r -n '__fish_doing_using_command last' -d Specify\ a\ section
218
298
  complete -c doing -l search -f -r -n '__fish_doing_using_command last' -d Search\ filter
@@ -220,7 +300,7 @@ complete -c doing -l tag -f -r -n '__fish_doing_using_command last' -d Tag\ fil
220
300
  complete -c doing -l val -f -r -n '__fish_doing_using_command last' -d Perform\ a\ tag\ value\ query
221
301
  complete -c doing -l exact -s x -f -n '__fish_doing_using_command last' -d Force\ exact\ search\ string\ matching
222
302
  complete -c doing -l ask -f -n '__fish_doing_using_command later' -d Prompt\ for\ note\ via\ multi-line\ input
223
- complete -c doing -l back -s b -f -r -n '__fish_doing_using_command later' -d Backdate\ start\ time\ to\ date\ string\ \[4pm\|20m\|2h\|yesterday\ noon\]
303
+ complete -c doing -l started -f -r -n '__fish_doing_using_command later' -d Backdate\ start\ time\ to\ date\ string\ \[4pm\|20m\|2h\|yesterday\ noon\]
224
304
  complete -c doing -l editor -s e -f -n '__fish_doing_using_command later' -d Edit\ entry\ with\ vim
225
305
  complete -c doing -l note -s n -f -r -n '__fish_doing_using_command later' -d Note
226
306
  complete -c doing -l bool -f -r -n '__fish_doing_using_command mark flag' -d Boolean
@@ -239,7 +319,7 @@ complete -c doing -l val -f -r -n '__fish_doing_using_command mark flag' -d Per
239
319
  complete -c doing -l exact -s x -f -n '__fish_doing_using_command mark flag' -d Force\ exact\ search\ string\ matching
240
320
  complete -c doing -l archive -s a -f -n '__fish_doing_using_command meanwhile' -d Archive\ previous\ @meanwhile\ entry
241
321
  complete -c doing -l ask -f -n '__fish_doing_using_command meanwhile' -d Prompt\ for\ note\ via\ multi-line\ input
242
- complete -c doing -l back -s b -f -r -n '__fish_doing_using_command meanwhile' -d Backdate\ start\ date\ for\ new\ entry\ to\ date\ string\ \[4pm\|20m\|2h\|yesterday\ noon\]
322
+ complete -c doing -l started -f -r -n '__fish_doing_using_command meanwhile' -d Backdate\ start\ date\ for\ new\ entry\ to\ date\ string\ \[4pm\|20m\|2h\|yesterday\ noon\]
243
323
  complete -c doing -l editor -s e -f -n '__fish_doing_using_command meanwhile' -d Edit\ entry\ with\ vim
244
324
  complete -c doing -l note -s n -f -r -n '__fish_doing_using_command meanwhile' -d Note
245
325
  complete -c doing -l section -s s -f -r -n '__fish_doing_using_command meanwhile' -d Section
@@ -331,6 +411,7 @@ complete -c doing -l count -s c -f -r -n '__fish_doing_using_command show' -d Ma
331
411
  complete -c doing -l case -f -r -n '__fish_doing_using_command show' -d Case\ sensitivity\ for\ search\ string\ matching\ \[\(c\)ase-sensitive
332
412
  complete -c doing -l duration -f -n '__fish_doing_using_command show' -d Show\ elapsed\ time\ on\ entries\ without\ @done\ tag
333
413
  complete -c doing -l from -f -r -n '__fish_doing_using_command show' -d Date\ range\ to\ show
414
+ complete -c doing -l hilite -s h -f -n '__fish_doing_using_command show' -d Highlight\ search\ matches\ in\ output
334
415
  complete -c doing -l interactive -s i -f -n '__fish_doing_using_command show' -d Select\ from\ a\ menu\ of\ matching\ entries\ to\ perform\ additional\ operations
335
416
  complete -c doing -l menu -s m -f -n '__fish_doing_using_command show' -d Select\ section\ or\ tag\ to\ display\ from\ a\ menu
336
417
  complete -c doing -l not -f -n '__fish_doing_using_command show' -d Show\ items\ that\ \*don\'t\*\ match\ search/tag/date\ filters
@@ -408,6 +489,7 @@ complete -c doing -l case -f -r -n '__fish_doing_using_command view' -d Case\ s
408
489
  complete -c doing -l color -f -n '__fish_doing_using_command view' -d Include\ colors\ in\ output
409
490
  complete -c doing -l duration -f -n '__fish_doing_using_command view' -d Show\ elapsed\ time\ on\ entries\ without\ @done\ tag
410
491
  complete -c doing -l from -f -r -n '__fish_doing_using_command view' -d Date\ range\ to\ show
492
+ complete -c doing -l hilite -s h -f -n '__fish_doing_using_command view' -d Highlight\ search\ matches\ in\ output
411
493
  complete -c doing -l interactive -s i -f -n '__fish_doing_using_command view' -d Select\ from\ a\ menu\ of\ matching\ entries\ to\ perform\ additional\ operations
412
494
  complete -c doing -l not -f -n '__fish_doing_using_command view' -d Show\ items\ that\ \*don\'t\*\ match\ search\ string
413
495
  complete -c doing -l output -s o -f -r -n '__fish_doing_using_command view' -d Output\ to\ export\ format
@@ -440,7 +522,7 @@ complete -c doing -l times -s t -f -n '__fish_doing_using_command yesterday' -d
440
522
  complete -c doing -l tag_order -f -r -n '__fish_doing_using_command yesterday' -d Tag\ sort\ direction
441
523
  complete -c doing -l tag_sort -f -r -n '__fish_doing_using_command yesterday' -d Sort\ tags\ by
442
524
  complete -c doing -l totals -f -n '__fish_doing_using_command yesterday' -d Show\ time\ totals\ at\ the\ end\ of\ output
443
- complete -f -c doing -s o -l output -x -n '__fish_doing_using_command grep search on select show since today view yesterday' -a '(__fish_doing_export_plugins)'
525
+ complete -f -c doing -s o -l output -x -n '__fish_doing_using_command grep search on select show since today view yesterday' -a '(__fish_doing_export_plugin)'
444
526
  complete -f -c doing -s b -l bool -x -n '__fish_doing_using_command again resume archive move autotag cancel finish grep search last mark flag note reset begin rotate show tag tags view wiki' -a 'and or not pattern'
445
527
  complete -f -c doing -l case -x -n '__fish_doing_using_command again resume archive move cancel finish grep search import last mark flag note reset begin rotate select show show tag tags tags view' -a 'case-sensitive ignore smart'
446
528
  complete -f -c doing -l tag_sort -x -n '__fish_doing_using_command grep search on recent show since today view yesterday' -a 'name time'
data/lib/doing/colors.rb CHANGED
@@ -24,6 +24,7 @@ module Doing
24
24
  [:yellow, 33],
25
25
  [:blue, 34],
26
26
  [:magenta, 35],
27
+ [:purple, 35],
27
28
  [:cyan, 36],
28
29
  [:white, 37],
29
30
  [:bgblack, 40],
@@ -32,6 +33,7 @@ module Doing
32
33
  [:bgyellow, 43],
33
34
  [:bgblue, 44],
34
35
  [:bgmagenta, 45],
36
+ [:bgpurple, 45],
35
37
  [:bgcyan, 46],
36
38
  [:bgwhite, 47],
37
39
  [:boldblack, 90], # High intensity, aixterm (works in OS X)
@@ -40,6 +42,7 @@ module Doing
40
42
  [:boldyellow, 93],
41
43
  [:boldblue, 94],
42
44
  [:boldmagenta, 95],
45
+ [:boldpurple, 95],
43
46
  [:boldcyan, 96],
44
47
  [:boldwhite, 97],
45
48
  [:boldbgblack, 100], # High intensity background, aixterm (works in OS X)
@@ -48,6 +51,7 @@ module Doing
48
51
  [:boldbgyellow, 103],
49
52
  [:boldbgblue, 104],
50
53
  [:boldbgmagenta, 105],
54
+ [:boldbgpurple, 105],
51
55
  [:boldbgcyan, 106],
52
56
  [:boldbgwhite, 107],
53
57
  [:softpurple, '0;35;40'],
@@ -31,28 +31,89 @@ module Doing
31
31
  and return 0
32
32
  end
33
33
 
34
+ function __fish_doing_cache_timer_expired
35
+ set -l timer __fish_doing_cache_timer_$argv[1]
36
+ if not set -q $timer
37
+ set -g $timer (date '+%s')
38
+ end
39
+
40
+ if test (math (date '+%s') - $$timer) -gt $argv[2]
41
+ set -g $timer (date '+%s')
42
+ return 1
43
+ end
44
+
45
+ return 0
46
+ end
47
+
48
+ function __fish_doing_subcommands
49
+ if not set -q __fish_doing_subcommands_cache
50
+ or __fish_doing_cache_timer_expired subcommands 86400
51
+ set -g -a __fish_doing_subcommands_cache (doing help -c)
52
+ end
53
+ printf '%s\n' $__fish_doing_subcommands_cache
54
+ end
55
+
34
56
  function __fish_doing_complete_sections
35
- doing sections -c
57
+ if not set -q __fish_doing_sections_cache
58
+ or __fish_doing_cache_timer_expired sections 3600
59
+ set -g -a __fish_doing_sections_cache (doing sections -c)
60
+ end
61
+ printf '%s\n' $__fish_doing_sections_cache
62
+ __fish_doing_complete_show_tag
36
63
  end
37
64
 
38
65
  function __fish_doing_complete_views
39
- doing views -c
66
+ if not set -q __fish_doing_views_cache
67
+ or __fish_doing_cache_timer_expired views 3600
68
+ set -g -a __fish_doing_views_cache (doing views -c)
69
+ end
70
+ printf '%s\n' $__fish_doing_views_cache
40
71
  end
41
72
 
42
- function __fish_doing_subcommands
43
- doing help -c
73
+ function __fish_doing_export_plugin
74
+ if not set -q __fish_doing_export_plugin_cache
75
+ or __fish_doing_cache_timer_expired export_plugins 3600
76
+ set -g -a __fish_doing_export_plugin_cache (doing plugins --type export -c)
77
+ end
78
+ printf '%s\n' $__fish_doing_export_plugin_cache
79
+ end
80
+
81
+ function __fish_doing_import_plugin
82
+ if not set -q __fish_doing_import_plugin_cache
83
+ or __fish_doing_cache_timer_expired import_plugins 3600
84
+ set -g -a __fish_doing_import_plugin_cache (doing plugins --type import -c)
85
+ end
86
+ printf '%s\n' $__fish_doing_import_plugin_cache
87
+ end
88
+
89
+ function __fish_doing_complete_template
90
+ if not set -q __fish_doing_template_cache
91
+ or __fish_doing_cache_timer_expired template 3600
92
+ set -g -a __fish_doing_template_cache (doing template -c)
93
+ end
94
+ printf '%s\n' $__fish_doing_template_cache
44
95
  end
45
96
 
46
- function __fish_doing_export_plugins
47
- doing plugins --type export -c
97
+ function __fish_doing_complete_tag
98
+ if not set -q __fish_doing_tag_cache
99
+ or __fish_doing_cache_timer_expired tags 60
100
+ set -g -a __fish_doing_tag_cache (doing tags)
101
+ end
102
+ printf '%s\n' $__fish_doing_tag_cache
48
103
  end
49
104
 
50
- function __fish_doing_import_plugins
51
- doing plugins --type import -c
105
+ function __fish_doing_complete_show_tag
106
+ if not set -q __fish_doing_tag_cache
107
+ or __fish_doing_cache_timer_expired tags 60
108
+ set -g -a __fish_doing_tag_cache (doing tags)
109
+ end
110
+ printf '@%s\n' $__fish_doing_tag_cache
52
111
  end
53
112
 
54
- function __fish_doing_complete_templates
55
- doing template -c
113
+ function __fish_doing_complete_args
114
+ for cmd in (doing commands_accepting -c $argv[1])
115
+ complete -x -c doing -l $argv[1] -n "__fish_doing_using_command $cmd" -a "(__fish_doing_complete_$argv[1])"
116
+ end
56
117
  end
57
118
 
58
119
  complete -c doing -f
@@ -64,6 +125,14 @@ module Doing
64
125
  complete -f -c doing -s t -l type -x -n '__fish_doing_using_command import' -a '(__fish_doing_import_plugins)'
65
126
 
66
127
  complete -xc doing -n '__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from (doing help -c)' -a "(doing help -c)"
128
+
129
+ function __fish_doing_complete_args
130
+ for cmd in (doing commands_accepting -c $argv[1])
131
+ complete -x -c doing -l $argv[1] -n "__fish_doing_using_command $cmd" -a "(__fish_doing_complete_$argv[1])"
132
+ end
133
+ end
134
+
135
+ __fish_doing_complete_args tag
67
136
  EOFUNCTIONS
68
137
  end
69
138
 
@@ -161,7 +230,7 @@ module Doing
161
230
  end
162
231
 
163
232
  unless need_export.empty?
164
- out << "complete -f -c doing -s o -l output -x -n '__fish_doing_using_command #{need_export.join(' ')}' -a '(__fish_doing_export_plugins)'"
233
+ out << "complete -f -c doing -s o -l output -x -n '__fish_doing_using_command #{need_export.join(' ')}' -a '(__fish_doing_export_plugin)'"
165
234
  end
166
235
 
167
236
  unless need_bool.empty?
@@ -30,6 +30,7 @@ module Doing
30
30
  'command_path' => File.join(Util.user_home, '.config', 'doing', 'commands')
31
31
  },
32
32
  'doing_file' => '~/.local/share/doing/what_was_i_doing.md',
33
+ 'doing_file_sort' => 'desc',
33
34
  'backup_dir' => '~/.local/share/doing/doing_backup',
34
35
  'history_size' => 15,
35
36
  'current_section' => 'Currently',
@@ -99,7 +100,8 @@ module Doing
99
100
  'search' => {
100
101
  'matching' => 'pattern', # fuzzy, pattern, exact
101
102
  'distance' => 3,
102
- 'case' => 'smart' # sensitive, ignore, smart
103
+ 'case' => 'smart', # sensitive, ignore, smart
104
+ 'highlight' => false
103
105
  },
104
106
  'include_notes' => true,
105
107
  'interaction' => {
data/lib/doing/hash.rb CHANGED
@@ -38,7 +38,7 @@ module Doing
38
38
  #
39
39
  def deep_set(path, value)
40
40
  if path.count == 1
41
- if value
41
+ unless value.nil? || value =~ /^ *$/
42
42
  self[path[0]] = value
43
43
  else
44
44
  delete(path[0])
data/lib/doing/item.rb CHANGED
@@ -9,6 +9,8 @@ module Doing
9
9
 
10
10
  # attr_reader :id
11
11
 
12
+ include Color
13
+
12
14
  ##
13
15
  ## Initialize an item with date, title, section, and
14
16
  ## optional note
@@ -269,6 +271,34 @@ module Doing
269
271
  (case_type == :smart && search !~ /[A-Z]/) || case_type == :ignore
270
272
  end
271
273
 
274
+ def highlight_search(search, distance: nil, negate: false, case_type: nil)
275
+ prefs = Doing.config.settings['search'] || {}
276
+ matching = prefs.fetch('matching', 'pattern').normalize_matching
277
+ distance ||= prefs.fetch('distance', 3).to_i
278
+ case_type ||= prefs.fetch('case', 'smart').normalize_case
279
+ new_note = Note.new
280
+
281
+ if search.is_rx? || matching == :fuzzy
282
+ rx = search.to_rx(distance: distance, case_type: case_type)
283
+ new_title = @title.gsub(rx) { |m| yellow(m) }
284
+ new_note.add(@note.to_s.gsub(rx) { |m| yellow(m) })
285
+ else
286
+ query = to_phrase_query(search.strip)
287
+
288
+ if query[:must].nil? && query[:must_not].nil?
289
+ query[:must] = query[:should]
290
+ query[:should] = []
291
+ end
292
+ query[:must].concat(query[:should]).each do |s|
293
+ rx = Regexp.new(s.wildcard_to_rx, ignore_case(s, case_type))
294
+ new_title = @title.gsub(rx) { |m| yellow(m) }
295
+ new_note.add(@note.to_s.gsub(rx) { |m| yellow(m) })
296
+ end
297
+ end
298
+
299
+ Item.new(@date, new_title, @section, new_note)
300
+ end
301
+
272
302
  ##
273
303
  ## Test if item matches search string
274
304
  ##
@@ -372,6 +402,27 @@ module Doing
372
402
  "\t- #{@date.strftime('%Y-%m-%d %H:%M')} | #{@title}#{@note.empty? ? '' : "\n#{@note}"}"
373
403
  end
374
404
 
405
+ ##
406
+ ## outputs a colored string with relative date and highlighted tags
407
+ ##
408
+ ## @return Pretty representation of the object.
409
+ ##
410
+ def to_pretty(elements: %i[date title section])
411
+ output = []
412
+ elements.each do |e|
413
+ case e
414
+ when :date
415
+ output << format('%13s |', @date.relative_date).cyan
416
+ when :section
417
+ output << "#{magenta}(#{white(@section)}#{magenta})"
418
+ when :title
419
+ output << @title.white.highlight_tags('cyan')
420
+ end
421
+ end
422
+
423
+ output.join(' ')
424
+ end
425
+
375
426
  # @private
376
427
  def inspect
377
428
  # %(<Doing::Item @date=#{@date} @title="#{@title}" @section:"#{@section}" @note:#{@note.to_s}>)
data/lib/doing/items.rb CHANGED
@@ -131,7 +131,9 @@ module Doing
131
131
  out = []
132
132
  @sections.each do |section|
133
133
  out.push(section.original)
134
- in_section(section.title).each { |item| out.push(item.to_s)}
134
+ items = in_section(section.title).sort_by { |i| i.date }
135
+ items.reverse! if Doing.config.settings['doing_file_sort'].normalize_order == 'desc'
136
+ items.each { |item| out.push(item.to_s)}
135
137
  end
136
138
 
137
139
  out.join("\n")
@@ -398,9 +398,9 @@ module Doing
398
398
  return topic.ljust(TOPIC_WIDTH) if topic && message.strip.empty?
399
399
 
400
400
  topic = formatted_topic(topic, colon: block_given?)
401
- message.truncmiddle!(@max_length - TOPIC_WIDTH - 5)
401
+ # message.truncmiddle!(@max_length - TOPIC_WIDTH - 5)
402
402
  out = topic + message
403
- out.truncate!(@max_length) if @max_length.positive?
403
+ # out.truncate!(@max_length) if @max_length.positive?
404
404
  messages << out
405
405
  out
406
406
  end
data/lib/doing/pager.rb CHANGED
@@ -55,7 +55,7 @@ module Doing
55
55
  write_io.write(text)
56
56
  write_io.close
57
57
  rescue SystemCallError => e
58
- raise Errors::DoingStandardError, "Pager error, #{e}"
58
+ # raise Errors::DoingStandardError, "Pager error, #{e}"
59
59
  end
60
60
 
61
61
  _, status = Process.waitpid2(pid)
@@ -75,7 +75,7 @@ module Doing
75
75
  note = i.note.map { |line| line.strip.link_urls(format: :markdown) } if i.note
76
76
  end
77
77
 
78
- title = "#{title} @project(#{i.section})" unless variables[:is_single]
78
+ title = "#{title} @section(#{i.section})" unless variables[:is_single]
79
79
 
80
80
  tags.concat(i.tag_array).sort!.uniq!
81
81
  flagged = day_flagged = true if i.tags?(wwid.config['marker_tag'])
@@ -48,7 +48,7 @@ module Doing
48
48
  note = i.note.map { |line| line.strip.link_urls(format: :markdown) } if i.note
49
49
  end
50
50
 
51
- title = "#{title} @project(#{i.section})" unless variables[:is_single]
51
+ title = "#{title} @section(#{i.section})" unless variables[:is_single]
52
52
 
53
53
  interval = wwid.get_interval(i, record: true) if i.title =~ /@done\((\d{4}-\d\d-\d\d \d\d:\d\d.*?)\)/ && opt[:times]
54
54
  interval ||= false
@@ -119,6 +119,8 @@ module Doing
119
119
 
120
120
  output.gsub!(/\\%/, '%')
121
121
 
122
+ output.highlight_search!(opt[:search]) if opt[:search] && !opt[:not] && opt[:hilite]
123
+
122
124
  out += "#{output}\n"
123
125
  end
124
126
 
data/lib/doing/prompt.rb CHANGED
@@ -17,6 +17,7 @@ module Doing
17
17
  end
18
18
 
19
19
  def enter_text(prompt, default_response: '')
20
+ $stdin.reopen('/dev/tty')
20
21
  return default_response if @default_answer
21
22
 
22
23
  print "#{yellow(prompt).sub(/:?$/, ':')} #{reset}"
@@ -24,12 +25,13 @@ module Doing
24
25
  end
25
26
 
26
27
  def read_line(prompt: 'Enter text', completions: [], default_response: '')
28
+ $stdin.reopen('/dev/tty')
27
29
  return default_response if @default_answer
28
30
 
29
31
  unless completions.empty?
30
32
  completions.sort!
31
33
  comp = proc { |s| completions.grep(/^#{Regexp.escape(s)}/) }
32
- Readline.completion_append_character = " "
34
+ Readline.completion_append_character = ' '
33
35
  Readline.completion_proc = comp
34
36
  end
35
37
 
@@ -41,20 +43,26 @@ module Doing
41
43
  end
42
44
 
43
45
  def read_lines(prompt: 'Enter text', completions: [])
46
+ $stdin.reopen('/dev/tty')
44
47
  return default_response if @default_answer
45
48
 
46
49
  completions.sort!
47
50
  comp = proc { |s| completions.grep(/^#{Regexp.escape(s)}/) }
48
- Readline.completion_append_character = " "
51
+ Readline.completion_append_character = ' '
49
52
  Readline.completion_proc = comp
50
-
51
- puts "#{boldgreen(prompt.sub(/:?$/, ':'))} #{yellow('Hit return for a new line, ')}#{boldwhite('enter a blank line (')}#{boldyellow('return twice')}#{boldwhite(') to end editing')}"
53
+ prompt_text = []
54
+ prompt_text << boldgreen(prompt.sub(/:?$/, ':'))
55
+ prompt_text << yellow(' Enter a blank line (')
56
+ prompt_text << boldwhite('return twice')
57
+ prompt_text << yellow(') to end editing')
58
+ puts prompt_text.join('')
52
59
 
53
60
  res = []
54
61
 
55
62
  begin
56
- while line = Readline.readline('> ', true)
63
+ while (line = Readline.readline('> ', true))
57
64
  break if line.strip.empty?
65
+
58
66
  res << line.chomp
59
67
  end
60
68
  rescue Interrupt
@@ -65,6 +73,7 @@ module Doing
65
73
  end
66
74
 
67
75
  def request_lines(prompt: 'Enter text')
76
+ $stdin.reopen('/dev/tty')
68
77
  ask_note = []
69
78
  reader = TTY::Reader.new(interrupt: -> { raise Errors::UserCancelled }, track_history: false)
70
79
  puts "#{boldgreen(prompt.sub(/:?$/, ':'))} #{yellow('Hit return for a new line, ')}#{boldwhite('enter a blank line (')}#{boldyellow('return twice')}#{boldwhite(') to end editing')}"
@@ -92,6 +101,8 @@ module Doing
92
101
  return @force_answer
93
102
  end
94
103
 
104
+ $stdin.reopen('/dev/tty')
105
+
95
106
  default = if default_response.is_a?(String)
96
107
  default_response =~ /y/i ? true : false
97
108
  else
data/lib/doing/string.rb CHANGED
@@ -101,6 +101,49 @@ module Doing
101
101
  gsub(/(\s|m)(@[^ ("']+)/, "\\1#{tag_color}\\2#{last_color}")
102
102
  end
103
103
 
104
+ def to_phrase_query(query)
105
+ parser = PhraseParser::QueryParser.new
106
+ transformer = PhraseParser::QueryTransformer.new
107
+ parse_tree = parser.parse(query)
108
+ transformer.apply(parse_tree).to_elasticsearch
109
+ end
110
+
111
+ def ignore_case(search, case_type)
112
+ (case_type == :smart && search !~ /[A-Z]/) || case_type == :ignore
113
+ end
114
+
115
+ def highlight_search!(search, distance: nil, negate: false, case_type: nil)
116
+ replace highlight_search(search, distance: distance, negate: negate, case_type: case_type)
117
+ end
118
+
119
+ def highlight_search(search, distance: nil, negate: false, case_type: nil)
120
+ out = dup
121
+ prefs = Doing.config.settings['search'] || {}
122
+ matching = prefs.fetch('matching', 'pattern').normalize_matching
123
+ distance ||= prefs.fetch('distance', 3).to_i
124
+ case_type ||= prefs.fetch('case', 'smart').normalize_case
125
+
126
+ if search.is_rx? || matching == :fuzzy
127
+ rx = search.to_rx(distance: distance, case_type: case_type)
128
+ out.gsub!(rx) { |m| m.bgyellow.black }
129
+ else
130
+ query = to_phrase_query(search.strip)
131
+
132
+ if query[:must].nil? && query[:must_not].nil?
133
+ query[:must] = query[:should]
134
+ query[:should] = []
135
+ end
136
+ qs = []
137
+ qs.concat(query[:must]) if query[:must]
138
+ qs.concat(query[:should]) if query[:should]
139
+ qs.each do |s|
140
+ rx = Regexp.new(s.wildcard_to_rx, ignore_case(s, case_type))
141
+ out.gsub!(rx) { |m| m.bgyellow.black }
142
+ end
143
+ end
144
+ out
145
+ end
146
+
104
147
  ##
105
148
  ## Test if line should be ignored
106
149
  ##
@@ -642,6 +685,15 @@ module Doing
642
685
  end
643
686
  end
644
687
 
688
+ def to_bool
689
+ case self
690
+ when /^[yt1]/i
691
+ true
692
+ else
693
+ false
694
+ end
695
+ end
696
+
645
697
  ##
646
698
  ## Convert a string value to an appropriate type. If
647
699
  ## kind is not specified, '[one, two]' becomes an Array,
@@ -661,6 +713,8 @@ module Doing
661
713
  gsub(/^\[ *| *\]$/, '').split(/ *, */)
662
714
  when /^i/i
663
715
  to_i
716
+ when /^(fa|tr)/i
717
+ to_bool
664
718
  when /^f/i
665
719
  to_f
666
720
  when /^sy/i