doing 2.1.30 → 2.1.31pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.irbrc +1 -0
  3. data/.yardoc/checksums +9 -8
  4. data/.yardoc/object_types +0 -0
  5. data/.yardoc/objects/root.dat +0 -0
  6. data/CHANGELOG.md +4923 -0
  7. data/Gemfile.lock +1 -1
  8. data/README.md +1 -1
  9. data/bin/commands/again.rb +1 -1
  10. data/bin/commands/archive.rb +3 -3
  11. data/bin/commands/cancel.rb +1 -1
  12. data/bin/commands/commands.rb +8 -8
  13. data/bin/commands/completion.rb +61 -19
  14. data/bin/commands/config.rb +9 -9
  15. data/bin/commands/done.rb +1 -1
  16. data/bin/commands/flag.rb +1 -1
  17. data/bin/commands/grep.rb +5 -5
  18. data/bin/commands/last.rb +1 -1
  19. data/bin/commands/meanwhile.rb +1 -1
  20. data/bin/commands/now.rb +1 -1
  21. data/bin/commands/on.rb +1 -1
  22. data/bin/commands/open.rb +1 -1
  23. data/bin/commands/recent.rb +4 -4
  24. data/bin/commands/show.rb +8 -8
  25. data/bin/commands/since.rb +1 -1
  26. data/bin/commands/today.rb +1 -1
  27. data/bin/commands/view.rb +3 -3
  28. data/bin/commands/yesterday.rb +2 -2
  29. data/bin/doing +22 -133
  30. data/docs/doc/Array.html +1 -1
  31. data/docs/doc/BooleanTermParser/Clause.html +1 -1
  32. data/docs/doc/BooleanTermParser/Operator.html +1 -1
  33. data/docs/doc/BooleanTermParser/Query.html +1 -1
  34. data/docs/doc/BooleanTermParser/QueryParser.html +1 -1
  35. data/docs/doc/BooleanTermParser/QueryTransformer.html +1 -1
  36. data/docs/doc/BooleanTermParser.html +1 -1
  37. data/docs/doc/Doing/Color.html +1 -1
  38. data/docs/doc/Doing/Completion.html +324 -4
  39. data/docs/doc/Doing/Configuration.html +1 -1
  40. data/docs/doc/Doing/Errors/DoingNoTraceError.html +1 -1
  41. data/docs/doc/Doing/Errors/DoingRuntimeError.html +1 -1
  42. data/docs/doc/Doing/Errors/DoingStandardError.html +1 -1
  43. data/docs/doc/Doing/Errors/EmptyInput.html +1 -1
  44. data/docs/doc/Doing/Errors/NoResults.html +1 -1
  45. data/docs/doc/Doing/Errors/PluginException.html +1 -1
  46. data/docs/doc/Doing/Errors/UserCancelled.html +1 -1
  47. data/docs/doc/Doing/Errors/WrongCommand.html +1 -1
  48. data/docs/doc/Doing/Errors.html +1 -1
  49. data/docs/doc/Doing/Hooks.html +1 -1
  50. data/docs/doc/Doing/Item.html +125 -1
  51. data/docs/doc/Doing/Items.html +1 -1
  52. data/docs/doc/Doing/LogAdapter.html +1 -1
  53. data/docs/doc/Doing/Note.html +109 -3
  54. data/docs/doc/Doing/Pager.html +1 -1
  55. data/docs/doc/Doing/Plugins.html +1 -1
  56. data/docs/doc/Doing/Prompt.html +1 -1
  57. data/docs/doc/Doing/Section.html +1 -1
  58. data/docs/doc/Doing/TemplateString.html +1 -1
  59. data/docs/doc/Doing/Types.html +1 -1
  60. data/docs/doc/Doing/Util/Backup.html +1 -1
  61. data/docs/doc/Doing/Util.html +1 -1
  62. data/docs/doc/Doing/WWID.html +6 -6
  63. data/docs/doc/Doing.html +2 -2
  64. data/docs/doc/FalseClass.html +1 -1
  65. data/docs/doc/GLI/Commands/Help.html +1 -1
  66. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +1 -1
  67. data/docs/doc/GLI/Commands.html +1 -1
  68. data/docs/doc/GLI.html +1 -1
  69. data/docs/doc/Hash.html +1 -1
  70. data/docs/doc/Object.html +1 -1
  71. data/docs/doc/PhraseParser/Operator.html +1 -1
  72. data/docs/doc/PhraseParser/PhraseClause.html +1 -1
  73. data/docs/doc/PhraseParser/Query.html +1 -1
  74. data/docs/doc/PhraseParser/QueryParser.html +1 -1
  75. data/docs/doc/PhraseParser/QueryTransformer.html +1 -1
  76. data/docs/doc/PhraseParser/TermClause.html +1 -1
  77. data/docs/doc/PhraseParser.html +1 -1
  78. data/docs/doc/Status.html +1 -1
  79. data/docs/doc/String.html +1 -1
  80. data/docs/doc/Symbol.html +1 -1
  81. data/docs/doc/Time.html +1 -1
  82. data/docs/doc/TrueClass.html +1 -1
  83. data/docs/doc/_index.html +3 -1
  84. data/docs/doc/file.README.html +2 -2
  85. data/docs/doc/index.html +2 -2
  86. data/docs/doc/method_list.html +337 -241
  87. data/docs/doc/top-level-namespace.html +105 -1
  88. data/doing.rdoc +25 -9
  89. data/example_plugin.rb +7 -5
  90. data/lib/completion/_doing.zsh +2 -2
  91. data/lib/completion/doing.bash +2 -2
  92. data/lib/completion/doing.fish +2 -3
  93. data/lib/doing/add_options.rb +117 -0
  94. data/lib/doing/array/array.rb +16 -0
  95. data/lib/doing/completion/bash_completion.rb +12 -51
  96. data/lib/doing/completion/fish_completion.rb +16 -52
  97. data/lib/doing/completion/zsh_completion.rb +12 -56
  98. data/lib/doing/completion.rb +203 -17
  99. data/lib/doing/item.rb +21 -3
  100. data/lib/doing/items.rb +5 -5
  101. data/lib/doing/note.rb +24 -8
  102. data/lib/doing/plugins/export/dayone_export.rb +8 -6
  103. data/lib/doing/plugins/export/html_export.rb +4 -4
  104. data/lib/doing/plugins/export/json_export.rb +19 -20
  105. data/lib/doing/plugins/export/markdown_export.rb +2 -2
  106. data/lib/doing/plugins/export/template_export.rb +4 -4
  107. data/lib/doing/plugins/import/calendar_import.rb +1 -1
  108. data/lib/doing/plugins/import/doing_import.rb +1 -1
  109. data/lib/doing/plugins/import/timing_import.rb +1 -1
  110. data/lib/doing/string/highlight.rb +3 -4
  111. data/lib/doing/string/string.rb +8 -0
  112. data/lib/doing/util.rb +1 -1
  113. data/lib/doing/util_backup.rb +12 -12
  114. data/lib/doing/version.rb +1 -1
  115. data/lib/doing/wwid.rb +76 -77
  116. data/lib/doing.rb +57 -0
  117. data/lib/examples/commands/wiki.rb +27 -19
  118. data/scripts/setting_replace.rb +11 -0
  119. metadata +6 -4
