doing 2.1.47 → 2.1.52

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 (126) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -0
  3. data/Gemfile.lock +2 -2
  4. data/README.md +1 -1
  5. data/bin/commands/completion.rb +1 -1
  6. data/bin/commands/now.rb +2 -1
  7. data/docs/doc/Array.html +1 -1
  8. data/docs/doc/BooleanTermParser/Clause.html +1 -1
  9. data/docs/doc/BooleanTermParser/Operator.html +1 -1
  10. data/docs/doc/BooleanTermParser/Query.html +1 -1
  11. data/docs/doc/BooleanTermParser/QueryParser.html +1 -1
  12. data/docs/doc/BooleanTermParser/QueryTransformer.html +1 -1
  13. data/docs/doc/BooleanTermParser.html +1 -1
  14. data/docs/doc/Doing/ArrayCleanup.html +1 -1
  15. data/docs/doc/Doing/ArrayNestedHash.html +1 -1
  16. data/docs/doc/Doing/ArrayTags.html +1 -1
  17. data/docs/doc/Doing/CSVExport.html +1 -1
  18. data/docs/doc/Doing/CalendarImport.html +1 -1
  19. data/docs/doc/Doing/Change.html +1 -1
  20. data/docs/doc/Doing/Changes.html +1 -1
  21. data/docs/doc/Doing/ChronifyArray.html +1 -1
  22. data/docs/doc/Doing/ChronifyNumeric.html +1 -1
  23. data/docs/doc/Doing/ChronifyString.html +1 -1
  24. data/docs/doc/Doing/Color.html +1 -1
  25. data/docs/doc/Doing/Completion/BashCompletions.html +1 -1
  26. data/docs/doc/Doing/Completion/FigCompletions.html +445 -0
  27. data/docs/doc/Doing/Completion/FishCompletions.html +1 -1
  28. data/docs/doc/Doing/Completion/StringUtils.html +1 -1
  29. data/docs/doc/Doing/Completion/ZshCompletions.html +1 -1
  30. data/docs/doc/Doing/Completion.html +5 -5
  31. data/docs/doc/Doing/Configuration.html +1 -1
  32. data/docs/doc/Doing/DayOneRenderer.html +1 -1
  33. data/docs/doc/Doing/DayoneExport.html +1 -1
  34. data/docs/doc/Doing/DoingExport.html +206 -0
  35. data/docs/doc/Doing/DoingImport.html +1 -1
  36. data/docs/doc/Doing/Entry.html +1 -1
  37. data/docs/doc/Doing/Errors/DoingNoTraceError.html +1 -1
  38. data/docs/doc/Doing/Errors/DoingRuntimeError.html +1 -1
  39. data/docs/doc/Doing/Errors/DoingStandardError.html +1 -1
  40. data/docs/doc/Doing/Errors/EmptyInput.html +1 -1
  41. data/docs/doc/Doing/Errors/HistoryLimitError.html +1 -1
  42. data/docs/doc/Doing/Errors/InvalidPlugin.html +1 -1
  43. data/docs/doc/Doing/Errors/MissingBackupFile.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/HTMLExport.html +1 -1
  50. data/docs/doc/Doing/Hooks.html +1 -1
  51. data/docs/doc/Doing/Item.html +1 -1
  52. data/docs/doc/Doing/ItemDates.html +1 -1
  53. data/docs/doc/Doing/ItemQuery.html +1 -1
  54. data/docs/doc/Doing/ItemState.html +1 -1
  55. data/docs/doc/Doing/ItemTags.html +1 -1
  56. data/docs/doc/Doing/Items.html +1 -1
  57. data/docs/doc/Doing/JSONExport.html +1 -1
  58. data/docs/doc/Doing/JSONImport.html +1 -1
  59. data/docs/doc/Doing/Logger.html +1 -1
  60. data/docs/doc/Doing/MarkdownExport.html +1 -1
  61. data/docs/doc/Doing/Note.html +1 -1
  62. data/docs/doc/Doing/Pager.html +1 -1
  63. data/docs/doc/Doing/Plugins.html +1 -1
  64. data/docs/doc/Doing/Prompt.html +1 -1
  65. data/docs/doc/Doing/PromptChoose.html +1 -1
  66. data/docs/doc/Doing/PromptFZF.html +1 -1
  67. data/docs/doc/Doing/PromptInput.html +1 -1
  68. data/docs/doc/Doing/PromptSTD.html +1 -1
  69. data/docs/doc/Doing/PromptYN.html +1 -1
  70. data/docs/doc/Doing/Section.html +1 -1
  71. data/docs/doc/Doing/StringHighlight.html +1 -1
  72. data/docs/doc/Doing/StringNormalize.html +1 -1
  73. data/docs/doc/Doing/StringQuery.html +1 -1
  74. data/docs/doc/Doing/StringTags.html +1 -1
  75. data/docs/doc/Doing/StringTransform.html +1 -1
  76. data/docs/doc/Doing/StringTruncate.html +1 -1
  77. data/docs/doc/Doing/StringURL.html +1 -1
  78. data/docs/doc/Doing/SymbolNormalize.html +1 -1
  79. data/docs/doc/Doing/TaskPaperExport.html +1 -1
  80. data/docs/doc/Doing/TemplateExport.html +1 -1
  81. data/docs/doc/Doing/TemplateString.html +1 -1
  82. data/docs/doc/Doing/TimingImport.html +1 -1
  83. data/docs/doc/Doing/Types.html +1 -1
  84. data/docs/doc/Doing/Util/Backup.html +1 -1
  85. data/docs/doc/Doing/Util.html +2 -2
  86. data/docs/doc/Doing/Version.html +1 -1
  87. data/docs/doc/Doing/WWID.html +1 -1
  88. data/docs/doc/Doing.html +3 -3
  89. data/docs/doc/FalseClass.html +1 -1
  90. data/docs/doc/GLI/Commands/Help.html +1 -1
  91. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +1 -1
  92. data/docs/doc/GLI/Commands.html +1 -1
  93. data/docs/doc/GLI.html +1 -1
  94. data/docs/doc/Hash.html +1 -1
  95. data/docs/doc/Numeric.html +1 -1
  96. data/docs/doc/Object.html +1 -1
  97. data/docs/doc/PhraseParser/Operator.html +1 -1
  98. data/docs/doc/PhraseParser/PhraseClause.html +1 -1
  99. data/docs/doc/PhraseParser/Query.html +1 -1
  100. data/docs/doc/PhraseParser/QueryParser.html +1 -1
  101. data/docs/doc/PhraseParser/QueryTransformer.html +1 -1
  102. data/docs/doc/PhraseParser/TermClause.html +1 -1
  103. data/docs/doc/PhraseParser.html +1 -1
  104. data/docs/doc/Status.html +1 -1
  105. data/docs/doc/String.html +2 -2
  106. data/docs/doc/Symbol.html +1 -1
  107. data/docs/doc/Time.html +1 -1
  108. data/docs/doc/TrueClass.html +1 -1
  109. data/docs/doc/_index.html +12 -5
  110. data/docs/doc/class_list.html +1 -1
  111. data/docs/doc/file.README.html +2 -2
  112. data/docs/doc/index.html +2 -2
  113. data/docs/doc/method_list.html +682 -626
  114. data/docs/doc/top-level-namespace.html +1 -1
  115. data/doing.rdoc +2 -2
  116. data/doing.ts +5911 -0
  117. data/export.doing +0 -0
  118. data/lib/completion/_doing.zsh +31 -31
  119. data/lib/completion/doing.ts +4942 -0
  120. data/lib/doing/completion/fig_completion.rb +121 -0
  121. data/lib/doing/completion.rb +15 -5
  122. data/lib/doing/plugins/export/doing_export.rb +0 -2
  123. data/lib/doing/version.rb +1 -1
  124. data/lib/doing/wwid/interactive.rb +5 -1
  125. data/lib/doing/wwid/modify.rb +8 -11
  126. metadata +8 -2
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Doing
4
+ module Completion
5
+ class ::String
6
+ def sanitize
7
+ gsub(/"/, '\"')
8
+ end
9
+ end
10
+
11
+ # Generate completions for zsh
12
+ class FigCompletions
13
+ attr_accessor :commands, :global_options
14
+
15
+ def generate_helpers
16
+ out=<<~EOFUNCTIONS
17
+ const completionSpec: Fig.Spec = {
18
+ name: "doing",
19
+ description: "A CLI for a What Was I Doing system",
20
+ subcommands: [
21
+ #{generate_subcommand_completions.join("\n ")}
22
+ ],
23
+ };
24
+ export default completionSpec;
25
+ EOFUNCTIONS
26
+ @bar.advance(status: '✅')
27
+ @bar.finish
28
+ out
29
+ end
30
+
31
+ def generate_subcommand_completions
32
+ out = []
33
+ indent = ' '
34
+ @commands.each do |cmd|
35
+ cmd[:commands].each do |c|
36
+ out << <<~EOCOMMAND
37
+ {
38
+ #{indent}name: "#{c}",
39
+ #{indent}description: "#{cmd[:description].sanitize}",
40
+ #{indent}#{generate_subcommand_option_completions(cmd)}
41
+ },
42
+ EOCOMMAND
43
+ end
44
+ end
45
+
46
+ out
47
+ end
48
+
49
+ def generate_subcommand_option_completions(cmd, indent: ' ')
50
+ out = []
51
+
52
+ @bar.advance(status: cmd[:commands].first)
53
+
54
+ data = Completion.get_help_sections(cmd[:commands].first)
55
+
56
+ option_arr = []
57
+
58
+ if data[:command_options]
59
+ Completion.parse_options(data[:command_options]).each do |option|
60
+ next if option.nil?
61
+
62
+ arg = ''
63
+
64
+ if option[:arg]
65
+ arg =<<~EOARG
66
+ args: {
67
+ #{indent} name: "#{option[:arg]}",
68
+ #{indent} description: "#{option[:arg]}",
69
+ #{indent} },
70
+ EOARG
71
+ end
72
+
73
+ if option[:short]
74
+ opt_data =<<~EOOPT
75
+ {
76
+ #{indent} name: ["-#{option[:short]}", "--#{option[:long]}"],
77
+ #{indent} description: "#{option[:description].sanitize}",
78
+ #{indent} #{arg}
79
+ #{indent}},
80
+ EOOPT
81
+ else
82
+ opt_data = <<~EOOPT
83
+ {
84
+ #{indent} name: ["--#{option[:long]}"],
85
+ #{indent} description: "#{option[:description].sanitize}",
86
+ #{indent} #{arg}
87
+ #{indent}},
88
+ EOOPT
89
+ end
90
+
91
+ option_arr << opt_data
92
+
93
+ end
94
+
95
+ cmd_opts = <<~EOCMD
96
+ options: [
97
+ #{indent}#{option_arr.join("\n#{indent}")}
98
+ ],
99
+ EOCMD
100
+ out << cmd_opts
101
+ end
102
+
103
+ out.join("\n")
104
+ end
105
+
106
+ def initialize
107
+ data = Completion.get_help_sections
108
+ @global_options = Completion.parse_options(data[:global_options])
109
+ @commands = Completion.parse_commands(data[:commands])
110
+ @bar = TTY::ProgressBar.new(" \033[0;0;33mGenerating Fig completions: \033[0;35;40m[:bar] :status\033[0m", total: @commands.count + 1, bar_format: :square, hide_cursor: true, status: 'processing subcommands')
111
+ width = TTY::Screen.columns - 45
112
+ @bar.resize(width)
113
+ end
114
+
115
+ def generate_completions
116
+ @bar.start
117
+ generate_helpers
118
+ end
119
+ end
120
+ end
121
+ end
@@ -6,6 +6,7 @@ require_relative 'completion/completion_string'
6
6
  require_relative 'completion/fish_completion'
7
7
  require_relative 'completion/zsh_completion'
8
8
  require_relative 'completion/bash_completion'
9
+ require_relative 'completion/fig_completion'
9
10
 
10
11
  module Doing
11
12
  # Completion script generator
@@ -15,8 +16,8 @@ module Doing
15
16
  COMMAND_RX = /^(?<cmd>[^, \t]+)(?<alias>(?:, [^, \t]+)*)?\s+- (?<desc>.*?)$/.freeze
16
17
 
17
18
  class << self
18
- def get_help_sections(command = '')
19
- res = `doing help #{command}`.strip
19
+ def get_help_sections(command = "")
20
+ res = `doing help #{command}|command cat`.strip
20
21
  scanned = res.scan(SECTIONS_RX)
21
22
  sections = {}
22
23
  scanned.each do |sect|
@@ -85,7 +86,7 @@ module Doing
85
86
  type = normalize_type(type)
86
87
  raise InvalidArgument, 'Unrecognized shell specified' if type == :invalid
87
88
 
88
- return %i[zsh bash fish].each { |t| link_default(t) } if type == :all
89
+ return %i[zsh bash fish fig].each { |t| link_default(t) } if type == :all
89
90
 
90
91
  install_builtin(type)
91
92
 
@@ -98,6 +99,7 @@ module Doing
98
99
 
99
100
  if File.exist?(File.join(default_dir, default_filenames[type]))
100
101
  return unless Doing::Prompt.yn("Update #{type} completion script", default_response: 'n')
102
+
101
103
  end
102
104
 
103
105
  FileUtils.cp(src, default_dir)
@@ -106,6 +108,8 @@ module Doing
106
108
 
107
109
  def normalize_type(type)
108
110
  case type.to_s
111
+ when /^fig/i
112
+ :fig
109
113
  when /^f/i
110
114
  :fish
111
115
  when /^b/i
@@ -123,6 +127,8 @@ module Doing
123
127
 
124
128
  def generate_type(type)
125
129
  generator = case type.to_s
130
+ when /^fig/i
131
+ FigCompletions.new
126
132
  when /^f/i
127
133
  FishCompletions.new
128
134
  when /^b/i
@@ -149,7 +155,7 @@ module Doing
149
155
  end
150
156
 
151
157
  def default_filenames
152
- { zsh: '_doing.zsh', bash: 'doing.bash', fish: 'doing.fish' }
158
+ { zsh: '_doing.zsh', bash: 'doing.bash', fish: 'doing.fish', fig: 'doing.ts' }
153
159
  end
154
160
 
155
161
  def default_file(type)
@@ -188,6 +194,8 @@ module Doing
188
194
  Doing.logger.warn('File written:', 'zsh completions written to lib/completion/_doing.zsh')
189
195
  generate_completion(type: 'bash', file: 'lib/completion/doing.bash', link: false)
190
196
  Doing.logger.warn('File written:', 'bash completions written to lib/completion/doing.bash')
197
+ generate_completion(type: 'fig', file: 'lib/completion/doing.ts', link: false)
198
+ Doing.logger.warn('File written:', 'Fig completions written to lib/completion/doing.ts')
191
199
  end
192
200
 
193
201
  def link_completion_type(type, file)
@@ -195,8 +203,9 @@ module Doing
195
203
  case type.to_s
196
204
  when /^b/i
197
205
  unless dir =~ %r{(\.bash_it/completion|bash_completion/completions)}
198
- link_completion(file, ['~/.bash_it/completion/enabled', '/usr/share/bash_completion/completions'], 'doing.bash')
206
+ link_completion(file, ['~/.bash_it/completion/enabled', '/usr/share/bash-completion/completions', '/usr/share/bash_completion/completions'], 'doing.bash')
199
207
  end
208
+ when /^fig/i
200
209
  when /^f/i
201
210
  link_completion(file, ['~/.config/fish/completions'], 'doing.fish') unless dir =~ %r{.config/fish/completions}
202
211
  when /^z/i
@@ -214,6 +223,7 @@ module Doing
214
223
 
215
224
  targets.each do |target|
216
225
  next unless File.directory?(File.expand_path(target))
226
+
217
227
  found = true
218
228
 
219
229
  target_file = File.join(File.expand_path(target), filename)
@@ -6,8 +6,6 @@
6
6
  # url: https://brettterpstra.com
7
7
  module Doing
8
8
  class DoingExport
9
- include Doing::Util
10
-
11
9
  def self.settings
12
10
  {
13
11
  trigger: 'doing'
data/lib/doing/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Doing
2
- VERSION = '2.1.47'
2
+ VERSION = '2.1.52'
3
3
  end
@@ -102,6 +102,9 @@ module Doing
102
102
  to_do = choice.strip.split(/\n/).map(&:downcase)
103
103
 
104
104
  to_do.each do |action|
105
+ action = 'resume' if action =~ /^resume/i
106
+ action = 'reset' if action =~ /^begin/i
107
+
105
108
  case action
106
109
  when /(resume|reset|autotag|archive|delete|finish|cancel|flag)/
107
110
  opt[action.to_sym] = true
@@ -355,7 +358,8 @@ module Doing
355
358
  def verify_duration(date, finish_date, title: nil)
356
359
  max_elapsed = Doing.setting('interaction.confirm_longer_than', 0)
357
360
  max_elapsed = max_elapsed.chronify_qty if max_elapsed.is_a?(String)
358
- date = date.chronify(guess: :end, context: :today) if finish_date.is_a?(String)
361
+ date = date.chronify(guess: :end, context: :today) if date.is_a?(String)
362
+ finish_date = finish_date.chronify(guess: :end, context: :today) if finish_date.is_a?(String)
359
363
 
360
364
  elapsed = finish_date - date
361
365
 
@@ -39,7 +39,8 @@ module Doing
39
39
 
40
40
  if opt[:done] && entry.should_finish?
41
41
  if entry.should_time?
42
- entry.tag('done', value: opt[:done])
42
+ finish = opt[:done].is_a?(String) ? opt[:done].chronify(guess: :end, context: :today) : opt[:done]
43
+ entry.tag('done', value: finish)
43
44
  else
44
45
  entry.tag('done')
45
46
  end
@@ -47,15 +48,11 @@ module Doing
47
48
 
48
49
  entry.note = note
49
50
 
50
- items = @content.clone
51
51
  if opt[:timed]
52
- items.reverse!
53
- items.each_with_index do |i, x|
54
- next if i.title =~ / @done/
55
-
56
- finish_date = verify_duration(i.date, opt[:back], title: i.title)
57
- items[x].tag('done', value: finish_date.strftime('%F %R'))
58
- break
52
+ last_item = last_entry({ section: section })
53
+ if last_item.tags?(['done'], :not)
54
+ finish_date = verify_duration(last_item.date, opt[:back], title: last_item.title)
55
+ last_item.tag('done', value: finish_date.strftime('%F %R'))
59
56
  end
60
57
  end
61
58
 
@@ -103,7 +100,7 @@ module Doing
103
100
  def repeat_item(item, opt)
104
101
  opt ||= {}
105
102
  old_item = item.clone
106
- if item.should_finish?
103
+ if item.unfinished? && item.should_finish?
107
104
  if item.should_time?
108
105
  finish_date = verify_duration(item.date, Time.now, title: item.title)
109
106
  item.title.tag!('done', value: finish_date.strftime('%F %R'))
@@ -563,7 +560,7 @@ module Doing
563
560
  count = opt[:count] || 0
564
561
  tags = opt[:tags] || []
565
562
  bool = opt[:bool] || :and
566
- label = opt[:label] || true
563
+ label = opt[:label]
567
564
 
568
565
  section = guess_section(section)
569
566
  destination = guess_section(destination)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doing
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.47
4
+ version: 2.1.52
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-26 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: github-markup
@@ -503,6 +503,7 @@ files:
503
503
  - docs/doc/Doing/Color.html
504
504
  - docs/doc/Doing/Completion.html
505
505
  - docs/doc/Doing/Completion/BashCompletions.html
506
+ - docs/doc/Doing/Completion/FigCompletions.html
506
507
  - docs/doc/Doing/Completion/FishCompletions.html
507
508
  - docs/doc/Doing/Completion/StringUtils.html
508
509
  - docs/doc/Doing/Completion/ZshCompletions.html
@@ -510,6 +511,7 @@ files:
510
511
  - docs/doc/Doing/Content.html
511
512
  - docs/doc/Doing/DayOneRenderer.html
512
513
  - docs/doc/Doing/DayoneExport.html
514
+ - docs/doc/Doing/DoingExport.html
513
515
  - docs/doc/Doing/DoingImport.html
514
516
  - docs/doc/Doing/Entry.html
515
517
  - docs/doc/Doing/Errors.html
@@ -614,7 +616,9 @@ files:
614
616
  - docs/index.md
615
617
  - doing.gemspec
616
618
  - doing.rdoc
619
+ - doing.ts
617
620
  - example_plugin.rb
621
+ - export.doing
618
622
  - generate_completions.sh
619
623
  - img/doing-colors.jpg
620
624
  - img/doing-printf-wrap-800.jpg
@@ -622,6 +626,7 @@ files:
622
626
  - lib/completion/_doing.zsh
623
627
  - lib/completion/doing.bash
624
628
  - lib/completion/doing.fish
629
+ - lib/completion/doing.ts
625
630
  - lib/doing.rb
626
631
  - lib/doing/add_options.rb
627
632
  - lib/doing/array/array.rb
@@ -643,6 +648,7 @@ files:
643
648
  - lib/doing/completion.rb
644
649
  - lib/doing/completion/bash_completion.rb
645
650
  - lib/doing/completion/completion_string.rb
651
+ - lib/doing/completion/fig_completion.rb
646
652
  - lib/doing/completion/fish_completion.rb
647
653
  - lib/doing/completion/zsh_completion.rb
648
654
  - lib/doing/configuration.rb