doing 2.1.89 → 2.1.91

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 (248) hide show
  1. checksums.yaml +4 -4
  2. data/.irbrc +2 -0
  3. data/.rubocop.yml +1 -0
  4. data/.rubocop_todo.yml +251 -0
  5. data/CHANGELOG.md +26 -0
  6. data/Gemfile +2 -0
  7. data/Gemfile.lock +1 -1
  8. data/README.md +1 -1
  9. data/Rakefile +5 -3
  10. data/bin/commands/changes.rb +3 -1
  11. data/bin/commands/choose.rb +2 -0
  12. data/bin/commands/colors.rb +5 -3
  13. data/bin/commands/commands_accepting.rb +3 -3
  14. data/bin/commands/completion.rb +2 -1
  15. data/bin/commands/config.rb +8 -6
  16. data/bin/commands/done.rb +19 -12
  17. data/bin/commands/finish.rb +4 -2
  18. data/bin/commands/grep.rb +9 -5
  19. data/bin/commands/import.rb +14 -11
  20. data/bin/commands/install_fzf.rb +4 -2
  21. data/bin/commands/last.rb +31 -27
  22. data/bin/commands/meanwhile.rb +6 -2
  23. data/bin/commands/note.rb +6 -3
  24. data/bin/commands/now.rb +2 -0
  25. data/bin/commands/open.rb +6 -1
  26. data/bin/commands/plugins.rb +2 -0
  27. data/bin/commands/recent.rb +47 -33
  28. data/bin/commands/reset.rb +7 -3
  29. data/bin/commands/rotate.rb +6 -3
  30. data/bin/commands/sections.rb +3 -3
  31. data/bin/commands/select.rb +2 -0
  32. data/bin/commands/show.rb +24 -20
  33. data/bin/commands/since.rb +10 -3
  34. data/bin/commands/tag.rb +18 -16
  35. data/bin/commands/tag_dir.rb +5 -2
  36. data/bin/commands/tags.rb +17 -17
  37. data/bin/commands/template.rb +8 -2
  38. data/bin/commands/today.rb +10 -2
  39. data/bin/commands/undo.rb +2 -0
  40. data/bin/commands/update.rb +9 -7
  41. data/bin/commands/view.rb +11 -8
  42. data/bin/commands/views.rb +2 -0
  43. data/bin/commands/yesterday.rb +6 -1
  44. data/bin/doing +54 -57
  45. data/docs/doc/Array.html +3 -3
  46. data/docs/doc/BooleanTermParser/Clause.html +3 -3
  47. data/docs/doc/BooleanTermParser/Operator.html +3 -3
  48. data/docs/doc/BooleanTermParser/Query.html +3 -3
  49. data/docs/doc/BooleanTermParser/QueryParser.html +3 -3
  50. data/docs/doc/BooleanTermParser/QueryTransformer.html +3 -3
  51. data/docs/doc/BooleanTermParser.html +3 -3
  52. data/docs/doc/Doing/ArrayCleanup.html +3 -3
  53. data/docs/doc/Doing/ArrayNestedHash.html +3 -3
  54. data/docs/doc/Doing/ArrayTags.html +9 -9
  55. data/docs/doc/Doing/ByDayExport.html +3 -3
  56. data/docs/doc/Doing/CSVExport.html +4 -4
  57. data/docs/doc/Doing/CalendarImport.html +4 -4
  58. data/docs/doc/Doing/Change.html +3 -3
  59. data/docs/doc/Doing/Changes.html +3 -3
  60. data/docs/doc/Doing/ChronifyArray.html +3 -3
  61. data/docs/doc/Doing/ChronifyNumeric.html +3 -3
  62. data/docs/doc/Doing/ChronifyString.html +6 -6
  63. data/docs/doc/Doing/Color.html +88 -47
  64. data/docs/doc/Doing/Completion/BashCompletions.html +3 -3
  65. data/docs/doc/Doing/Completion/FigCompletions.html +3 -3
  66. data/docs/doc/Doing/Completion/FishCompletions.html +3 -3
  67. data/docs/doc/Doing/Completion/StringUtils.html +3 -3
  68. data/docs/doc/Doing/Completion/ZshCompletions.html +3 -3
  69. data/docs/doc/Doing/Completion.html +5 -5
  70. data/docs/doc/Doing/Configuration.html +6 -6
  71. data/docs/doc/Doing/DayOneRenderer.html +3 -3
  72. data/docs/doc/Doing/DayoneExport.html +4 -4
  73. data/docs/doc/Doing/DoingExport.html +5 -5
  74. data/docs/doc/Doing/DoingImport.html +4 -4
  75. data/docs/doc/Doing/Entry.html +3 -3
  76. data/docs/doc/Doing/Errors/DoingNoTraceError.html +3 -3
  77. data/docs/doc/Doing/Errors/DoingRuntimeError.html +3 -3
  78. data/docs/doc/Doing/Errors/DoingStandardError.html +3 -3
  79. data/docs/doc/Doing/Errors/EmptyInput.html +3 -3
  80. data/docs/doc/Doing/Errors/HistoryLimitError.html +3 -3
  81. data/docs/doc/Doing/Errors/InvalidPlugin.html +3 -3
  82. data/docs/doc/Doing/Errors/MissingBackupFile.html +3 -3
  83. data/docs/doc/Doing/Errors/NoResults.html +3 -3
  84. data/docs/doc/Doing/Errors/PluginException.html +3 -3
  85. data/docs/doc/Doing/Errors/UserCancelled.html +3 -3
  86. data/docs/doc/Doing/Errors/WrongCommand.html +3 -3
  87. data/docs/doc/Doing/Errors.html +3 -3
  88. data/docs/doc/Doing/HTMLExport.html +4 -4
  89. data/docs/doc/Doing/Hooks.html +3 -16
  90. data/docs/doc/Doing/Item.html +4 -4
  91. data/docs/doc/Doing/ItemDates.html +3 -3
  92. data/docs/doc/Doing/ItemQuery.html +3 -3
  93. data/docs/doc/Doing/ItemState.html +3 -3
  94. data/docs/doc/Doing/ItemTags.html +3 -3
  95. data/docs/doc/Doing/Items.html +3 -3
  96. data/docs/doc/Doing/JSONExport.html +4 -4
  97. data/docs/doc/Doing/JSONImport.html +4 -4
  98. data/docs/doc/Doing/Logger.html +183 -3
  99. data/docs/doc/Doing/MarkdownExport.html +4 -4
  100. data/docs/doc/Doing/Note.html +3 -3
  101. data/docs/doc/Doing/Pager.html +54 -58
  102. data/docs/doc/Doing/Plugins.html +3 -3
  103. data/docs/doc/Doing/Prompt.html +4 -4
  104. data/docs/doc/Doing/PromptChoose.html +3 -3
  105. data/docs/doc/Doing/PromptFZF.html +3 -3
  106. data/docs/doc/Doing/PromptInput.html +3 -3
  107. data/docs/doc/Doing/PromptSTD.html +3 -3
  108. data/docs/doc/Doing/PromptYN.html +3 -3
  109. data/docs/doc/Doing/Section.html +3 -3
  110. data/docs/doc/Doing/StringHighlight.html +3 -3
  111. data/docs/doc/Doing/StringNormalize.html +3 -3
  112. data/docs/doc/Doing/StringQuery.html +4 -4
  113. data/docs/doc/Doing/StringTags.html +3 -3
  114. data/docs/doc/Doing/StringTransform.html +3 -3
  115. data/docs/doc/Doing/StringTruncate.html +3 -3
  116. data/docs/doc/Doing/StringURL.html +3 -3
  117. data/docs/doc/Doing/SymbolNormalize.html +5 -5
  118. data/docs/doc/Doing/TaskPaperExport.html +4 -4
  119. data/docs/doc/Doing/TemplateExport.html +5 -5
  120. data/docs/doc/Doing/TemplateString.html +7 -7
  121. data/docs/doc/Doing/TimingImport.html +4 -4
  122. data/docs/doc/Doing/Types.html +3 -3
  123. data/docs/doc/Doing/Util/Backup.html +4 -17
  124. data/docs/doc/Doing/Util.html +56 -61
  125. data/docs/doc/Doing/Version.html +3 -3
  126. data/docs/doc/Doing/WWID.html +6 -4
  127. data/docs/doc/Doing.html +4 -4
  128. data/docs/doc/FalseClass.html +3 -3
  129. data/docs/doc/GLI/Commands/Help.html +5 -5
  130. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +3 -3
  131. data/docs/doc/GLI/Commands.html +3 -3
  132. data/docs/doc/GLI.html +3 -3
  133. data/docs/doc/Hash.html +4 -4
  134. data/docs/doc/Numeric.html +3 -3
  135. data/docs/doc/Object.html +3 -3
  136. data/docs/doc/PhraseParser/Operator.html +3 -3
  137. data/docs/doc/PhraseParser/PhraseClause.html +3 -3
  138. data/docs/doc/PhraseParser/Query.html +3 -3
  139. data/docs/doc/PhraseParser/QueryParser.html +3 -3
  140. data/docs/doc/PhraseParser/QueryTransformer.html +3 -3
  141. data/docs/doc/PhraseParser/TermClause.html +3 -3
  142. data/docs/doc/PhraseParser.html +3 -3
  143. data/docs/doc/Status.html +3 -3
  144. data/docs/doc/String.html +51 -5
  145. data/docs/doc/Symbol.html +3 -3
  146. data/docs/doc/Time.html +3 -3
  147. data/docs/doc/TrueClass.html +3 -3
  148. data/docs/doc/_index.html +4 -4
  149. data/docs/doc/class_list.html +6 -3
  150. data/docs/doc/css/full_list.css +3 -3
  151. data/docs/doc/css/style.css +6 -0
  152. data/docs/doc/file.README.html +4 -4
  153. data/docs/doc/file_list.html +5 -2
  154. data/docs/doc/frames.html +1 -1
  155. data/docs/doc/index.html +4 -4
  156. data/docs/doc/js/app.js +294 -264
  157. data/docs/doc/js/full_list.js +30 -4
  158. data/docs/doc/method_list.html +443 -392
  159. data/docs/doc/top-level-namespace.html +3 -3
  160. data/doing.gemspec +2 -0
  161. data/doing.rdoc +1 -30
  162. data/example_plugin.rb +1 -4
  163. data/lib/completion/_doing.zsh +0 -4
  164. data/lib/completion/doing.bash +0 -11
  165. data/lib/completion/doing.fish +0 -5
  166. data/lib/completion/doing.ts +0 -40
  167. data/lib/doing/add_options.rb +2 -2
  168. data/lib/doing/array/cleanup.rb +2 -0
  169. data/lib/doing/array/nested_hash.rb +2 -0
  170. data/lib/doing/boolean_term_parser.rb +3 -3
  171. data/lib/doing/changelog/changes.rb +4 -5
  172. data/lib/doing/changelog/version.rb +8 -11
  173. data/lib/doing/chronify/array.rb +4 -4
  174. data/lib/doing/chronify/string.rb +5 -4
  175. data/lib/doing/cli_status.rb +7 -2
  176. data/lib/doing/colors.rb +93 -51
  177. data/lib/doing/completion/bash_completion.rb +36 -39
  178. data/lib/doing/completion/completion_string.rb +2 -1
  179. data/lib/doing/completion/fig_completion.rb +33 -33
  180. data/lib/doing/completion/fish_completion.rb +22 -23
  181. data/lib/doing/completion/zsh_completion.rb +5 -5
  182. data/lib/doing/completion.rb +7 -4
  183. data/lib/doing/configuration.rb +21 -13
  184. data/lib/doing/errors.rb +1 -4
  185. data/lib/doing/good.rb +1 -1
  186. data/lib/doing/hash.rb +4 -4
  187. data/lib/doing/help_monkey_patch.rb +1 -1
  188. data/lib/doing/hooks.rb +6 -2
  189. data/lib/doing/item/dates.rb +3 -1
  190. data/lib/doing/item/item.rb +1 -1
  191. data/lib/doing/item/query.rb +14 -14
  192. data/lib/doing/item/state.rb +2 -0
  193. data/lib/doing/logger.rb +113 -45
  194. data/lib/doing/markdown_document_listener.rb +25 -25
  195. data/lib/doing/normalize.rb +1 -1
  196. data/lib/doing/pager.rb +73 -29
  197. data/lib/doing/plugin_manager.rb +4 -5
  198. data/lib/doing/plugins/export/byday.rb +1 -1
  199. data/lib/doing/plugins/export/dayone_export.rb +28 -27
  200. data/lib/doing/plugins/export/doing_export.rb +1 -1
  201. data/lib/doing/plugins/export/html_export.rb +3 -3
  202. data/lib/doing/plugins/export/json_export.rb +4 -5
  203. data/lib/doing/plugins/export/markdown_export.rb +10 -2
  204. data/lib/doing/plugins/export/taskpaper_export.rb +1 -0
  205. data/lib/doing/plugins/export/template_export.rb +110 -107
  206. data/lib/doing/plugins/import/calendar_import.rb +1 -1
  207. data/lib/doing/plugins/import/doing_import.rb +2 -2
  208. data/lib/doing/plugins/import/timing_import.rb +3 -3
  209. data/lib/doing/prompt/choose.rb +5 -6
  210. data/lib/doing/prompt/fzf.rb +3 -2
  211. data/lib/doing/prompt/input.rb +10 -9
  212. data/lib/doing/prompt/yn.rb +9 -11
  213. data/lib/doing/string/tags.rb +7 -4
  214. data/lib/doing/string/transform.rb +15 -10
  215. data/lib/doing/string/truncate.rb +1 -0
  216. data/lib/doing/string/url.rb +1 -1
  217. data/lib/doing/template_string.rb +13 -9
  218. data/lib/doing/time.rb +4 -2
  219. data/lib/doing/util.rb +12 -11
  220. data/lib/doing/util_backup.rb +29 -26
  221. data/lib/doing/version.rb +3 -1
  222. data/lib/doing/wwid/display.rb +182 -151
  223. data/lib/doing/wwid/editor.rb +13 -12
  224. data/lib/doing/wwid/filetools.rb +13 -11
  225. data/lib/doing/wwid/filter.rb +41 -40
  226. data/lib/doing/wwid/guess.rb +6 -8
  227. data/lib/doing/wwid/interactive.rb +10 -10
  228. data/lib/doing/wwid/modify.rb +55 -55
  229. data/lib/doing/wwid/timers.rb +4 -5
  230. data/lib/doing/wwid/wwid.rb +0 -0
  231. data/lib/doing/wwid/wwidutil.rb +8 -10
  232. data/lib/examples/commands/wiki.rb +2 -0
  233. data/lib/examples/plugins/capture_thing_import.rb +1 -1
  234. data/lib/examples/plugins/say_export.rb +1 -2
  235. data/lib/examples/plugins/wiki_export/wiki_export.rb +3 -4
  236. data/lib/helpers/fzf/test/test_go.rb +5 -5
  237. data/lib/helpers/threaded_tests.rb +20 -20
  238. data/lib/helpers/threaded_tests_string.rb +2 -0
  239. data/rdoc_to_mmd.rb +5 -4
  240. data/rdocfixer.rb +1 -2
  241. data/scripts/deploy.rb +3 -4
  242. data/scripts/generate_bash_completions.rb +40 -43
  243. data/scripts/generate_fish_completions.rb +17 -15
  244. data/scripts/generate_zsh_completions.rb +9 -7
  245. data/scripts/setting_replace.rb +1 -0
  246. data/scripts/sort_commands.rb +4 -2
  247. data/yard_templates/default/method_details/setup.rb +3 -1
  248. metadata +3 -1