data/bin/doing CHANGED
@@ -4,6 +4,7 @@
4
4
  $LOAD_PATH.unshift File.join(__dir__, '..', 'lib')
5
5
  require 'gli'
6
6
  require 'doing/help_monkey_patch'
7
+ require 'doing/add_options'
7
8
  require 'doing'
8
9
  require 'tempfile'
9
10
  require 'pp'
@@ -26,6 +27,7 @@ include Doing::Errors
26
27
  version Doing::VERSION
27
28
  hide_commands_without_desc true
28
29
  autocomplete_commands true
30
+ wrap_help_text :one_line unless $stdout.isatty
29
31
 
30
32
  include Doing::Types
31
33
 
@@ -35,7 +37,9 @@ include Doing::Types
35
37
  Doing.logger.log_level = :info
36
38
  env_log_level = nil
37
39
 
38
- if ENV['DOING_LOG_LEVEL'] || ENV['DOING_DEBUG'] || ENV['DOING_QUIET'] || ENV['DOING_VERBOSE'] || ENV['DOING_PLUGIN_DEBUG']
40
+ if ENV['DOING_LOG_LEVEL'] ||
41
+ ENV['DOING_DEBUG'] || ENV['DOING_QUIET'] ||
42
+ ENV['DOING_VERBOSE'] || ENV['DOING_PLUGIN_DEBUG']
39
43
  env_log_level = true
