doing 2.1.39 → 2.1.42

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/CHANGELOG.md +67 -0
  4. data/Gemfile.lock +1 -1
  5. data/README.md +1 -1
  6. data/Rakefile +4 -4
  7. data/bin/commands/again.rb +1 -3
  8. data/bin/commands/changes.rb +50 -34
  9. data/bin/commands/commands.rb +77 -52
  10. data/bin/commands/commands_accepting.rb +57 -53
  11. data/bin/commands/config.rb +45 -36
  12. data/bin/commands/done.rb +1 -18
  13. data/bin/commands/finish.rb +90 -59
  14. data/bin/commands/flag.rb +5 -1
  15. data/bin/commands/grep.rb +3 -14
  16. data/bin/commands/last.rb +2 -8
  17. data/bin/commands/meanwhile.rb +13 -6
  18. data/bin/commands/now.rb +151 -107
  19. data/bin/commands/on.rb +8 -18
  20. data/bin/commands/recent.rb +2 -8
  21. data/bin/commands/reset.rb +24 -1
  22. data/bin/commands/select.rb +1 -1
  23. data/bin/commands/show.rb +6 -17
  24. data/bin/commands/since.rb +1 -12
  25. data/bin/commands/tag_dir.rb +49 -15
  26. data/bin/commands/today.rb +2 -13
  27. data/bin/commands/undo.rb +4 -6
  28. data/bin/commands/view.rb +1 -1
  29. data/bin/commands/yesterday.rb +2 -13
  30. data/bin/doing +15 -8
  31. data/{Dockerfile → docker/Dockerfile} +3 -1
  32. data/{Dockerfile-2.6 → docker/Dockerfile-2.6} +2 -2
  33. data/{Dockerfile-2.7 → docker/Dockerfile-2.7} +2 -2
  34. data/{Dockerfile-3.0 → docker/Dockerfile-3.0} +2 -2
  35. data/{bash_profile → docker/bash_profile} +0 -0
  36. data/{inputrc → docker/inputrc} +0 -0
  37. data/docs/doc/Array.html +85 -2
  38. data/docs/doc/BooleanTermParser/Clause.html +1 -1
  39. data/docs/doc/BooleanTermParser/Operator.html +1 -1
  40. data/docs/doc/BooleanTermParser/Query.html +1 -1
  41. data/docs/doc/BooleanTermParser/QueryParser.html +1 -1
  42. data/docs/doc/BooleanTermParser/QueryTransformer.html +1 -1
  43. data/docs/doc/BooleanTermParser.html +1 -1
  44. data/docs/doc/Doing/ArrayNestedHash.html +198 -0
  45. data/docs/doc/Doing/ArrayTags.html +424 -0
  46. data/docs/doc/Doing/CSVExport.html +266 -0
  47. data/docs/doc/Doing/CalendarImport.html +232 -0
  48. data/docs/doc/Doing/Change.html +617 -0
  49. data/docs/doc/Doing/Changes.html +468 -0
  50. data/docs/doc/Doing/ChronifyArray.html +347 -0
  51. data/docs/doc/Doing/ChronifyNumeric.html +271 -0
  52. data/docs/doc/Doing/ChronifyString.html +682 -0
  53. data/docs/doc/Doing/Color.html +167 -21
  54. data/docs/doc/Doing/Completion/BashCompletions.html +445 -0
  55. data/docs/doc/Doing/Completion/FishCompletions.html +445 -0
  56. data/docs/doc/Doing/Completion/StringUtils.html +229 -0
  57. data/docs/doc/Doing/Completion/ZshCompletions.html +445 -0
  58. data/docs/doc/Doing/Completion.html +17 -3
  59. data/docs/doc/Doing/Configuration.html +3 -2
  60. data/docs/doc/Doing/DayOneRenderer.html +383 -0
  61. data/docs/doc/Doing/DayoneExport.html +290 -0
  62. data/docs/doc/Doing/DoingImport.html +391 -0
  63. data/docs/doc/Doing/Entry.html +381 -0
  64. data/docs/doc/Doing/Errors/DoingNoTraceError.html +7 -3
  65. data/docs/doc/Doing/Errors/DoingRuntimeError.html +7 -3
  66. data/docs/doc/Doing/Errors/DoingStandardError.html +1 -1
  67. data/docs/doc/Doing/Errors/EmptyInput.html +10 -2
  68. data/docs/doc/Doing/Errors/HistoryLimitError.html +194 -0
  69. data/docs/doc/Doing/Errors/InvalidPlugin.html +194 -0
  70. data/docs/doc/Doing/Errors/MissingBackupFile.html +194 -0
  71. data/docs/doc/Doing/Errors/NoResults.html +10 -2
  72. data/docs/doc/Doing/Errors/PluginException.html +1 -1
  73. data/docs/doc/Doing/Errors/UserCancelled.html +10 -2
  74. data/docs/doc/Doing/Errors/WrongCommand.html +10 -2
  75. data/docs/doc/Doing/Errors.html +9 -9
  76. data/docs/doc/Doing/HTMLExport.html +256 -0
  77. data/docs/doc/Doing/Hooks.html +1 -1
  78. data/docs/doc/Doing/Item.html +179 -1660
  79. data/docs/doc/Doing/ItemDates.html +564 -0
  80. data/docs/doc/Doing/ItemQuery.html +614 -0
  81. data/docs/doc/Doing/ItemState.html +387 -0
  82. data/docs/doc/Doing/ItemTags.html +498 -0
  83. data/docs/doc/Doing/Items.html +581 -15
  84. data/docs/doc/Doing/JSONExport.html +222 -0
  85. data/docs/doc/Doing/Logger.html +1 -1
  86. data/docs/doc/Doing/MarkdownExport.html +266 -0
  87. data/docs/doc/Doing/MarkdownRenderer.html +383 -0
  88. data/docs/doc/Doing/Note.html +18 -4
  89. data/docs/doc/Doing/Pager.html +1 -1
  90. data/docs/doc/Doing/Plugins.html +181 -76
  91. data/docs/doc/Doing/Prompt.html +32 -683
  92. data/docs/doc/Doing/PromptChoose.html +484 -0
  93. data/docs/doc/Doing/PromptFZF.html +391 -0
  94. data/docs/doc/Doing/PromptInput.html +572 -0
  95. data/docs/doc/Doing/PromptSTD.html +293 -0
  96. data/docs/doc/Doing/PromptYN.html +237 -0
  97. data/docs/doc/Doing/Section.html +58 -2
  98. data/docs/doc/Doing/StringHighlight.html +533 -0
  99. data/docs/doc/Doing/StringNormalize.html +929 -0
  100. data/docs/doc/Doing/StringQuery.html +725 -0
  101. data/docs/doc/Doing/StringTags.html +884 -0
  102. data/docs/doc/Doing/StringTransform.html +599 -0
  103. data/docs/doc/Doing/StringTruncate.html +448 -0
  104. data/docs/doc/Doing/StringURL.html +409 -0
  105. data/docs/doc/Doing/SymbolNormalize.html +341 -0
  106. data/docs/doc/Doing/TaskPaperExport.html +222 -0
  107. data/docs/doc/Doing/TemplateExport.html +249 -0
  108. data/docs/doc/Doing/TemplateString.html +102 -3
  109. data/docs/doc/Doing/TimingImport.html +285 -0
  110. data/docs/doc/Doing/Types.html +1 -1
  111. data/docs/doc/Doing/Util/Backup.html +11 -163
  112. data/docs/doc/Doing/Util.html +67 -10
  113. data/docs/doc/Doing/Version.html +523 -0
  114. data/docs/doc/Doing/WWID/WWIDUtil.html +510 -0
  115. data/docs/doc/Doing/WWID.html +476 -139
  116. data/docs/doc/Doing/WWIDDisplay.html +865 -0
  117. data/docs/doc/Doing/WWIDEditor.html +466 -0
  118. data/docs/doc/Doing/WWIDFileTools.html +359 -0
  119. data/docs/doc/Doing/WWIDFilter.html +466 -0
  120. data/docs/doc/Doing/WWIDGuess.html +299 -0
  121. data/docs/doc/Doing/WWIDInteractive.html +752 -0
  122. data/docs/doc/Doing/WWIDModify.html +1078 -0
  123. data/docs/doc/Doing/WWIDTags.html +302 -0
  124. data/docs/doc/Doing/WWIDTimers.html +359 -0
  125. data/docs/doc/Doing/WWIDUtil.html +510 -0
  126. data/docs/doc/Doing.html +9 -6
  127. data/docs/doc/FalseClass.html +1 -1
  128. data/docs/doc/GLI/Commands/Help.html +1 -1
  129. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +1 -1
  130. data/docs/doc/GLI/Commands.html +1 -1
  131. data/docs/doc/GLI.html +1 -1
  132. data/docs/doc/Hash.html +1 -1
  133. data/docs/doc/Numeric.html +23 -78
  134. data/docs/doc/Object.html +1 -1
  135. data/docs/doc/PhraseParser/Operator.html +1 -1
  136. data/docs/doc/PhraseParser/PhraseClause.html +1 -1
  137. data/docs/doc/PhraseParser/Query.html +1 -1
  138. data/docs/doc/PhraseParser/QueryParser.html +1 -1
  139. data/docs/doc/PhraseParser/QueryTransformer.html +1 -1
  140. data/docs/doc/PhraseParser/TermClause.html +1 -1
  141. data/docs/doc/PhraseParser.html +1 -1
  142. data/docs/doc/Status.html +1 -1
  143. data/docs/doc/String.html +58 -633
  144. data/docs/doc/Symbol.html +9 -224
  145. data/docs/doc/Time.html +119 -13
  146. data/docs/doc/TrueClass.html +1 -1
  147. data/docs/doc/_index.html +348 -4
  148. data/docs/doc/class_list.html +1 -1
  149. data/docs/doc/file.README.html +2 -2
  150. data/docs/doc/index.html +2 -2
  151. data/docs/doc/method_list.html +1904 -592
  152. data/docs/doc/top-level-namespace.html +12 -4
  153. data/docs/index.md +1 -1
  154. data/doing.rdoc +67 -15
  155. data/lib/completion/_doing.zsh +6 -6
  156. data/lib/completion/doing.bash +10 -10
  157. data/lib/completion/doing.fish +10 -3
  158. data/lib/doing/add_options.rb +39 -1
  159. data/lib/doing/array/array.rb +18 -12
  160. data/lib/doing/array/cleanup.rb +31 -0
  161. data/lib/doing/array/nested_hash.rb +1 -1
  162. data/lib/doing/array/tags.rb +6 -5
  163. data/lib/doing/changelog/changelog.rb +6 -0
  164. data/lib/doing/chronify/array.rb +65 -25
  165. data/lib/doing/chronify/chronify.rb +12 -0
  166. data/lib/doing/chronify/numeric.rb +3 -2
  167. data/lib/doing/chronify/string.rb +1 -1
  168. data/lib/doing/colors.rb +77 -30
  169. data/lib/doing/completion/completion_string.rb +25 -0
  170. data/lib/doing/completion.rb +4 -5
  171. data/lib/doing/configuration.rb +7 -3
  172. data/lib/doing/errors.rb +51 -35
  173. data/lib/doing/good.rb +8 -0
  174. data/lib/doing/hooks.rb +3 -3
  175. data/lib/doing/item/dates.rb +112 -0
  176. data/lib/doing/item/item.rb +128 -0
  177. data/lib/doing/{item.rb → item/query.rb} +2 -353
  178. data/lib/doing/item/state.rb +59 -0
  179. data/lib/doing/item/tags.rb +87 -0
  180. data/lib/doing/items/filter.rb +67 -0
  181. data/lib/doing/items/items.rb +57 -0
  182. data/lib/doing/items/modify.rb +36 -0
  183. data/lib/doing/items/sections.rb +83 -0
  184. data/lib/doing/items/util.rb +74 -0
  185. data/lib/doing/normalize.rb +10 -2
  186. data/lib/doing/note.rb +1 -1
  187. data/lib/doing/pager.rb +9 -3
  188. data/lib/doing/plugin_manager.rb +33 -8
  189. data/lib/doing/plugins/export/markdown_export.rb +4 -2
  190. data/lib/doing/plugins/export/template_export.rb +4 -4
  191. data/lib/doing/plugins/import/cal_to_json.scpt +0 -0
  192. data/lib/doing/plugins/import/doing_import.rb +1 -1
  193. data/lib/doing/prompt/choose.rb +118 -0
  194. data/lib/doing/prompt/fzf.rb +84 -0
  195. data/lib/doing/prompt/input.rb +129 -0
  196. data/lib/doing/prompt/prompt.rb +41 -0
  197. data/lib/doing/prompt/std.rb +32 -0
  198. data/lib/doing/prompt/yn.rb +64 -0
  199. data/lib/doing/section.rb +4 -0
  200. data/lib/doing/string/highlight.rb +1 -1
  201. data/lib/doing/string/query.rb +1 -1
  202. data/lib/doing/string/string.rb +18 -7
  203. data/lib/doing/string/tags.rb +14 -3
  204. data/lib/doing/string/transform.rb +7 -1
  205. data/lib/doing/string/truncate.rb +1 -1
  206. data/lib/doing/string/url.rb +1 -1
  207. data/lib/doing/time.rb +19 -1
  208. data/lib/doing/util.rb +12 -6
  209. data/lib/doing/util_backup.rb +62 -57
  210. data/lib/doing/version.rb +1 -1
  211. data/lib/doing/wwid/display.rb +396 -0
  212. data/lib/doing/wwid/editor.rb +214 -0
  213. data/lib/doing/wwid/filetools.rb +183 -0
  214. data/lib/doing/wwid/filter.rb +226 -0
  215. data/lib/doing/wwid/guess.rb +85 -0
  216. data/lib/doing/wwid/interactive.rb +377 -0
  217. data/lib/doing/wwid/modify.rb +617 -0
  218. data/lib/doing/wwid/tags.rb +51 -0
  219. data/lib/doing/wwid/timers.rb +342 -0
  220. data/lib/doing/wwid/wwid.rb +121 -0
  221. data/lib/doing/wwid/wwidutil.rb +101 -0
  222. data/lib/doing.rb +7 -7
  223. data/lib/helpers/threaded_tests.rb +1 -0
  224. metadata +94 -14
  225. data/lib/doing/changelog.rb +0 -6
  226. data/lib/doing/completion/string.rb +0 -17
  227. data/lib/doing/items.rb +0 -196
  228. data/lib/doing/prompt.rb +0 -330
  229. data/lib/doing/wwid.rb +0 -2398
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02eff91d6af3da80b7a9f728c517dbb34c4a308d74f7b722a45c0999e3d9cec8
4
- data.tar.gz: edb57cbb3c4c3c6a6a598f3e16a6a8d23dcb2a466635b68e0ecd359db207f8f3
3
+ metadata.gz: 8021e76952eb60e4eb68c5aa013f558e7e9e5db454bad792c1ae7e5cc495e24c
4
+ data.tar.gz: 5eda874992b4f9648c421afdc4429963f2614d08aabba8fb338d4d27c353e258
5
5
  SHA512:
6
- metadata.gz: f1c66ccce28e225692c0e3fbbb46a74ba0c5ebd5f8043c79f2a938948cbb5c8a65dc6a7a80a19901bf5633441e01c083a7d1ab6e589cb1bfd5542f4aa6d48b5d
7
- data.tar.gz: 53560dc1b93d92e67e9bc3a1803da23aaf167041857301126b4ae8b2eff851b75c45b36386cfad34922e22cbc2acc1e689b3c7b635f46dfd0fe5833d7ea24d4e
6
+ metadata.gz: 37ce93cc4868cbb5565f18b8cd2a77d61099f9692c5b6bcaacdf9329876faa4bc9ff240adc29ea2f8e4cff76adbadc697f583131dfcdb61379dc998a91d40de4
7
+ data.tar.gz: 06d59cd04607005a65f166701873107a8d4817986007940489dfda3247d97d567a4072d62eb05687f50e1ba93eb6341f1db8f5a317df948836fa56945270a8fa
data/.yardopts CHANGED
@@ -1 +1 @@
1
- --output-dir docs/doc --markup-provider=redcarpet --markup=markdown --no-private --exclude=README.md lib/doing/*.rb
1
+ --output-dir docs/doc --markup-provider=redcarpet --markup=markdown --no-private --exclude=README.md lib/doing/**/*.rb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,70 @@
1
+ ### 2.1.42
2
+
3
+ 2022-03-17 09:38
4
+
5
+ #### NEW
6
+
7
+ - Config option `editors.pager` allows you to force a pager (ignore env settings)
8
+
9
+ #### IMPROVED
10
+
11
+ - Change pager preference order to $PAGER, less -Xr, $GIT_PAGER
12
+ - Remove `bat` from pager options as it just falls back to `less -Xr` anyway
13
+ - Using CTRL-C when entring a note interactively won't cancel the whole operation, just the note
14
+
15
+ #### FIXED
16
+
17
+ - Add delay between `doing select --editor` and opening the editor, fixes some TTY echo issues
18
+ - If `doing last --editor` has no changes, exit gracefully
19
+ - Trigger pre/post_write hooks when using undo/redo
20
+ - `doing config set` issues with keys that default to nil
21
+ - Notification for `doing config set --remove` missing last element of key path
22
+
23
+ ### 2.1.41
24
+
25
+ 2022-03-16 09:29
26
+
27
+ #### NEW
28
+
29
+ - Filter methods available to plugins on Items collection - #in_section, #search, #tagged, #between_dates
30
+
31
+ #### IMPROVED
32
+
33
+ - Better comparison methods for Items and Sections
34
+ - `doing tag_dir -r TAG` can remove an indivudal tag from default_tags (--clear removes all)
35
+ - `doing tag_dir` accepts `--editor` to edit tag list in default editor
36
+ - `doing tag_dir` without arguments requests input via readline
37
+ - Use `.txt` instead of `.md` for editor temp file to avoid incorrect syntax higlighting in editor
38
+ - Further API documentation
39
+
40
+ #### FIXED
41
+
42
+ - Security warnings related to regular expressions
43
+ - Items.diff method returning too many changes
44
+
45
+ ### 2.1.40
46
+
47
+ 2022-03-14 19:56
48
+
49
+ #### NEW
50
+
51
+ - `doing finish` accepts `--from` ranges to update both start and finish dates
52
+ - `doing finish` allows `--back` and `--took` to be used together
53
+ - `doing finish` allows `--search` and `--tag` to be used together
54
+ - `doing finish --from 'DATE to DATE'` allows you to set a new start and end time with a single range string
55
+ - `doing reset --from 'DATE to DATE'` allows you to reset an entry's start time and update or add @done time
56
+ - `doing reset` accepts a `--took Xm` flag to change the finish time
57
+ - `--output FORMAT` option for all display commands, including last, recent and today
58
+
59
+ #### IMPROVED
60
+
61
+ - Code refactoring, split up WWID class
62
+ - Better diff method available to hooks to see what changed
63
+
64
+ #### FIXED
65
+
66
+ - Search highlighting was being skipped in all cases
67
+
1
68
  ### 2.1.39