@@ -11,35 +11,33 @@ module Doing
11
11
  out = []
12
12
  logic = []
13
13
 
14
- @commands.each_with_index do |cmd, i|
14
+ @commands.each_with_index do |cmd, _i|
15
15
  @bar.advance(status: cmd[:commands].first)
16
16
 
17
17
  data = Completion.get_help_sections(cmd[:commands].first)
18
18
 
19
19
  arg = data[:synopsis].join(' ').strip.split(/ /).last
20
- case arg
21
- when /(path|file)/i
22
- type = :file
23
- when /sect/i
24
- type = 'sections'
25
- when /view/i
26
- type = 'views'
20
+ type = case arg
21
+ when /(path|file)/i
22
+ :file
23
+ when /sect/i
24
+ 'sections'
25
+ when /view/i
26
+ 'views'
27
+ end
28
+
29
+ next unless data[:command_options]
30
+
31
+ options = Completion.parse_options(data[:command_options])
32
+ out << command_function(cmd[:commands].first, options, type)
33
+
34
+ if first
35
+ op = 'if'
36
+ first = false
27
37
  else
28
- type = nil
29
- end
30
-
31
- if data[:command_options]
32
- options = Completion.parse_options(data[:command_options])
33
- out << command_function(cmd[:commands].first, options, type)
34
-
35
- if first
36
- op = 'if'
37
- first = false
38
- else
39
- op = 'elif'
40
- end
41
- logic << %(#{op} [[ $last =~ (#{cmd[:commands].join('|')}) ]]; then _doing_#{cmd[:commands].first})
38
+ op = 'elif'
42
39
  end
40
+ logic << %(#{op} [[ $last =~ (#{cmd[:commands].join('|')}) ]]; then _doing_#{cmd[:commands].first})
43
41
  end
44
42
 
45
43
  out << <<~EOFUNC
@@ -71,25 +69,23 @@ module Doing
71
69
  short_options << o[:short] if o[:short]
72
70
  end
73
71
 
74
- long = long_options.map! {|o| "--#{o}"}.join(' ')
75
- short = short_options.map! {|o| "-#{o}"}.join(' ')
72
+ long = long_options.map! { |o| "--#{o}" }.join(' ')
73
+ short = short_options.map! { |o| "-#{o}" }.join(' ')
76
74
  words = ''
77
75
  logic = ''
78
- words, logic = get_words(type) if type && type.is_a?(String)
79
-
80
- func = <<~ENDFUNC
81
- _doing_#{command}() {
82
- #{words}
83
- if [[ "$token" == --* ]]; then
84
- COMPREPLY=( $( compgen -W '#{long}' -- $token ) )
85
- elif [[ "$token" == -* ]]; then
86
- COMPREPLY=( $( compgen -W '#{short} #{long}' -- $token ) )
87
- #{logic}
88
- fi
89
- }
76
+ words, logic = get_words(type) if type.is_a?(String)
77
+
78
+ <<~ENDFUNC
79
+ _doing_#{command}() {
80
+ #{words}
81
+ if [[ "$token" == --* ]]; then
82
+ COMPREPLY=( $( compgen -W '#{long}' -- $token ) )
83
+ elif [[ "$token" == -* ]]; then
84
+ COMPREPLY=( $( compgen -W '#{short} #{long}' -- $token ) )
85
+ #{logic}
86
+ fi
87
+ }
90
88
  ENDFUNC