40
44
  # Quiet always wins
41
45
  if ENV['DOING_QUIET']&.truthy?
@@ -53,21 +57,20 @@ Doing.logger.benchmark(:total, :start)
53
57
 
54
58
  Doing.logger.benchmark(:configure, :start)
55
59
  Doing.config_with(ENV['DOING_CONFIG'], { ignore_local: true }) if ENV['DOING_CONFIG']
56
- @config = Doing.config
57
60
  Doing.logger.benchmark(:configure, :finish)
58
61
 
59
- @config.settings['backup_dir'] = ENV['DOING_BACKUP_DIR'] if ENV['DOING_BACKUP_DIR']
60
- @settings = @config.settings
61
- @wwid.config = @settings
62
+ Doing.set('backup_dir', ENV['DOING_BACKUP_DIR']) if ENV['DOING_BACKUP_DIR']
62
63
 
63
- commands_from File.expand_path(@settings.dig('plugins', 'command_path')) if @settings.dig('plugins', 'command_path')
64
+ # Set up class vars for backwards compatibility
65
+ @settings = Doing.settings
66
+ @wwid.config = Doing.settings
64
67
 
65
68
  accept BooleanSymbol do |value|
66
69
  value.normalize_bool(:pattern)
67
70
  end
68
71
 
69
72
  accept CaseSymbol do |value|
70
- value.normalize_case(@config.fetch('search', 'case', :smart))
73
+ value.normalize_case(Doing.config.fetch('search', 'case', :smart))
71
74
  end
72
75
 
73
76
  accept AgeSymbol do |value|
@@ -83,11 +86,11 @@ accept MatchingSymbol do |value|
83
86
  end
84
87
 
85
88
  accept TagSortSymbol do |value|
86
- value.normalize_tag_sort(@config.fetch('tag_sort', :name))
89
+ value.normalize_tag_sort(Doing.config.fetch('tag_sort', :name))
87
90
  end
88
91
 
89
92
  accept TemplateName do |value|
90
- res = @settings['templates'].keys.select { |k| k =~ value.to_rx(distance: 2) }
93
+ res = Doing.setting('templates').keys.select { |k| k =~ value.to_rx(distance: 2) }
91
94
  raise InvalidArgument, "Unknown template: #{value}" unless res.good?
92
95
 
93
96
  res.group_by(&:length).min.last[0]
@@ -141,121 +144,7 @@ accept TagArray do |value|
141
144
  value.gsub(/[, ]+/, ' ').split(' ').map { |tag| tag.sub(/^@/, '') }.map(&:strip)
142
145
  end
143
146
 