2
69
 
3
70
  2022-03-13 04:32
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- doing (2.1.39)
4
+ doing (2.1.42)
5
5
  chronic (~> 0.10, >= 0.10.2)
6
6
  deep_merge (~> 1.2, >= 1.2.1)
7
7
  gli (~> 2.20, >= 2.20.1)
data/README.md CHANGED
@@ -8,7 +8,7 @@ _If you're one of the rare people like me who find this useful, feel free to
8
8
 
9
9
  <!--README-->
10
10
 
11
- The current version of `doing` is <!--VER-->2.1.38<!--END VER-->.
11
+ The current version of `doing` is <!--VER-->2.1.41<!--END VER-->.
12
12
 
13
13
  Find all of the documentation in the [doing wiki][wiki].
14
14
 
data/Rakefile CHANGED
@@ -71,16 +71,16 @@ task :dockertest, :version, :login do |_, args|
71
71
  Process.exit 0
72
72
  when /^3/
73
73
  img = 'doingtest3'
74
- file = 'Dockerfile-3.0'
74
+ file = 'docker/Dockerfile-3.0'
75
75
  when /6$/
76
76
  img = 'doingtest26'
77
- file = 'Dockerfile-2.6'
77
+ file = 'docker/Dockerfile-2.6'
78
78
  when /(^2|7$)/