91
-
92
- func
93
89
  end
94
90
 
95
91
  def get_words(type)
@@ -126,7 +122,8 @@ module Doing
126
122
  data = Completion.get_help_sections
127
123
  @global_options = Completion.parse_options(data[:global_options])
128
124
  @commands = Completion.parse_commands(data[:commands])
129
- @bar = TTY::ProgressBar.new("\033[0;0;33mGenerating Bash completions: \033[0;35;40m[:bar] :status\033[0m", total: @commands.count + 1, bar_format: :square, hide_cursor: true, status: 'Reading subcommands')
125
+ @bar = TTY::ProgressBar.new("\033[0;0;33mGenerating Bash completions: \033[0;35;40m[:bar] :status\033[0m",
126
+ total: @commands.count + 1, bar_format: :square, hide_cursor: true, status: 'Reading subcommands')
130
127
  width = TTY::Screen.columns - 45
131
128
  @bar.resize(width)
132
129
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Doing
2
4
  module Completion
3
5
  module StringUtils
4
-
5
6
  ##
6
7
  ## Get short description for command completion
7
8
  ##
@@ -13,15 +13,15 @@ module Doing
13
13
  attr_accessor :commands, :global_options
14
14
 
15
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;
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
25
  EOFUNCTIONS
26
26
  @bar.advance(status: '✅')