144
- ##
145
- ## Add presets of flags and switches to a command.
146
- ##
147
- ## :add_entry => --noauto, --note, --ask, --editor, --back
148
- ##
149
- ## :search => --search, --case, --exact
150
- ##
151
- ## :tag_filter => --tag, --bool, --not, --val
152
- ##
153
- ## :date_filter => --before, --after, --from
154
- ##
155
- ## @param type [Symbol] The type
156
- ## @param cmd The GLI command to which the options will be added
157
- ##
158
- def add_options(type, cmd)
159
- cmd_name = cmd.name.to_s
160
- action = case cmd_name
161
- when /again/
162
- 'Repeat'
163
- when /grep/
164
- 'Search'
165
- when /mark/
166
- 'Flag'
167
- when /(last|tags|view)/
168
- 'Show'
169
- else
170
- cmd_name.capitalize
171
- end
172
-
173
- case type
174
- when :add_entry
175
- cmd.desc 'Exclude auto tags and default tags'
176
- cmd.switch %i[X noauto], default_value: false, negatable: false
177
-
178
- cmd.desc 'Include a note'
179
- cmd.arg_name 'TEXT'
180
- cmd.flag %i[n note]
181
-
182
- cmd.desc 'Prompt for note via multi-line input'
183
- cmd.switch %i[ask], negatable: false, default_value: false
184
-
185
- cmd.desc "Edit entry with #{Doing::Util.default_editor}"
186
- cmd.switch %i[e editor], negatable: false, default_value: false
187
-
188
- cmd.desc 'Backdate start date for new entry to date string [4pm|20m|2h|yesterday noon]'
189
- cmd.arg_name 'DATE_STRING'
190
- cmd.flag %i[b back started], type: DateBeginString
191
- when :search
192
- cmd.desc 'Filter entries using a search query, surround with slashes for regex (e.g. "/query.*/"),
193
- start with single quote for exact match ("\'query")'
194
- cmd.arg_name 'QUERY'
195
- cmd.flag [:search]
196
-
197
- cmd.desc 'Case sensitivity for search string matching [(c)ase-sensitive, (i)gnore, (s)mart]'
198
- cmd.arg_name 'TYPE'
199
- cmd.flag [:case], must_match: REGEX_CASE,
200
- default_value: @settings.dig('search', 'case').normalize_case,
201
- type: CaseSymbol
202
-
203
- cmd.desc 'Force exact search string matching (case sensitive)'
204
- cmd.switch %i[x exact], default_value: @config.exact_match?, negatable: @config.exact_match?
205
- when :tag_filter
206
- cmd.desc 'Filter entries by tag. Combine multiple tags with a comma. Wildcards allowed (*, ?)'
207
- cmd.arg_name 'TAG'
208
- cmd.flag [:tag], type: TagArray
209
-
210
- cmd.desc 'Perform a tag value query ("@done > two hours ago" or "@progress < 50").
211
- May be used multiple times, combined with --bool'
212
- cmd.arg_name 'QUERY'
213
- cmd.flag [:val], multiple: true, must_match: REGEX_VALUE_QUERY
214
-
215
- cmd.desc "#{action} items that *don't* match search/tag filters"
216
- cmd.switch [:not], default_value: false, negatable: false
217
-
218
- cmd.desc 'Boolean used to combine multiple tags. Use PATTERN to parse + and - as booleans'
219
- cmd.arg_name 'BOOLEAN'
220
- cmd.flag [:bool], must_match: REGEX_BOOL,
221
- default_value: :pattern,
222
- type: BooleanSymbol
223
- when :date_filter
224
- if action =~ /Archive/
225
- cmd.desc 'Archive entries older than date (natural language).'
226
- else
227
- cmd.desc "#{action} entries older than date (natural language). If this is only a time (8am, 1:30pm, 15:00), all
228
- dates will be included, but entries will be filtered by time of day"
229
- end
230
- cmd.arg_name 'DATE_STRING'
231
- cmd.flag [:before], type: DateBeginString
232
-
233
- if action =~ /Archive/
234
- cmd.desc 'Archive entries newer than date (natural language).'
235
- else
236
- cmd.desc "#{action} entries newer than date (natural language). If this is only a time (8am, 1:30pm, 15:00), all
237
- dates will be included, but entries will be filtered by time of day"
238
- end
239
- cmd.arg_name 'DATE_STRING'
240
- cmd.flag [:after], type: DateEndString
241
-
242
- if action =~ /Archive/
243
- cmd.desc %(
244
- Date range (natural language) to archive: `doing archive --from "1/1/21 to 12/31/21"`.
245
- )
246
- else
247
- cmd.desc %(
248
- Date range (natural language) to #{action.downcase}, or a single day to filter on.
249
- To specify a range, use "to": `doing #{cmd_name} --from "monday 8am to friday 5pm"`.
250
-
251
- If values are only time(s) (6am to noon) all dates will be included, but entries will be filtered
252
- by time of day.
253
- )
254
- end
255
- cmd.arg_name 'DATE_OR_RANGE'
256
- cmd.flag [:from], type: DateRangeString
257
- end
258
- end
147
+ commands_from File.expand_path(Doing.setting('plugins.command_path')) if Doing.setting('plugins.command_path')
259
148
 