79
79
  img = 'doingtest27'
80
- file = 'Dockerfile-2.7'
80
+ file = 'docker/Dockerfile-2.7'
81
81
  else
82
82
  img = 'doingtest'
83
- file = 'Dockerfile'
83
+ file = 'docker/Dockerfile'
84
84
  end
85
85
 
86
86
  puts `docker build . --file #{file} -t #{img}`
@@ -33,9 +33,7 @@ command %i[again resume] do |c|
33
33
  c.action do |_global_options, options, _args|
34
34
  options[:fuzzy] = false
35
35
 
36
- if options[:search]
37
- options[:search] = options[:exact] ? options[:search].sub(/^'?/, "'") : options[:search]
38
- end
36
+ options[:search] = options[:search].sub(/^'?/, "'") if options[:search] && options[:exact]
39
37
 
40
38
  if options[:back]
41
39
  options[:date] = options[:back]
@@ -14,52 +14,68 @@ MARKDOWN_THEME = {
14
14
  comment: :bright_black
15
15
  }.deep_freeze
16
16
 
17
- CHANGE_RX = /^(?:(?:(?:[<>=]+|p(?:rior)|b(?:efore)|o(?:lder)|s(?:ince)|a(?:fter)|n(?:ewer))? *[0-9.*?]+ *)+|(?:[\d.]+ *(?:-|to)+ *[0-9.]+))$/
17
+ module Doing
18
+ # changes command methods
19
+ class ChangesCommand
20
+ CHANGE_RX = /^(?:(?:(?:[<>=]+|p(?:rior)|b(?:efore)|o(?:lder)|s(?:ince)|a(?:fter)|n(?:ewer))? *[0-9.*?]{1,10} *)+|(?:[\d.]+ *(?:-|to)+ *[0-9.]{1,10}))$/
18
21
 
19
- desc 'List recent changes in Doing'
20
- long_desc %(Display a formatted list of changes in recent versions.
22
+ def add_options(cmd)
23
+ cmd.desc 'Display all versions'
24
+ cmd.switch %i[a all], default_value: false, negatable: false
21
25
 
22
- Without flags, displays only the most recent version.
23
- Use --lookup or --all for history.)
24
- command %i[changes changelog] do |c|
25
- c.desc 'Display all versions'
26
- c.switch %i[a all], default_value: false, negatable: false
26
+ cmd.desc %(Look up a specific version. Specify versions as "MAJ.MIN.PATCH", MIN
27
+ and PATCH are optional. Use > or < to see all changes since or prior
28
+ to a version. Wildcards (*?) accepted unless using < or >.)
29
+ cmd.arg_name 'VERSION'
30
+ cmd.flag %i[l lookup], must_match: CHANGE_RX
27
31
 
28
- c.desc %(Look up a specific version. Specify versions as "MAJ.MIN.PATCH", MIN
29
- and PATCH are optional. Use > or < to see all changes since or prior
30
- to a version. Wildcards (*?) accepted unless using < or >.)
31
- c.arg_name 'VERSION'
32
- c.flag %i[l lookup], must_match: CHANGE_RX
32
+ cmd.desc %(Show changelogs matching search terms (uses pattern-based searching).
33
+ Add slashes to search with regular expressions, e.g. `--search "/output.*flag/"`)
34
+ cmd.flag %i[s search]
33
35
 
34
- c.desc %(Show changelogs matching search terms (uses pattern-based searching).
35
- Add slashes to search with regular expressions, e.g. `--search "/output.*flag/"`)
36
- c.flag %i[s search]
36
+ cmd.desc 'Sort order (asc/desc)'
37
+ cmd.arg_name 'ORDER'
38
+ cmd.flag %i[sort], must_match: REGEX_SORT_ORDER, default_value: :desc, type: OrderSymbol
37
39
 
38
- c.desc 'Sort order (asc/desc)'
39
- c.arg_name 'ORDER'
40
- c.flag %i[sort], must_match: REGEX_SORT_ORDER, default_value: :desc, type: OrderSymbol
40
+ cmd.desc 'Only output changes, no version numbers, headers, or dates'
41
+ cmd.switch %i[C changes], default_value: false, negatable: false
41
42
 
42
- c.desc 'Only output changes, no version numbers, headers, or dates'
43
- c.switch %i[C changes], default_value: false, negatable: false
43
+ cmd.desc 'Output raw Markdown'
44
+ cmd.switch %i[m md markdown], default_value: false, negatable: false
44
45
 
45
- c.desc 'Output raw Markdown'
46
- c.switch %i[m md markdown], default_value: false, negatable: false
46
+ cmd.desc 'Force rendered output'
47
+ cmd.switch %i[render], default_value: false, negatable: false
47
48
 
48
- c.desc 'Force rendered output'
49
- c.switch %i[render], default_value: false, negatable: false
49
+ cmd.desc 'Open changelog in interactive viewer'
50
+ cmd.switch %i[i interactive], default_value: false, negatable: false
51
+ end
50
52
 
51
- c.desc 'Open changelog in interactive viewer'
52
- c.switch %i[i interactive], default_value: false, negatable: false
53
+ def add_examples(cmd)
54
+ cmd.example 'doing changes', desc: 'View changes in the current version'
55
+ cmd.example 'doing changes --all', desc: 'See the entire changelog'
56
+ cmd.example 'doing changes --lookup 2.0.21', desc: 'See changes from version 2.0.21'
57
+ cmd.example 'doing changes --lookup "> 2.1"', desc: 'See all changes since 2.1.0'
58
+ cmd.example 'doing changes --search "tags +bool"', desc: 'See all changes containing "tags" and "bool"'
59
+ cmd.example 'doing changes -l "> 2.1" -s "pattern"', desc: 'Lookup and search can be combined'
60
+ end
61
+ end
62
+ end
63
+
64
+ desc 'List recent changes in Doing'
65
+ long_desc %(Display a formatted list of changes in recent versions.
53
66
 
54
- c.example 'doing changes', desc: 'View changes in the current version'
55
- c.example 'doing changes --all', desc: 'See the entire changelog'
56
- c.example 'doing changes --lookup 2.0.21', desc: 'See changes from version 2.0.21'
57
- c.example 'doing changes --lookup "> 2.1"', desc: 'See all changes since 2.1.0'
58
- c.example 'doing changes --search "tags +bool"', desc: 'See all changes containing "tags" and "bool"'
59
- c.example 'doing changes -l "> 2.1" -s "pattern"', desc: 'Lookup and search can be combined'
67
+ Without flags, displays only the most recent version.
68
+ Use --lookup or --all for history.)
69
+ command %i[changes changelog] do |c|
70
+ cmd = Doing::ChangesCommand.new
71
+ cmd.add_options(c)
72
+ cmd.add_examples(c)
60
73
 
61
74
  c.action do |_global_options, options, _args|
62
- cl = Doing::Changes.new(lookup: options[:lookup], search: options[:search], changes: options[:changes], sort: options[:sort])
75
+ cl = Doing::Changes.new(lookup: options[:lookup],
76
+ search: options[:search],
77
+ changes: options[:changes],
78
+ sort: options[:sort])
63
79
 
64
80
  if options[:interactive]
65
81
  cl.interactive
@@ -1,37 +1,71 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # @@commands
4
- desc 'Enable and disable Doing commands'
5
- command :commands do |c|
6
- c.example 'doing commands add', desc: 'Get a menu of available commands'
7
- c.example 'doing commands add COMMAND', desc: 'Specify a command to enable'
8
- c.example 'doing commands remove COMMAND', desc: 'Specify a command to disable'
3
+ module Doing
4
+ # commands command methods
5
+ class CommandsCommand
6
+ def add_examples(cmd)
7
+ cmd.example 'doing commands add', desc: 'Get a menu of available commands'
8
+ cmd.example 'doing commands add COMMAND', desc: 'Specify a command to enable'
9
+ cmd.example 'doing commands remove COMMAND', desc: 'Specify a command to disable'
10
+ end
9
11
 
10
- c.default_command :add
12
+ def remove_command(args)
13
+ available = Dir.glob(File.join(File.dirname(__FILE__), '*.rb')).map { |cmd| File.basename(cmd, '.rb') }
14
+ cfg = Doing.settings
15
+ custom_dir = Doing.setting('plugins.command_path')
16
+ custom_commands = Dir.glob(File.join(File.expand_path(custom_dir), '*.rb'))
17
+ available.concat(custom_commands.map { |cmd| File.basename(cmd, '.rb') })
18
+ disabled = Doing.setting('disabled_commands')
19
+ disabled.each { |cmd| available.delete(cmd) }
20
+ to_disable = if args.good?
21
+ args
22
+ else
23
+ Prompt.choose_from(available,
24
+ prompt: 'Select commands to enable',
25
+ multiple: true,
26
+ sorted: true)
27
+ end
28
+ raise UserCancelled unless to_disable.good?
11
29
 
12
- # @@commands.enable
13
- c.desc 'Enable Doing commands'
14
- c.long_desc 'Run without arguments to select commands from a list.'
15
- c.arg_name 'COMMAND [COMMAND...]'
16
- c.command %i[add enable] do |add|
17
- add.action do |_global, _options, args|
30
+ to_disable = to_disable.strip.split("\n") if to_disable.is_a?(String)
31
+
32
+ to_disable.each do |cmd|
33
+ default_command = File.join(File.dirname(__FILE__), "#{cmd}.rb")
34
+ custom_command = File.join(File.expand_path(custom_dir), "#{cmd}.rb")
35
+ unless File.exist?(default_command) || File.exist?(custom_command)
36
+ raise InvalidArgument, "Command #{cmd} not found"
37
+
38
+ end
39
+
40
+ raise InvalidArgument, "Command #{cmd} is not enabled" unless available.include?(cmd)
41
+ end
42
+
43
+ cfg.deep_set(['disabled_commands'], disabled.concat(to_disable))
44
+
45
+ Util.write_to_file(Doing.config.config_file, YAML.dump(cfg), backup: true)
46
+ Doing.logger.warn('Config:', "#{Doing.config.config_file} updated")
47
+ end
48
+
49
+ def add_command(args)
18
50
  cfg = Doing.settings
19
- custom_dir = cfg.dig('plugins', 'command_path')
51
+ custom_dir = Doing.setting('plugins.command_path')
52
+ available = Doing.setting('disabled_commands')
20
53
 
21
- available = cfg['disabled_commands']
22
54
  raise UserCancelled, 'No commands available to enable' unless args.good? || available.good?
23
55
 
24
56
  to_enable = if args.good?
25
57
  args
26
58
  else
27
- Doing::Prompt.choose_from(available,
28
- prompt: 'Select commands to enable',
29
- multiple: true,
30
- sorted: true)
59
+ Prompt.choose_from(available,
60
+ prompt: 'Select commands to enable',
61
+ multiple: true,
62
+ sorted: true)
31
63
  end
32
- raise UserCancelled unless to_enable
64
+ raise UserCancelled unless to_enable.good?
33
65
 
34
- to_enable.strip.split("\n").each do |cmd|
66
+ to_enable = to_enable.strip.split("\n") if to_enable.is_a?(String)
67
+
68
+ to_enable.each do |cmd|
35
69
  default_command = File.join(File.dirname(__FILE__), "#{cmd}.rb")
36
70
  custom_command = File.join(File.expand_path(custom_dir), "#{cmd}.rb")
37
71
  unless File.exist?(default_command) || File.exist?(custom_command)
@@ -45,45 +79,36 @@ command :commands do |c|
45
79
 
46
80
  cfg.deep_set(['disabled_commands'], available)
47
81
 
48
- Doing::Util.write_to_file(Doing.config.config_file, YAML.dump(cfg), backup: true)
82
+ Util.write_to_file(Doing.config.config_file, YAML.dump(cfg), backup: true)
49
83
  Doing.logger.warn('Config:', "#{Doing.config.config_file} updated")
50
84
  end
51
85
  end
86
+ end
87
+
88
+ # @@commands
89
+ desc 'Enable and disable Doing commands'
90
+ command :commands do |c|
91
+ c.default_command :add
92
+
93
+ cmd = Doing::CommandsCommand.new
94
+
95
+ cmd.add_examples(c)
96
+
97
+ # @@commands.enable
98
+ c.desc 'Enable Doing commands'
99
+ c.long_desc 'Run without arguments to select commands from a list.'
100
+ c.arg_name 'COMMAND [COMMAND...]'
101
+ c.command %i[add enable] do |add|
102
+ add.action do |_global, _options, args|
103
+ cmd.add_command(args)
104
+ end
105
+ end
52
106
 
53
107
  # @@commands.disable
54
108
  c.desc 'Disable Doing commands'
55
109
  c.command %i[remove disable] do |remove|
56
110
  remove.action do |_global, _options, args|
57
- available = Dir.glob(File.join(File.dirname(__FILE__), '*.rb')).map { |cmd| File.basename(cmd, '.rb') }
58
- cfg = Doing.settings
59
- custom_dir = cfg.dig('plugins', 'command_path')
60
- custom_commands = Dir.glob(File.join(File.expand_path(custom_dir), '*.rb'))
61
- available.concat(custom_commands.map { |cmd| File.basename(cmd, '.rb') })
62
- disabled = cfg['disabled_commands']
63
- disabled.each { |cmd| available.delete(cmd) }
64
- to_disable = if args.good?
65
- args
66
- else
67
- Doing::Prompt.choose_from(available,
68
- prompt: 'Select commands to enable',
69
- multiple: true,
70
- sorted: true).strip.split("\n")
71
- end
72
- to_disable.each do |cmd|
73
- default_command = File.join(File.dirname(__FILE__), "#{cmd}.rb")
74
- custom_command = File.join(File.expand_path(custom_dir), "#{cmd}.rb")
75
- unless File.exist?(default_command) || File.exist?(custom_command)
76
- raise InvalidArgument, "Command #{cmd} not found"
77
-
78
- end
79
-
80
- raise InvalidArgument, "Command #{cmd} is not enabled" unless available.include?(cmd)
81
- end
82
-
83
- cfg.deep_set(['disabled_commands'], disabled.concat(to_disable))
84
-
85
- Doing::Util.write_to_file(Doing.config.config_file, YAML.dump(cfg), backup: true)
86
- Doing.logger.warn('Config:', "#{Doing.config.config_file} updated")
111
+ cmd.remove_command(args)
87
112
  end
88
113
  end
89
114
  end
@@ -1,5 +1,56 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ module Doing
4
+ # commands_accepting command methods
5
+ class CommandsAcceptingCommand
6
+ def flags?(options, args, bool)
7
+ case bool
8
+ when :and
9
+ all_flags?(options, args)
10
+ when :not
11
+ no_flags?(options, args)
12
+ else
13
+ any_flags?(options, args)
14
+ end
15
+ end
16
+
17
+ def all_flags?(options, args)
18
+ args.each do |arg|
19
+ has_flag = false
20
+ options.flags.merge(options.switches).each do |_, flag|
21
+ if flag.name == arg.to_sym || flag.aliases&.include?(arg.to_sym)
22
+ has_flag = true
23
+ break
24
+ end
25
+ end
26
+ return false unless has_flag
27
+ end
28
+
29
+ true
30
+ end
31
+
32
+ def any_flags?(options, args)
33
+ args.each do |option|
34
+ options.flags.merge(options.switches).each do |_, flag|
35
+ return true if flag.name == option.to_sym || flag.aliases&.include?(option.to_sym)
36
+ end
37
+ end
38
+
39
+ false
40
+ end
41
+
42
+ def no_flags?(options, args)
43
+ args.each do |option|
44
+ options.flags.merge(options.switches).each do |_, flag|
45
+ return false if flag.name == option.to_sym || flag.aliases&.include?(option.to_sym)
46
+ end
47
+ end
48
+
49
+ true
50
+ end
51
+ end
52
+ end
53
+
3
54
  # @@commands_accepting
4
55
  arg_name 'OPTION'
5
56
  command :commands_accepting do |c|
@@ -11,66 +62,19 @@ command :commands_accepting do |c|
11
62
  default_value: :and,
12
63
  type: BooleanSymbol
13
64
 
14
- c.action do |g, o, a|
65
+ c.action do |_g, o, a|
66
+ cac = Doing::CommandsAcceptingCommand.new
15
67
  cmds = []
16
- commands.each { |cmd, v| cmds.push(cmd) if has_flags?(v, a, o[:bool]) }
68
+ commands.each { |cmd, v| cmds.push(cmd) if cac.flags?(v, a, o[:bool]) }
17
69
 
18
70
  if o[:column]
19
71
  puts cmds.sort
20
72
  else
21
- description = "Commands "
22
- description += "not " if o[:bool] == :not
23
- description += "accepting "
73
+ description = 'Commands '
74
+ description += 'not ' if o[:bool] == :not
75
+ description += 'accepting '
24
76
  description += a.map { |arg| "--#{arg}" }.join(o[:bool] == :and ? ' and ' : ' or ')
25
77
  puts "#{description}: #{cmds.sort.join(', ')}"
26
78
  end
27
79
  end
28
-
29
- def has_flags?(options, args, bool)
30
- case bool
31
- when :and
32
- all_flags?(options, args)
33
- when :not
34
- no_flags?(options, args)
35
- else
36
- any_flags?(options, args)
37
- end
38
- end
39
-
40
- def all_flags?(options, args)
41
- args.each do |arg|
42
- has_flag = false
43
- options.flags.merge(options.switches).each do |_, flag|
44
- if flag.name == arg.to_sym || flag.aliases&.include?(arg.to_sym)
45
- has_flag = true
46
- break
47
- end
48
- end
49
- return false unless has_flag
50
- end
51
-
52
- true
53
- end
54
-
55
- def any_flags?(options, args)
56
- args.each do |option|
57
- options.flags.merge(options.switches).each do |_, flag|
58
- return true if flag.name == option.to_sym || flag.aliases&.include?(option.to_sym)
59
- end
60
- end
61
-
62
- false
63
- end
64
-
65
- def no_flags?(options, args)
66
- args.each do |option|
67
- options.flags.merge(options.switches).each do |_, flag|
68
- return false if flag.name == option.to_sym || flag.aliases&.include?(option.to_sym)
69
- end
70
- end
71
-
72
- true
73
- end
74
80
  end
75
-
76
-