27
27
  @bar.finish
@@ -62,34 +62,33 @@ module Doing
62
62
  arg = ''
63
63
 
64
64
  if option[:arg]
65
- arg =<<~EOARG
66
- args: {
67
- #{indent} name: "#{option[:arg]}",
68
- #{indent} description: "#{option[:arg]}",
69
- #{indent} },
65
+ arg = <<~EOARG
66
+ args: {
67
+ #{indent} name: "#{option[:arg]}",
68
+ #{indent} description: "#{option[:arg]}",
69
+ #{indent} },
70
70
  EOARG
71
71
  end
72
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
73
+ opt_data = if option[:short]
74
+ <<~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
+ <<~EOOPT
83
+ {
84
+ #{indent} name: ["--#{option[:long]}"],
85
+ #{indent} description: "#{option[:description].sanitize}",
86
+ #{indent} #{arg}
87
+ #{indent}},
88
+ EOOPT
89
+ end
90
90
 
91
91
  option_arr << opt_data
92
-
93
92
  end
94
93
 
95
94
  cmd_opts = <<~EOCMD
@@ -107,7 +106,8 @@ module Doing
107
106
  data = Completion.get_help_sections
108
107
  @global_options = Completion.parse_options(data[:global_options])
109
108
  @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')
109
+ @bar = TTY::ProgressBar.new(" \033[0;0;33mGenerating Fig completions: \033[0;35;40m[:bar] :status\033[0m",
110
+ total: @commands.count + 1, bar_format: :square, hide_cursor: true, status: 'processing subcommands')
111
111
  width = TTY::Screen.columns - 45
112
112
  @bar.resize(width)
113
113
  end
@@ -4,7 +4,6 @@ module Doing
4
4
  module Completion
5
5
  # Generate completions for Fish
6
6
  class FishCompletions
7
-
8
7
  attr_accessor :commands, :global_options
9
8
 
10
9
  def generate_helpers
@@ -152,7 +151,6 @@ module Doing
152
151
  end
153
152
 
154
153
  def generate_subcommand_option_completions
155
-
156
154
  out = []
157
155
  need_export = []
158
156
  need_bool = []
@@ -163,32 +161,32 @@ module Doing
163
161
  need_age = []
164
162
  need_section = []
165
163
 
166
- @commands.each_with_index do |cmd, i|
164
+ @commands.each_with_index do |cmd, _i|
167
165
  @bar.advance(status: cmd[:commands].first)
168
166
  data = Completion.get_help_sections(cmd[:commands].first)
169
167
 
170
168
  if data[:synopsis].join(' ').strip.split(/ /).last =~ /(path|file)/i
171
- out << "complete -c doing -F -n '__fish_doing_using_command #{cmd[:commands].join(" ")}'"
169
+ out << "complete -c doing -F -n '__fish_doing_using_command #{cmd[:commands].join(' ')}'"
172
170
  end
173
171
 
174
- if data[:command_options]
175
- Completion.parse_options(data[:command_options]).each do |option|
176
- next if option.nil?
177
-
178
- arg = option[:arg] ? '-r' : ''
179
- short = option[:short] ? "-s #{option[:short]}" : ''
180
- long = option[:long] ? "-l #{option[:long]}" : ''
181
- out << "complete -c doing #{long} #{short} -f #{arg} -n '__fish_doing_using_command #{cmd[:commands].join(' ')}' -d #{Shellwords.escape(option[:description])}"
182
-
183
- need_export.concat(cmd[:commands]) if option[:long] == 'output'
184
- need_bool.concat(cmd[:commands]) if option[:long] == 'bool'
185
- need_case.concat(cmd[:commands]) if option[:long] == 'case'
186
- need_sort.concat(cmd[:commands]) if option[:long] == 'sort'
187
- need_tag_sort.concat(cmd[:commands]) if option[:long] == 'tag_sort'
188
- need_tag_order.concat(cmd[:commands]) if option[:long] == 'tag_order'
189
- need_age.concat(cmd[:commands]) if option[:long] == 'age'
190
- need_section.concat(cmd[:commands]) if option[:long] == 'section'
191
- end
172
+ next unless data[:command_options]
173
+
174
+ Completion.parse_options(data[:command_options]).each do |option|
175
+ next if option.nil?
176
+
177
+ arg = option[:arg] ? '-r' : ''
178
+ short = option[:short] ? "-s #{option[:short]}" : ''
179
+ long = option[:long] ? "-l #{option[:long]}" : ''
180
+ out << "complete -c doing #{long} #{short} -f #{arg} -n '__fish_doing_using_command #{cmd[:commands].join(' ')}' -d #{Shellwords.escape(option[:description])}"
181
+
182
+ need_export.concat(cmd[:commands]) if option[:long] == 'output'
183
+ need_bool.concat(cmd[:commands]) if option[:long] == 'bool'
184
+ need_case.concat(cmd[:commands]) if option[:long] == 'case'
185
+ need_sort.concat(cmd[:commands]) if option[:long] == 'sort'
186
+ need_tag_sort.concat(cmd[:commands]) if option[:long] == 'tag_sort'
187
+ need_tag_order.concat(cmd[:commands]) if option[:long] == 'tag_order'
188
+ need_age.concat(cmd[:commands]) if option[:long] == 'age'
189
+ need_section.concat(cmd[:commands]) if option[:long] == 'section'
192
190
  end
193
191
  end
194
192
 
@@ -232,7 +230,8 @@ module Doing
232
230
  data = Completion.get_help_sections
233
231
  @global_options = Completion.parse_options(data[:global_options])
234
232
  @commands = Completion.parse_commands(data[:commands])
235
- @bar = TTY::ProgressBar.new("\033[0;0;33mGenerating Fish completions: \033[0;35;40m[:bar] :status\033[0m", total: @commands.count + 1, bar_format: :square, hide_cursor: true, status: 'processing subcommands')
233
+ @bar = TTY::ProgressBar.new("\033[0;0;33mGenerating Fish completions: \033[0;35;40m[:bar] :status\033[0m",
234
+ total: @commands.count + 1, bar_format: :square, hide_cursor: true, status: 'processing subcommands')
236
235
  width = TTY::Screen.columns - 45
237
236
  @bar.resize(width)
238
237
  end
@@ -13,7 +13,7 @@ module Doing
13
13
  attr_accessor :commands, :global_options
14
14
 
15
15
  def generate_helpers
16
- out=<<~EOFUNCTIONS
16
+ out = <<~EOFUNCTIONS
17
17
  compdef _doing doing
18
18
 
19
19
  function _doing() {
@@ -49,7 +49,7 @@ module Doing
49
49
 
50
50
  def generate_subcommand_completions
51
51
  out = []
52
- @commands.each_with_index do |cmd, i|
52
+ @commands.each_with_index do |cmd, _i|
53
53
  cmd[:commands].each do |c|
54
54
  out << "'#{c}:#{cmd[:description].gsub(/'/, '\\\'')}'"
55
55
  end
@@ -58,10 +58,9 @@ module Doing
58
58
  end
59
59
 
60
60
  def generate_subcommand_option_completions(indent: ' ')
61
-
62
61
  out = []
63
62
 
64
- @commands.each_with_index do |cmd, i|
63
+ @commands.each_with_index do |cmd, _i|
65
64
  @bar.advance(status: cmd[:commands].first)
66
65
 
67
66
  data = Completion.get_help_sections(cmd[:commands].first)
@@ -93,7 +92,8 @@ module Doing
93
92
  data = Completion.get_help_sections
94
93
  @global_options = Completion.parse_options(data[:global_options])
95
94
  @commands = Completion.parse_commands(data[:commands])
96
- @bar = TTY::ProgressBar.new(" \033[0;0;33mGenerating Zsh completions: \033[0;35;40m[:bar] :status\033[0m", total: @commands.count + 1, bar_format: :square, hide_cursor: true, status: 'processing subcommands')
95
+ @bar = TTY::ProgressBar.new(" \033[0;0;33mGenerating Zsh completions: \033[0;35;40m[:bar] :status\033[0m",
96
+ total: @commands.count + 1, bar_format: :square, hide_cursor: true, status: 'processing subcommands')
97
97
  width = TTY::Screen.columns - 45
98
98
  @bar.resize(width)
99
99
  end
@@ -16,7 +16,7 @@ module Doing
16
16
  COMMAND_RX = /^(?<cmd>[^, \t]+)(?<alias>(?:, [^, \t]+)*)?\s+- (?<desc>.*?)$/.freeze
17
17
 
18
18
  class << self
19
- def get_help_sections(command = "")
19
+ def get_help_sections(command = '')
20
20
  res = `doing help #{command}|command cat`.strip
21
21
  scanned = res.scan(SECTIONS_RX)
22
22
  sections = {}
@@ -97,8 +97,10 @@ module Doing
97
97
  FileUtils.mkdir_p(default_dir)
98
98
  src = File.expand_path(File.join(File.dirname(__FILE__), '..', 'completion', default_filenames[type]))
99
99
 
100
- if File.exist?(File.join(default_dir, default_filenames[type]))
101
- return unless Doing::Prompt.yn("Update #{type} completion script", default_response: 'n')
100
+ if File.exist?(File.join(default_dir,
101
+ default_filenames[type])) && !Doing::Prompt.yn("Update #{type} completion script",
102
+ default_response: 'n')
103
+ return
102
104
 
103
105
  end
104
106
 
@@ -203,7 +205,8 @@ module Doing
203
205
  case type.to_s
204
206
  when /^b/i
205
207
  unless dir =~ %r{(\.bash_it/completion|bash_completion/completions)}
206
- link_completion(file, ['~/.bash_it/completion/enabled', '/usr/share/bash-completion/completions', '/usr/share/bash_completion/completions'], 'doing.bash')
208
+ link_completion(file,
209
+ ['~/.bash_it/completion/enabled', '/usr/share/bash-completion/completions', '/usr/share/bash_completion/completions'], 'doing.bash')
207
210
  end
208
211
  when /^fig/i
209
212
  when /^f/i
@@ -116,7 +116,7 @@ module Doing
116
116
  'interaction' => {
117
117
  'confirm_longer_than' => '5h'
118
118
  }
119
- }
119
+ }.freeze
120
120
 
121
121
  def initialize(file = nil, options: {})
122
122
  @config_file = file.nil? ? default_config_file : File.expand_path(file)
@@ -237,11 +237,9 @@ module Doing
237
237
  if new_cfg.nil?
238
238
  return real_path if real_path[-1] == path && real_path.count == element_count
239
239
 
240
- if distance < 5 && !create
241
- return resolve_key_path(keypath, create: false, distance: distance + 1)
242
- else
243
- return nil unless create
244
- end
240
+ return resolve_key_path(keypath, create: false, distance: distance + 1) if distance < 5 && !create
241
+
242
+ return nil unless create
245
243
 
246
244
  resolved = real_path.count.positive? ? "Resolved #{real_path.join('.')}, but " : ''
247
245
  Doing.logger.log_now(:warn, "#{resolved}#{path} is unknown")
@@ -251,13 +249,19 @@ module Doing
251
249
  raise InvalidArgument, 'Invalid key path' unless res
252
250
 
253
251
  real_path.push(path).concat(paths).compact!
254
- Doing.logger.debug('Config:', "translated key path #{keypath} to #{real_path.join('.')}") unless keypath == real_path.join('.')
252
+ unless keypath == real_path.join('.')
253
+ Doing.logger.debug('Config:',
254
+ "translated key path #{keypath} to #{real_path.join('.')}")
255
+ end
255
256
  return real_path
256
257
  end
257
258
  cfg = new_cfg
258
259
  end
259
260
  end
260
- Doing.logger.debug('Config:', "translated key path #{keypath} to #{real_path.join('.')}") unless keypath == real_path.join('.')
261
+ unless keypath == real_path.join('.')
262
+ Doing.logger.debug('Config:',
263
+ "translated key path #{keypath} to #{real_path.join('.')}")
264
+ end
261
265
  real_path
262
266
  end
263
267
 
@@ -295,7 +299,8 @@ module Doing
295
299
  #
296
300
  def from(user_config)
297
301
  # Util.deep_merge_hashes(DEFAULTS, Configuration[user_config].stringify_keys)
298
- Configuration[user_config].stringify_keys.deep_merge(DEFAULTS, { extend_existing_arrays: true, sort_merged_arrays: true })
302
+ Configuration[user_config].stringify_keys.deep_merge(DEFAULTS,
303
+ { extend_existing_arrays: true, sort_merged_arrays: true })
299
304
  end
300
305
 
301
306
  ##
@@ -346,7 +351,7 @@ module Doing
346
351
 
347
352
  load_plugins(plugin_config['plugin_path'])
348
353
 
349
- Plugins.plugins.each do |_type, plugins|
354
+ Plugins.plugins.each_value do |plugins|
350
355
  plugins.each do |title, plugin|
351
356
  plugin_config[title] = plugin[:config] if plugin[:config].good?
352
357
  config['export_templates'][title] ||= nil if plugin[:templates] && !plugin[:templates].empty?
@@ -366,7 +371,10 @@ module Doing
366
371
 
367
372
  Hooks.trigger :post_config, self
368
373
 
369
- config = local_config.deep_merge(config, { extend_existing_arrays: true, sort_merged_arrays: true }) unless @ignore_local
374
+ unless @ignore_local
375
+ config = local_config.deep_merge(config,
376
+ { extend_existing_arrays: true, sort_merged_arrays: true })
377
+ end
370
378
  # config = Util.deep_merge_hashes(config, local_config) unless @ignore_local
371
379
 
372
380
  Hooks.trigger :post_local_config, self
@@ -483,13 +491,13 @@ module Doing
483
491
  end
484
492
 
485
493
  begin
486
-
487
494
  user_config = Util.safe_load_file(config_file)
488
495
  raise StandardError, 'Invalid config file format' unless user_config.is_a?(Hash)
489
496
 
490
497
  if user_config.key?('html_template')
491
498
  user_config['export_templates'] ||= {}
492
- user_config['export_templates'].deep_merge(user_config.delete('html_template'), { extend_existing_arrays: true, sort_merged_arrays: true })
499
+ user_config['export_templates'].deep_merge(user_config.delete('html_template'),
500
+ { extend_existing_arrays: true, sort_merged_arrays: true })
493
501
  end
494
502
 
495
503
  user_config['include_notes'] = user_config.delete(':include_notes') if user_config.key?(':include_notes')
data/lib/doing/errors.rb CHANGED
@@ -6,9 +6,7 @@ module Doing
6
6
  def initialize(msg = nil, level: nil, topic: 'Error:', exit_code: 1)
7
7
  level ||= :error
8
8
  Doing.logger.output_results
9
- if msg
10
- Doing.logger.log_now(level, topic, msg)
11
- end
9
+ Doing.logger.log_now(level, topic, msg) if msg
12
10
 
13
11
  Process.exit exit_code
14
12
  end
@@ -52,7 +50,6 @@ module Doing
52
50
  class NoResults < DoingNoTraceError
53
51
  def initialize(msg = 'No results', topic = 'Exited:')
54
52
  super(msg, level: :warn, topic: topic, exit_code: 0)
55
-
56
53
  end
57
54
  end
58
55
 
data/lib/doing/good.rb CHANGED
@@ -18,7 +18,7 @@ module Doing
18
18
  ## has content
19
19
  ##
20
20
  def good?
21
- !nil? && !self&.empty? || false
21
+ !nil? && !empty? || false
22
22
  end
23
23
  end
24
24
 
data/lib/doing/hash.rb CHANGED
@@ -153,7 +153,7 @@ module Doing
153
153
  ## Remove keys with empty values
154
154
  ##
155
155
  def remove_empty
156
- delete_if { |k, v| !v.is_a?(FalseClass) && !v.good? }
156
+ delete_if { |_k, v| !v.is_a?(FalseClass) && !v.good? }
157
157
  end
158
158
 
159
159
  def tag_filter_to_options
@@ -193,9 +193,9 @@ module Doing
193
193
  ## @param to_delete [Array] the keys to delete if key doesn't exist
194
194
  ##
195
195
  def delete_unless_key(key, to_delete)
196
- unless key?(key)
197
- to_delete.each { |k| delete(k) }
198
- end
196
+ return if key?(key)
197
+
198
+ to_delete.each { |k| delete(k) }
199
199
  end
200
200
  end
201
201
  end
@@ -4,7 +4,7 @@ module GLI
4
4
  module Commands
5
5
  # Help Command Monkeypatch for paginated output
6
6
  class Help < Command
7
- def show_help(global_options, options, arguments, out, error)
7
+ def show_help(_global_options, options, arguments, out, error)
8
8
  Doing::Pager.paginate = true
9
9
 
10
10
  command_finder = HelpModules::CommandFinder.new(@app, arguments, error)
data/lib/doing/hooks.rb CHANGED
@@ -40,10 +40,14 @@ module Doing
40
40
  # register a single hook to be called later, internal API
41
41
  def self.register_one(event, priority, &block)
42
42
  unless @registry[event]
43
- raise Doing::Errors::HookUnavailable.new("Invalid hook. Doing only supports #{@registry.keys.inspect}", 'hook', event)
43
+ raise Doing::Errors::HookUnavailable.new("Invalid hook. Doing only supports #{@registry.keys.inspect}", 'hook',
44
+ event)
44
45
  end
45
46
 
46
- raise Doing::Errors::PluginUncallable.new('Hooks must respond to :call', 'hook', event) unless block.respond_to? :call
47
+ unless block.respond_to? :call
48
+ raise Doing::Errors::PluginUncallable.new('Hooks must respond to :call', 'hook',
49
+ event)
50
+ end
47
51
 
48
52
  Doing.logger.debug('Hook Manager:', "Registered #{event} hook") if ENV['DOING_PLUGIN_DEBUG']
49
53
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Doing
2
4
  module ItemDates
3
5
  # def date=(new_date)
@@ -10,7 +12,7 @@ module Doing
10
12
 
11
13
  return nil if @title =~ /(?<=^| )@done\b/
12
14
 
13
- return Time.now - @date
15
+ Time.now - @date
14
16
  end
15
17
 
16
18
  ##
@@ -105,7 +105,7 @@ module Doing
105
105
  when :date
106
106
  output << format('%13s |', @date.relative_date).cyan
107
107
  when :section
108
- output << "#{magenta}(#{white(@section)}#{magenta})"
108
+ output << "#{Color.magenta}(#{Color.white(@section)}#{Color.magenta})"
109
109
  when :title
110
110
  output << @title.white.highlight_tags('cyan')
111
111
  end
@@ -78,8 +78,8 @@ module Doing
78
78
 
79
79
  if search.rx? || matching == :fuzzy
80
80
  rx = search.to_rx(distance: distance, case_type: case_type)
81
- new_title = @title.gsub(rx) { |m| yellow(m) }
82
- new_note.add(@note.to_s.gsub(rx) { |m| yellow(m) })
81
+ new_title = @title.gsub(rx) { |m| Color.yellow(m) }
82
+ new_note.add(@note.to_s.gsub(rx) { |m| Color.yellow(m) })
83
83
  else
84
84
  query = search.strip.to_phrase_query
85
85
 
@@ -89,8 +89,8 @@ module Doing
89
89
  end
90
90
  query[:must].concat(query[:should]).each do |s|
91
91
  rx = Regexp.new(s.wildcard_to_rx, ignore_case(s, case_type))
92
- new_title = @title.gsub(rx) { |m| yellow(m) }
93
- new_note.add(@note.to_s.gsub(rx) { |m| yellow(m) })
92
+ new_title = @title.gsub(rx) { |m| Color.yellow(m) }
93
+ new_note.add(@note.to_s.gsub(rx) { |m| Color.yellow(m) })
94
94
  end
95
95
  end
96
96
 
@@ -448,16 +448,16 @@ module Doing
448
448
  end
449
449
 
450
450
  def value_string_matches?(tag_val, comp, value)
451
- case comp
452
- when /\^=/
453
- tag_val =~ /^#{value.wildcard_to_rx}/i
454
- when /\$=/
455
- tag_val =~ /#{value.wildcard_to_rx}$/i
456
- when %r{==}
457
- tag_val =~ /^#{value.wildcard_to_rx}$/i
458
- else
459
- tag_val =~ /#{value.wildcard_to_rx}/i
460
- end
451
+ tag_val =~ case comp
452
+ when /\^=/
453
+ /^#{value.wildcard_to_rx}/i
454
+ when /\$=/
455
+ /#{value.wildcard_to_rx}$/i
456
+ when /==/
457
+ /^#{value.wildcard_to_rx}$/i
458
+ else
459
+ /#{value.wildcard_to_rx}/i
460
+ end
461
461
  end
462
462
 
463
463
  def value_number_matches?(tag_val, comp, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Doing
2
4
  # State queries for a Doing entry
3
5
  module ItemState