260
149
  program_desc 'A CLI for a What Was I Doing system'
261
150
  program_long_desc %(Doing uses a TaskPaper-like formatting to keep a plain text
@@ -275,7 +164,7 @@ desc 'Send results report to STDOUT instead of STDERR'
275
164
  switch [:stdout], default_value: false, negatable: false
276
165
 
277
166
  desc 'Use a pager when output is longer than screen'
278
- switch %i[p pager], default_value: @settings['paginate']
167
+ switch %i[p pager], default_value: Doing.setting('paginate')
279
168
 
280
169
  desc 'Answer yes/no menus with default option'
281
170
  switch [:default], default_value: false, negatable: false
@@ -299,14 +188,14 @@ desc 'Verbose output'
299
188
  switch %i[debug], default_value: false, negatable: false
300
189
 
301
190
  desc 'Use a specific configuration file. Deprecated, set $DOING_CONFIG instead'
302
- flag [:config_file], default_value: @config.config_file
191
+ flag [:config_file], default_value: Doing.config.config_file
303
192
 
304
193
  desc 'Specify a different doing_file'
305
194
  flag %i[f doing_file]
306
195
 
307
196
  def add_commands(commands)
308
197
  commands = [commands] unless commands.is_a?(Array)
309
- hidden = @settings['disabled_commands']
198
+ hidden = Doing.setting('disabled_commands')
310
199
  hidden = hidden.set_type('array') if hidden.good? && !hidden.is_a?(Array)
311
200
  commands.delete_if { |c| hidden.include?(c) }
312
201
  commands.each { |cmd| require_relative "commands/#{cmd}" }
@@ -328,7 +217,7 @@ add_commands(%w[commands_accepting install_fzf])
328
217
  add_commands(%w[again cancel flag meanwhile reset tags today yesterday since add_section tag_dir colors completion plugins sections template views changes])
329
218
 
330
219
  pre do |global, _command, _options, _args|
331
- # global[:pager] ||= @settings['paginate']
220
+ # global[:pager] ||= Doing.setting('paginate')
332
221
  Doing::Pager.paginate = global[:pager]
333
222
 
334
223
  $stdout.puts "doing v#{Doing::VERSION}" if global[:version]
@@ -367,7 +256,7 @@ end
367
256
 
368
257
  around do |global, command, options, arguments, code|
369
258
  Doing.logger.benchmark("command_#{command.name.to_s}".to_sym, :start)
370
- # Doing.logger.debug('Pager:', "Global: #{global[:pager]}, Config: #{@settings['paginate']}, Pager: #{Doing::Pager.paginate}")
259
+ # Doing.logger.debug('Pager:', "Global: #{global[:pager]}, Config: #{Doing.setting('paginate')}, Pager: #{Doing::Pager.paginate}")
371
260
  if env_log_level.nil?
372
261
  Doing.logger.adjust_verbosity(global)
373
262
  end
@@ -392,15 +281,15 @@ around do |global, command, options, arguments, code|
392
281
  Doing.config.force_answer = global[:default] ? true : false
393
282
  end
394
283
 
395
- if global[:config_file] && global[:config_file] != @config.config_file
284
+ if global[:config_file] && global[:config_file] != Doing.config.config_file
396
285
  Doing.logger.warn(format('%sWARNING:%s %sThe use of --config_file is deprecated, please set the environment variable DOING_CONFIG instead.', @colors.flamingo, @colors.default, @colors.boldred))
397
286
  Doing.logger.warn(format('%sTo set it just for the current command, use: %sDOING_CONFIG=/path/to/doingrc doing [command]%s', @colors.red, @colors.boldwhite, @colors.default))
398
287
 
399
288
  cf = File.expand_path(global[:config_file])
400
289
  raise MissingConfigFile, "Config file not found (#{global[:config_file]})" unless File.exist?(cf)
401
290
 
402
- @config.config_file = cf
403
- @settings = @config.configure({ ignore_local: true })
291
+ Doing.config.config_file = cf
292
+ Doing.config_with(cf, { ignore_local: true })
404
293
  end
405
294
  Doing.logger.benchmark(:init, :start)
406
295
  if global[:doing_file]
@@ -411,7 +300,7 @@ around do |global, command, options, arguments, code|
411
300
  Doing.logger.benchmark(:init, :finish)
412
301
  @wwid.auto_tag = !global[:noauto]
413
302
 
414
- @settings[:include_notes] = false unless global[:notes]
303
+ Doing.set('include_notes', false) unless global[:notes]
415
304
 
416
305
  global[:wwid] = @wwid
417
306
 
data/docs/doc/Array.html CHANGED
@@ -195,7 +195,7 @@ has content</p>
195
195
  </div>
196
196
 
197
197
  <div id="footer">
198
- Generated on Wed Feb 16 07:23:35 2022 by
198
+ Generated on Thu Feb 17 13:05:18 2022 by
199
199
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
200
200
  0.9.27 (ruby-3.0.1).
201
201
  </div>
@@ -283,7 +283,7 @@
283
283
  </div>
284
284
 
285
285
  <div id="footer">
286
- Generated on Wed Feb 16 07:23:35 2022 by
286
+ Generated on Thu Feb 17 13:05:19 2022 by
287
287
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
288
288
  0.9.27 (ruby-3.0.1).
289
289
  </div>
@@ -162,7 +162,7 @@
162
162
  </div>
163
163
 
164
164
  <div id="footer">
165
- Generated on Wed Feb 16 07:23:35 2022 by
165
+ Generated on Thu Feb 17 13:05:19 2022 by
166
166
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
167
167
  0.9.27 (ruby-3.0.1).
168
168
  </div>
@@ -407,7 +407,7 @@
407
407
  </div>
408
408
 
409
409
  <div id="footer">
410
- Generated on Wed Feb 16 07:23:35 2022 by
410
+ Generated on Thu Feb 17 13:05:19 2022 by
411
411
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
412
412
  0.9.27 (ruby-3.0.1).
413
413
  </div>
@@ -125,7 +125,7 @@ parser. In order to do that, a new &quot;clause&quot; node is added to the parse
125
125
  </div>
126
126
 
127
127
  <div id="footer">
128
- Generated on Wed Feb 16 07:23:35 2022 by
128
+ Generated on Thu Feb 17 13:05:19 2022 by
129
129
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
130
130
  0.9.27 (ruby-3.0.1).
131
131
  </div>
@@ -114,7 +114,7 @@
114
114
  </div>
115
115
 
116
116
  <div id="footer">
117
- Generated on Wed Feb 16 07:23:35 2022 by
117
+ Generated on Thu Feb 17 13:05:19 2022 by
118
118
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
119
  0.9.27 (ruby-3.0.1).
120
120
  </div>
@@ -105,7 +105,7 @@
105
105
  </div>
106
106
 
107
107
  <div id="footer">
108
- Generated on Wed Feb 16 07:23:35 2022 by
108
+ Generated on Thu Feb 17 13:05:18 2022 by
109
109
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
110
110
  0.9.27 (ruby-3.0.1).
111
111
  </div>
@@ -518,7 +518,7 @@ ANSI-sequences are stripped from the string.</p>
518
518
  </div>
519
519
 
520
520
  <div id="footer">
521
- Generated on Wed Feb 16 07:23:35 2022 by
521
+ Generated on Thu Feb 17 13:05:18 2022 by
522
522
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
523
523
  0.9.27 (ruby-3.0.1).
524
524
  </div>