doing 2.1.29 → 2.1.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/.irbrc +1 -0
  3. data/CHANGELOG.md +4962 -0
  4. data/Dockerfile-2.6 +3 -1
  5. data/Dockerfile-2.7 +4 -2
  6. data/Dockerfile-3.0 +3 -1
  7. data/Gemfile.lock +2 -67
  8. data/README.md +1 -1
  9. data/bash_profile +13 -0
  10. data/bin/commands/again.rb +1 -1
  11. data/bin/commands/archive.rb +3 -3
  12. data/bin/commands/cancel.rb +1 -1
  13. data/bin/commands/changes.rb +2 -2
  14. data/bin/commands/commands.rb +8 -8
  15. data/bin/commands/completion.rb +61 -19
  16. data/bin/commands/config.rb +20 -17
  17. data/bin/commands/done.rb +1 -1
  18. data/bin/commands/flag.rb +1 -1
  19. data/bin/commands/grep.rb +5 -5
  20. data/bin/commands/last.rb +1 -1
  21. data/bin/commands/meanwhile.rb +1 -1
  22. data/bin/commands/now.rb +1 -1
  23. data/bin/commands/on.rb +1 -1
  24. data/bin/commands/open.rb +4 -4
  25. data/bin/commands/recent.rb +4 -4
  26. data/bin/commands/show.rb +8 -8
  27. data/bin/commands/since.rb +1 -1
  28. data/bin/commands/tag_dir.rb +27 -3
  29. data/bin/commands/today.rb +1 -1
  30. data/bin/commands/view.rb +3 -3
  31. data/bin/commands/yesterday.rb +2 -2
  32. data/bin/doing +26 -135
  33. data/docs/doc/Array.html +1 -1
  34. data/docs/doc/BooleanTermParser/Clause.html +1 -1
  35. data/docs/doc/BooleanTermParser/Operator.html +1 -1
  36. data/docs/doc/BooleanTermParser/Query.html +1 -1
  37. data/docs/doc/BooleanTermParser/QueryParser.html +1 -1
  38. data/docs/doc/BooleanTermParser/QueryTransformer.html +1 -1
  39. data/docs/doc/BooleanTermParser.html +1 -1
  40. data/docs/doc/Doing/Color.html +1 -1
  41. data/docs/doc/Doing/Completion.html +324 -4
  42. data/docs/doc/Doing/Configuration.html +3 -3
  43. data/docs/doc/Doing/Errors/DoingNoTraceError.html +1 -1
  44. data/docs/doc/Doing/Errors/DoingRuntimeError.html +1 -1
  45. data/docs/doc/Doing/Errors/DoingStandardError.html +1 -1
  46. data/docs/doc/Doing/Errors/EmptyInput.html +1 -1
  47. data/docs/doc/Doing/Errors/NoResults.html +1 -1
  48. data/docs/doc/Doing/Errors/PluginException.html +1 -1
  49. data/docs/doc/Doing/Errors/UserCancelled.html +1 -1
  50. data/docs/doc/Doing/Errors/WrongCommand.html +1 -1
  51. data/docs/doc/Doing/Errors.html +1 -1
  52. data/docs/doc/Doing/Hooks.html +1 -1
  53. data/docs/doc/Doing/Item.html +125 -1
  54. data/docs/doc/Doing/Items.html +1 -1
  55. data/docs/doc/Doing/LogAdapter.html +1 -1
  56. data/docs/doc/Doing/Note.html +109 -3
  57. data/docs/doc/Doing/Pager.html +1 -1
  58. data/docs/doc/Doing/Plugins.html +1 -1
  59. data/docs/doc/Doing/Prompt.html +1 -1
  60. data/docs/doc/Doing/Section.html +1 -1
  61. data/docs/doc/Doing/TemplateString.html +1 -1
  62. data/docs/doc/Doing/Types.html +2 -2
  63. data/docs/doc/Doing/Util/Backup.html +1 -1
  64. data/docs/doc/Doing/Util.html +1 -1
  65. data/docs/doc/Doing/WWID.html +6 -6
  66. data/docs/doc/Doing.html +2 -2
  67. data/docs/doc/FalseClass.html +1 -1
  68. data/docs/doc/GLI/Commands/Help.html +1 -1
  69. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +1 -1
  70. data/docs/doc/GLI/Commands.html +1 -1
  71. data/docs/doc/GLI.html +1 -1
  72. data/docs/doc/Hash.html +1 -1
  73. data/docs/doc/Object.html +1 -1
  74. data/docs/doc/PhraseParser/Operator.html +1 -1
  75. data/docs/doc/PhraseParser/PhraseClause.html +1 -1
  76. data/docs/doc/PhraseParser/Query.html +1 -1
  77. data/docs/doc/PhraseParser/QueryParser.html +1 -1
  78. data/docs/doc/PhraseParser/QueryTransformer.html +1 -1
  79. data/docs/doc/PhraseParser/TermClause.html +1 -1
  80. data/docs/doc/PhraseParser.html +1 -1
  81. data/docs/doc/Status.html +1 -1
  82. data/docs/doc/String.html +1 -1
  83. data/docs/doc/Symbol.html +1 -1
  84. data/docs/doc/Time.html +1 -1
  85. data/docs/doc/TrueClass.html +1 -1
  86. data/docs/doc/_index.html +3 -1
  87. data/docs/doc/file.README.html +2 -2
  88. data/docs/doc/index.html +2 -2
  89. data/docs/doc/method_list.html +337 -241
  90. data/docs/doc/top-level-namespace.html +105 -1
  91. data/docs/index.md +1 -1
  92. data/doing.gemspec +24 -23
  93. data/doing.rdoc +34 -13
  94. data/example_plugin.rb +7 -5
  95. data/inputrc +57 -0
  96. data/lib/completion/_doing.zsh +46 -46
  97. data/lib/completion/doing.bash +2 -2
  98. data/lib/completion/doing.fish +4 -4
  99. data/lib/doing/add_options.rb +117 -0
  100. data/lib/doing/array/array.rb +16 -0
  101. data/lib/doing/changelog/changes.rb +8 -6
  102. data/lib/doing/changelog/version.rb +11 -3
  103. data/lib/doing/completion/bash_completion.rb +12 -51
  104. data/lib/doing/completion/fish_completion.rb +17 -53
  105. data/lib/doing/completion/zsh_completion.rb +21 -54
  106. data/lib/doing/completion.rb +203 -17
  107. data/lib/doing/configuration.rb +12 -6
  108. data/lib/doing/item.rb +21 -3
  109. data/lib/doing/items.rb +5 -5
  110. data/lib/doing/note.rb +24 -8
  111. data/lib/doing/plugins/export/dayone_export.rb +8 -6
  112. data/lib/doing/plugins/export/html_export.rb +4 -4
  113. data/lib/doing/plugins/export/json_export.rb +19 -20
  114. data/lib/doing/plugins/export/markdown_export.rb +2 -2
  115. data/lib/doing/plugins/export/template_export.rb +4 -4
  116. data/lib/doing/plugins/import/calendar_import.rb +1 -1
  117. data/lib/doing/plugins/import/doing_import.rb +1 -1
  118. data/lib/doing/plugins/import/timing_import.rb +1 -1
  119. data/lib/doing/section.rb +1 -1
  120. data/lib/doing/string/highlight.rb +3 -4
  121. data/lib/doing/string/string.rb +8 -0
  122. data/lib/doing/types.rb +1 -1
  123. data/lib/doing/util.rb +1 -1
  124. data/lib/doing/util_backup.rb +12 -12
  125. data/lib/doing/version.rb +1 -1
  126. data/lib/doing/wwid.rb +75 -76
  127. data/lib/doing.rb +58 -0
  128. data/lib/examples/commands/wiki.rb +27 -19
  129. data/lib/helpers/threaded_tests.rb +2 -0
  130. data/scripts/setting_replace.rb +11 -0
  131. metadata +107 -102
  132. data/.yardoc/checksums +0 -29
  133. data/.yardoc/complete +0 -0
  134. data/.yardoc/object_types +0 -0
  135. data/.yardoc/objects/root.dat +0 -0
  136. data/.yardoc/proxy_types +0 -0
data/Dockerfile-2.6 CHANGED
@@ -5,5 +5,7 @@ WORKDIR /doing
5
5
  # COPY ./ /doing/
6
6
  RUN gem install bundler:2.2.17
7
7
  RUN apt-get update -y
8
- RUN apt-get install -y less
8
+ RUN apt-get install -y less vim
9
+ COPY ./inputrc /root/.inputrc
10
+ COPY ./bash_profile /root/.bash_profile
9
11
  CMD ["scripts/runtests.sh"]
data/Dockerfile-2.7 CHANGED
@@ -1,9 +1,11 @@
1
1
  FROM ruby:2.7
2
- RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
2
+ # RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
3
3
  RUN mkdir /doing
4
4
  WORKDIR /doing
5
5
  # COPY ./ /doing/
6
6
  RUN gem install bundler:2.2.17
7
7
  RUN apt-get update -y
8
- RUN apt-get install -y less
8
+ RUN apt-get install -y less vim
9
+ COPY ./inputrc /root/.inputrc
10
+ COPY ./bash_profile /root/.bash_profile
9
11
  CMD ["scripts/runtests.sh"]
data/Dockerfile-3.0 CHANGED
@@ -5,5 +5,7 @@ WORKDIR /doing
5
5
  # COPY ./ /doing/
6
6
  RUN gem install bundler:2.2.17
7
7
  RUN apt-get update -y
8
- RUN apt-get install -y less
8
+ RUN apt-get install -y less vim
9
+ COPY ./inputrc /root/.inputrc
10
+ COPY ./bash_profile /root/.bash_profile
9
11
  CMD ["scripts/runtests.sh"]
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- doing (2.1.29)
4
+ doing (2.1.33)
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)
@@ -9,6 +9,7 @@ PATH
9
9
  parslet (~> 2.0, >= 2.0.0)
10
10
  plist (~> 3.6, >= 3.6.0)
11
11
  safe_yaml (~> 1.0)
12
+ sys-uname (~> 1.2, >= 1.2.2)
12
13
  tty-link (~> 0.1, >= 0.1.1)
13
14
  tty-markdown (~> 0.7, >= 0.7.0)
14
15
  tty-progressbar (~> 0.18, >= 0.18.2)
@@ -19,68 +20,16 @@ PATH
19
20
  GEM
20
21
  remote: http://rubygems.org/
21
22
  specs:
22
- activesupport (7.0.1)
23
- concurrent-ruby (~> 1.0, >= 1.0.2)
24
- i18n (>= 1.6, < 2)
25
- minitest (>= 5.1)
26
- tzinfo (~> 2.0)
27
- aruba (1.0.4)
28
- childprocess (>= 2.0, < 5.0)
29
- contracts (~> 0.16.0)
30
- cucumber (>= 2.4, < 6.0)
31
- rspec-expectations (~> 3.4)
32
- thor (~> 1.0)
33
- builder (3.2.4)
34
- childprocess (4.1.0)
35
23
  chronic (0.10.2)
36
- concurrent-ruby (1.1.9)
37
- contracts (0.16.1)
38
- cucumber (5.3.0)
39
- builder (~> 3.2, >= 3.2.4)
40
- cucumber-core (~> 8.0, >= 8.0.1)
41
- cucumber-create-meta (~> 2.0, >= 2.0.2)
42
- cucumber-cucumber-expressions (~> 10.3, >= 10.3.0)
43
- cucumber-gherkin (~> 15.0, >= 15.0.2)
44
- cucumber-html-formatter (~> 9.0, >= 9.0.0)
45
- cucumber-messages (~> 13.1, >= 13.1.0)
46
- cucumber-wire (~> 4.0, >= 4.0.1)
47
- diff-lcs (~> 1.4, >= 1.4.4)
48
- multi_test (~> 0.1, >= 0.1.2)
49
- sys-uname (~> 1.2, >= 1.2.1)
50
- cucumber-core (8.0.1)
51
- cucumber-gherkin (~> 15.0, >= 15.0.2)
52
- cucumber-messages (~> 13.0, >= 13.0.1)
53
- cucumber-tag-expressions (~> 2.0, >= 2.0.4)
54
- cucumber-create-meta (2.0.4)
55
- cucumber-messages (~> 13.1, >= 13.1.0)
56
- sys-uname (~> 1.2, >= 1.2.1)
57
- cucumber-cucumber-expressions (10.3.0)
58
- cucumber-gherkin (15.0.2)
59
- cucumber-messages (~> 13.0, >= 13.0.1)
60
- cucumber-html-formatter (9.0.0)
61
- cucumber-messages (~> 13.0, >= 13.0.1)
62
- cucumber-messages (13.2.1)
63
- protobuf-cucumber (~> 3.10, >= 3.10.8)
64
- cucumber-tag-expressions (2.0.4)
65
- cucumber-wire (4.0.1)
66
- cucumber-core (~> 8.0, >= 8.0.1)
67
- cucumber-cucumber-expressions (~> 10.3, >= 10.3.0)
68
- cucumber-messages (~> 13.0, >= 13.0.1)
69
24
  deep_merge (1.2.2)
70
- diff-lcs (1.5.0)
71
25
  ffi (1.15.5)
72
26
  github-markup (4.0.0)
73
27
  gli (2.20.1)
74
28
  haml (5.0.4)
75
29
  temple (>= 0.8.0)
76
30
  tilt
77
- i18n (1.8.11)
78
- concurrent-ruby (~> 1.0)
79
31
  kramdown (2.3.1)
80
32
  rexml
81
- middleware (0.1.0)
82
- minitest (5.15.0)
83
- multi_test (0.1.2)
84
33
  parallel (1.21.0)
85
34
  parallel_tests (3.7.3)
86
35
  parallel
@@ -89,20 +38,11 @@ GEM
89
38
  tty-color (~> 0.5)
90
39
  plist (3.6.0)
91
40
  power_assert (2.0.1)
92
- protobuf-cucumber (3.10.8)
93
- activesupport (>= 3.2)
94
- middleware
95
- thor
96
- thread_safe
97
41
  rake (13.0.6)
98
42
  rdoc (6.3.3)
99
43
  redcarpet (3.5.1)
100
44
  rexml (3.2.5)
101
45
  rouge (3.27.0)
102
- rspec-expectations (3.10.2)
103
- diff-lcs (>= 1.2.0, < 2.0)
104
- rspec-support (~> 3.10.0)
105
- rspec-support (3.10.3)
106
46
  safe_yaml (1.0.5)
107
47
  strings (0.2.1)
108
48
  strings-ansi (~> 0.2)
@@ -114,8 +54,6 @@ GEM
114
54
  temple (0.8.2)
115
55
  test-unit (3.4.9)
116
56
  power_assert
117
- thor (1.2.1)
118
- thread_safe (0.3.6)
119
57
  tilt (2.0.10)
120
58
  tty-color (0.6.0)
121
59
  tty-cursor (0.7.1)
@@ -140,8 +78,6 @@ GEM
140
78
  tty-spinner (0.9.3)
141
79
  tty-cursor (~> 0.7)
142
80
  tty-which (0.5.0)
143
- tzinfo (2.0.4)
144
- concurrent-ruby (~> 1.0)
145
81
  unicode-display_width (2.1.0)
146
82
  unicode_utils (1.4.0)
147
83
  webrick (1.7.0)
@@ -153,7 +89,6 @@ PLATFORMS
153
89
  ruby
154
90
 
155
91
  DEPENDENCIES
156
- aruba (~> 1.0.2)
157
92
  doing!
158
93
  github-markup (~> 4.0, >= 4.0.0)
159
94
  parallel_tests (~> 3.7, >= 3.7.3)
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.28<!--END VER-->.
11
+ The current version of `doing` is <!--VER-->2.1.31<!--END VER-->.
12
12
 
13
13
  Find all of the documentation in the [doing wiki][wiki].
14
14
 
data/bash_profile ADDED
@@ -0,0 +1,13 @@
1
+ #!/bin/bash
2
+ export GLI_DEBUG=true
3
+ export EDITOR="/usr/bin/vim"
4
+ alias bdoing="GLI_DEBUG=true bundle exec bin/doing"
5
+
6
+ shopt -s nocaseglob
7
+ shopt -s histappend
8
+ shopt -s histreedit
9
+ shopt -s histverify
10
+ shopt -s cmdhist
11
+
12
+ cd /doing
13
+ bundle install
@@ -39,7 +39,7 @@ command %i[again resume] do |c|
39
39
 
40
40
  if options[:back]
41
41
  options[:date] = options[:back]
42
- raise InvalidTimeExpression, 'Unable to parse date string for --back' if date.nil?
42
+ raise InvalidTimeExpression, 'Unable to parse date string for --back' if options[:date].nil?
43
43
 
44
44
  else
45
45
  options[:date] = Time.now
@@ -5,9 +5,9 @@ desc 'Move entries between sections'
5
5
  long_desc %(Argument can be a section name to move all entries from a section,
6
6
  or start with an "@" to move entries matching a tag.
7
7
 
8
- Default with no argument moves items from the "#{@settings['current_section']}" section to Archive.)
8
+ Default with no argument moves items from the "#{Doing.setting('current_section')}" section to Archive.)
9
9
  arg_name 'SECTION_OR_TAG'
10
- default_value @settings['current_section']
10
+ default_value Doing.setting('current_section')
11
11
  command %i[archive move] do |c|
12
12
  c.example 'doing archive Currently', desc: 'Move all entries in the Currently section to Archive section'
13
13
  c.example 'doing archive @done', desc: 'Move all entries tagged @done to Archive'
@@ -33,7 +33,7 @@ command %i[archive move] do |c|
33
33
  c.action do |_global_options, options, args|
34
34
  options[:fuzzy] = false
35
35
  section, tags = if args.empty?
36
- [@settings['current_section'], []]
36
+ [Doing.setting('current_section'), []]
37
37
  elsif args[0] =~ /^all/i
38
38
  ['all', []]
39
39
  elsif args[0] =~ /^@\S+/
@@ -30,7 +30,7 @@ command :cancel do |c|
30
30
  options[:section] = if options[:section]
31
31
  @wwid.guess_section(options[:section]) || options[:section].cap_first
32
32
  else
33
- @settings['current_section']
33
+ Doing.setting('current_section')
34
34
  end
35
35
 
36
36
  raise InvalidArgument, 'Only one argument allowed' if args.length > 1
@@ -14,7 +14,7 @@ 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))? *[\d.*?]+ *)+|(?:[\d.]+ *-+ *[\d.]+))$/
17
+ CHANGE_RX = /^(?:(?:(?:[<>=]+|p(?:rior)|b(?:efore)|o(?:lder)|s(?:ince)|a(?:fter)|n(?:ewer))? *[0-9.*?]+ *)+|(?:[\d.]+ *(?:-|to)+ *[0-9.]+))$/
18
18
 
19
19
  desc 'List recent changes in Doing'
20
20
  long_desc %(Display a formatted list of changes in recent versions.
@@ -27,7 +27,7 @@ command %i[changes changelog] do |c|
27
27
 
28
28
  c.desc %(Look up a specific version. Specify versions as "MAJ.MIN.PATCH", MIN
29
29
  and PATCH are optional. Use > or < to see all changes since or prior
30
- to a version.)
30
+ to a version. Wildcards (*?) accepted unless using < or >.)
31
31
  c.arg_name 'VERSION'
32
32
  c.flag %i[l lookup], must_match: CHANGE_RX
33
33
 
@@ -15,8 +15,8 @@ command :commands do |c|
15
15
  c.arg_name 'COMMAND [COMMAND...]'
16
16
  c.command %i[add enable] do |add|
17
17
  add.action do |_global, _options, args|
18
- cfg = @settings
19
- custom_dir = @settings.dig('plugins', 'command_path')
18
+ cfg = Doing.settings
19
+ custom_dir = cfg.dig('plugins', 'command_path')
20
20
 
21
21
  available = cfg['disabled_commands']
22
22
  raise UserCancelled, 'No commands available to enable' unless args.good? || available.good?
@@ -45,8 +45,8 @@ command :commands do |c|
45
45
 
46
46
  cfg.deep_set(['disabled_commands'], available)
47
47
 
48
- Doing::Util.write_to_file(@config.config_file, YAML.dump(cfg), backup: true)
49
- Doing.logger.warn('Config:', "#{@config.config_file} updated")
48
+ Doing::Util.write_to_file(Doing.config.config_file, YAML.dump(cfg), backup: true)
49
+ Doing.logger.warn('Config:', "#{Doing.config.config_file} updated")
50
50
  end
51
51
  end
52
52
 
@@ -55,8 +55,8 @@ command :commands do |c|
55
55
  c.command %i[remove disable] do |remove|
56
56
  remove.action do |_global, _options, args|
57
57
  available = Dir.glob(File.join(File.dirname(__FILE__), '*.rb')).map { |cmd| File.basename(cmd, '.rb') }
58
- cfg = @settings
59
- custom_dir = @settings.dig('plugins', 'command_path')
58
+ cfg = Doing.settings
59
+ custom_dir = cfg.dig('plugins', 'command_path')
60
60
  custom_commands = Dir.glob(File.join(File.expand_path(custom_dir), '*.rb'))
61
61
  available.concat(custom_commands.map { |cmd| File.basename(cmd, '.rb') })
62
62
  disabled = cfg['disabled_commands']
@@ -82,8 +82,8 @@ command :commands do |c|
82
82
 
83
83
  cfg.deep_set(['disabled_commands'], disabled.concat(to_disable))
84
84
 
85
- Doing::Util.write_to_file(@config.config_file, YAML.dump(cfg), backup: true)
86
- Doing.logger.warn('Config:', "#{@config.config_file} updated")
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")
87
87
  end
88
88
  end
89
89
  end
@@ -1,27 +1,69 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ SHELLS = %w[zsh bash fish all].freeze
4
+ SHELL_RX = /^(?:[bzf](?:[ai]?sh)?|all)$/i.freeze
5
+
3
6
  # @@completion
4
- desc 'Generate shell completion scripts'
7
+ desc 'Generate shell completion scripts for doing'
5
8
  long_desc 'Generates the necessary scripts to add command line completion to various shells,
6
9
  so typing \'doing\' and hitting tab will offer completions of subcommands and their options.'
7
10
  command :completion do |c|
8
- c.example 'doing completion', desc: 'Output zsh (default) to STDOUT'
9
- c.example 'doing completion --type zsh --file ~/.zsh-completions/_doing.zsh',
10
- desc: 'Output zsh completions to file'
11
- c.example 'doing completion --type fish --file ~/.config/fish/completions/doing.fish',
12
- desc: 'Output fish completions to file'
13
- c.example 'doing completion --type bash --file ~/.bash_it/completion/enabled/doing.bash',
14
- desc: 'Output bash completions to file'
15
-
16
- c.desc 'Shell to generate for (bash, zsh, fish)'
17
- c.arg_name 'SHELL'
18
- c.flag %i[t type], must_match: /^(?:[bzf](?:[ai]?sh)?|all)$/i, default_value: 'zsh'
19
-
20
- c.desc 'File to write output to'
21
- c.arg_name 'PATH'
22
- c.flag %i[f file], default_value: 'STDOUT'
23
-
24
- c.action do |_global_options, options, _args|
25
- Doing::Completion.generate_completion(type: options[:type], file: options[:file])
11
+ c.example 'doing completion install zsh',
12
+ desc: 'Install the default zsh completion script and link it to the zsh autolaod directory.'
13
+ c.example 'doing completion generate zsh', desc: 'Generate zsh (default) script to default file, offer to symlink'
14
+ c.example 'doing completion generate fish --file ~/doing.fish',
15
+ desc: 'Generate fish completions to alternative file'
16
+
17
+ c.desc 'Deprecated, specify shell as argument to subcommand'
18
+ c.flag %i[t type], must_match: SHELL_RX
19
+
20
+ c.desc 'Generate completion scripts, including custom plugins and command options'
21
+ c.long_desc "Argument specifies which shell to install for: #{SHELLS.join(', ')}"
22
+ c.arg_name "[#{SHELLS.join('|')}]"
23
+ c.command :generate do |gen|
24
+ gen.example 'doing completion generate fish', desc: 'Generate fish completion script and link to autoload directory'
25
+ gen.example 'doing completion generate zsh --file ~/.zsh-completions/doing.zsh', desc: 'Generate zsh completion script and save to alternative file'
26
+
27
+ gen.desc 'Alternative file to write output to'
28
+ gen.arg_name 'PATH'
29
+ gen.flag %i[f file]
30
+
31
+ gen.desc 'Output result to STDOUT only'
32
+ gen.switch [:stdout], negatable: false
33
+
34
+ gen.action do |_global_options, options, args|
35
+ args = [options[:type]] if options[:type] && args.count.zero?
36
+
37
+ raise MissingArgument, "Specify a shell (#{SHELLS.join('|')})" unless args.count.positive?
38
+
39
+ file = options[:stdout] ? 'stdout' : options[:file] || :default
40
+
41
+ raise InvalidArgument, '--file can not be used with multiple arguments' if options[:file] && args.count > 1
42
+
43
+ args.each do |shell|
44
+ type = Doing::Completion.normalize_type(shell)
45
+ raise InvalidArgument, "Unknown shell #{shell}" if type == :invalid
46
+
47
+ Doing::Completion.generate_completion(type: type, file: file)
48
+ end
49
+ end
50
+ end
51
+
52
+ c.desc 'Install default completion scripts'
53
+ c.long_desc 'Argument specifies which shell to install for: zsh, bash, fish, or all'
54
+ c.arg_name '[zsh|bash|fish]'
55
+ c.command :install do |install|
56
+ install.example 'doing completion install zsh', desc: 'Install and link zsh completion script'
57
+
58
+ # install.flag %i[t type], must_match: /^(?:[bzf](?:[ai]?sh)?|all)$/i
59
+
60
+ install.action do |_global_options, options, args|
61
+ type = options[:type] || args[0]&.strip || 'zsh'
62
+ raise InvalidArgument, "Unknown shell #{type}" unless type =~ SHELL_RX
63
+
64
+ Doing::Completion.link_default(type)
65
+ end
26
66
  end
67
+
68
+ c.default_command :generate
27
69
  end
@@ -30,8 +30,8 @@ command :config do |c|
30
30
  Values defined in the top item in the list will override values in configutations below it.'
31
31
  c.command :list do |list|
32
32
  list.action do |global, options, args|
33
- puts @config.additional_configs.join("\n")
34
- puts @config.config_file
33
+ puts Doing.config.additional_configs.join("\n")
34
+ puts Doing.config.config_file
35
35
  end
36
36
  end
37
37
 
@@ -45,7 +45,7 @@ command :config do |c|
45
45
  edit.arg_name 'EDITOR'
46
46
  edit.flag %i[e editor], default_value: nil
47
47
 
48
- if `uname` =~ /Darwin/
48
+ if Sys::Platform.mac?
49
49
  edit.desc 'Application to use'
50
50
  edit.arg_name 'APP_NAME'
51
51
  edit.flag %i[a app]
@@ -74,9 +74,9 @@ command :config do |c|
74
74
  return
75
75
  end
76
76
 
77
- config_file = @config.choose_config
77
+ config_file = Doing.config.choose_config
78
78
 
79
- if `uname` =~ /Darwin/
79
+ if Sys::Platform.mac?
80
80
  if options[:default]
81
81
  editor = Doing::Util.find_default_editor('config')
82
82
  if editor
@@ -118,7 +118,7 @@ command :config do |c|
118
118
  c.desc 'Update default config file, adding any missing keys'
119
119
  c.command %i[update refresh] do |update|
120
120
  update.action do |_global, options, args|
121
- @config.configure({rewrite: true, ignore_local: true})
121
+ Doing.config.configure({rewrite: true, ignore_local: true})
122
122
  Doing.logger.warn('Config:', 'config refreshed')
123
123
  end
124
124
  end
@@ -127,7 +127,7 @@ command :config do |c|
127
127
  c.desc 'Undo the last change to a config file'
128
128
  c.command :undo do |undo|
129
129
  undo.action do |_global, options, args|
130
- config_file = @config.choose_config
130
+ config_file = Doing.config.choose_config
131
131
  Doing::Util::Backup.restore_last_backup(config_file, count: 1)
132
132
  end
133
133
  end
@@ -139,7 +139,7 @@ command :config do |c|
139
139
  dump.example 'doing config get', desc: 'Output the entire configuration'
140
140
  dump.example 'doing config get timer_format --output raw', desc: 'Output the value of timer_format as a plain string'
141
141
  dump.example 'doing config get doing_file', desc: 'Output the value of the doing_file setting, respecting local configurations'
142
- dump.example 'doing config get -o json plug.plugpath', desc: 'Key path is fuzzy matched: output the value of plugins->plugin_path as JSON'
142
+ dump.example 'doing config get -o json plug.plugpath', desc: 'Key path is fuzzy matched: output the value of plugins.plugin_path as JSON'
143
143
 
144
144
  dump.desc 'Format for output (json|yaml|raw)'
145
145
  dump.arg_name 'FORMAT'
@@ -148,8 +148,8 @@ command :config do |c|
148
148
  dump.action do |_global, options, args|
149
149
 
150
150
  keypath = args.join('.')
151
- cfg = @config.value_for_key(keypath)
152
- real_path = @config.resolve_key_path(keypath)
151
+ cfg = Doing.config.value_for_key(keypath)
152
+ real_path = Doing.config.resolve_key_path(keypath)
153
153
 
154
154
  if cfg
155
155
  val = cfg.map {|k, v| v }[0]
@@ -188,10 +188,13 @@ command :config do |c|
188
188
  c.arg 'KEY VALUE'
189
189
  c.command :set do |set|
190
190
  set.example 'doing config set timer_format human', desc: 'Set the value of timer_format to "human"'
191
- set.example 'doing config set plug.plugpath ~/my_plugins', desc: 'Key path is fuzzy matched: set the value of plugins->plugin_path'
191
+ set.example 'doing config set plug.plugpath ~/my_plugins', desc: 'Key path is fuzzy matched: set the value of plugins.plugin_path'
192
192
 
193
193
  set.desc 'Delete specified key'
194
- set.switch %i[r remove], default_value: false, negatable: false
194
+ set.switch %i[r remove], negatable: false
195
+
196
+ set.desc 'Force update to .doingrc in the current directory'
197
+ set.switch %[local], negatable: false
195
198
 
196
199
  set.action do |_global, options, args|
197
200
  if args.count < 2 && !options[:remove]
@@ -201,12 +204,12 @@ command :config do |c|
201
204
 
202
205
  value = options[:remove] ? nil : args.pop
203
206
  keypath = args.join('.')
204
- real_path = @config.resolve_key_path(keypath, create: true)
207
+ real_path = Doing.config.resolve_key_path(keypath, create: true)
205
208
  old_value = @settings.dig(*real_path)
206
209
  old_type = old_value&.class.to_s || nil
207
210
 
208
211
  if old_value.is_a?(Hash) && !options[:remove]
209
- Doing.logger.log_now(:warn, 'Config:', "Config key must point to a single value, #{real_path.join('->').boldwhite} is a mapping")
212
+ Doing.logger.log_now(:warn, 'Config:', "Config key must point to a single value, #{real_path.join('.').boldwhite} is a mapping")
210
213
  didyou = 'Did you mean:'
211
214
  old_value.keys.each do |k|
212
215
  Doing.logger.log_now(:warn, "#{didyou}", "#{keypath}.#{k}?")
@@ -216,7 +219,7 @@ command :config do |c|
216
219
 
217
220
  end
218
221
 
219
- config_file = @config.choose_config(create: true)
222
+ config_file = Doing.config.choose_config(create: true, local: options[:local])
220
223
 
221
224
  cfg = Doing::Util.safe_load_file(config_file) || {}
222
225
 
@@ -224,11 +227,11 @@ command :config do |c|
224
227
 
225
228
  if options[:remove]
226
229
  cfg.deep_set(real_path, nil)
227
- $stderr.puts "#{'Deleting key:'.yellow} #{real_path.join('->').boldwhite}"
230
+ $stderr.puts "#{'Deleting key:'.yellow} #{real_path.join('.').boldwhite}"
228
231
  else
229
232
  current_value = cfg.dig(*real_path)
230
233
  cfg.deep_set(real_path, value.set_type(old_type))
231
- $stderr.puts "#{' Key path:'.yellow} #{real_path.join('->').boldwhite}"
234
+ $stderr.puts "#{' Key path:'.yellow} #{real_path.join('.').boldwhite}"
232
235
  $stderr.puts "#{'Inherited:'.yellow} #{(old_value ? old_value.to_s : 'empty').boldwhite}"
233
236
  $stderr.puts "#{' Current:'.yellow} #{ (current_value ? current_value.to_s : 'empty').boldwhite }"
234
237
  $stderr.puts "#{' New:'.yellow} #{value.set_type(old_type).to_s.boldwhite}"
data/bin/commands/done.rb CHANGED
@@ -98,7 +98,7 @@ command %i[done did] do |c|
98
98
  if options[:section]
99
99
  section = @wwid.guess_section(options[:section]) || options[:section].cap_first
100
100
  else
101
- section = @settings['current_section']
101
+ section = Doing.setting('current_section')
102
102
  end
103
103
 
104
104
 
data/bin/commands/flag.rb CHANGED
@@ -34,7 +34,7 @@ command %i[mark flag] do |c|
34
34
 
35
35
  c.action do |_global_options, options, _args|
36
36
  options[:fuzzy] = false
37
- mark = @settings['marker_tag'] || 'flagged'
37
+ mark = Doing.setting('marker_tag', 'flagged')
38
38
 
39
39
  raise InvalidArgument, '--search and --tag can not be used together' if options[:search] && options[:tag]
40
40
 
data/bin/commands/grep.rb CHANGED
@@ -38,7 +38,7 @@ command %i[grep search] do |c|
38
38
  c.switch [:totals], default_value: false, negatable: false
39
39
 
40
40
  c.desc 'Sort tags by (name|time)'
41
- default = @settings['tag_sort'].normalize_tag_sort || :name
41
+ default = Doing.setting('tag_sort').normalize_tag_sort || :name
42
42
  c.arg_name 'KEY'
43
43
  c.flag [:tag_sort], must_match: REGEX_TAG_SORT, default_value: default, type: TagSortSymbol
44
44
 
@@ -49,7 +49,7 @@ command %i[grep search] do |c|
49
49
  # c.switch [:fuzzy], default_value: false, negatable: false
50
50
 
51
51
  c.desc 'Force exact string matching (case sensitive)'
52
- c.switch %i[x exact], default_value: @config.exact_match?, negatable: @config.exact_match?
52
+ c.switch %i[x exact], default_value: Doing.config.exact_match?, negatable: Doing.config.exact_match?
53
53
 
54
54
  c.desc 'Show items that *don\'t* match search string'
55
55
  c.switch [:not], default_value: false, negatable: false
@@ -57,11 +57,11 @@ command %i[grep search] do |c|
57
57
  c.desc 'Case sensitivity for search string matching [(c)ase-sensitive, (i)gnore, (s)mart]'
58
58
  c.arg_name 'TYPE'
59
59
  c.flag [:case], must_match: REGEX_CASE,
60
- default_value: @settings.dig('search', 'case').normalize_case,
60
+ default_value: Doing.settings.dig('search', 'case').normalize_case,
61
61
  type: CaseSymbol
62
62
 
63
63
  c.desc "Highlight search matches in output. Only affects command line output"
64
- c.switch %i[h hilite], default_value: @settings.dig('search', 'highlight')
64
+ c.switch %i[h hilite], default_value: Doing.settings.dig('search', 'highlight')
65
65
 
66
66
  c.desc "Edit matching entries with #{Doing::Util.default_editor}"
67
67
  c.switch %i[e editor], negatable: false, default_value: false
@@ -88,7 +88,7 @@ command %i[grep search] do |c|
88
88
  options[:fuzzy] = false
89
89
  raise DoingRuntimeError, %(Invalid output type "#{options[:output]}") if options[:output] && options[:output] !~ Doing::Plugins.plugin_regex(type: :export)
90
90
 
91
- template = @settings['templates'][options[:config_template]].deep_merge(@settings)
91
+ template = Doing.setting(['templates', options[:config_template]]).deep_merge(Doing.settings)
92
92
  tags_color = template.key?('tags_color') ? template['tags_color'] : nil
93
93
 
94
94
  section = @wwid.guess_section(options[:section]) if options[:section]
data/bin/commands/last.rb CHANGED
@@ -30,7 +30,7 @@ command :last do |c|
30
30
  c.flag [:template]
31
31
 
32
32
  c.desc "Highlight search matches in output. Only affects command line output"
33
- c.switch %i[h hilite], default_value: @settings.dig('search', 'highlight')
33
+ c.switch %i[h hilite], default_value: Doing.settings.dig('search', 'highlight')
34
34
 
35
35
  c.desc 'Show elapsed time if entry is not tagged @done'
36
36
  c.switch [:duration]
@@ -34,7 +34,7 @@ command :meanwhile do |c|
34
34
  if options[:section]
35
35
  section = @wwid.guess_section(options[:section]) || options[:section].cap_first
36
36
  else
37
- section = @settings['current_section']
37
+ section = Doing.setting('current_section')
38
38
  end
39
39
  input = ''
40
40
 
data/bin/commands/now.rb CHANGED
@@ -54,7 +54,7 @@ command %i[now next] do |c|
54
54
  section = if options[:section]
55
55
  @wwid.guess_section(options[:section]) || options[:section].cap_first
56
56
  else
57
- @settings['current_section']
57
+ Doing.setting('current_section')
58
58
  end
59
59
 
60
60
  ask_note = if options[:ask] && !options[:editor] && args.count.positive?
data/bin/commands/on.rb CHANGED
@@ -23,7 +23,7 @@ command :on do |c|
23
23
  c.switch [:totals], default_value: false, negatable: false
24
24
 
25
25
  c.desc 'Sort tags by (name|time)'
26
- default = @settings['tag_sort'].normalize_tag_sort || :name
26
+ default = Doing.setting('tag_sort').normalize_tag_sort || :name
27
27
  c.arg_name 'KEY'
28
28
  c.flag [:tag_sort], must_match: REGEX_TAG_SORT, default_value: default, type: TagSortSymbol
29
29
 
data/bin/commands/open.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  # @@open
2
2
  desc 'Open the "doing" file in an editor'
3
- long_desc "`doing open` defaults to using the editors->doing_file setting
4
- in #{@config.config_file} (#{Doing::Util.find_default_editor('doing_file')})."
3
+ long_desc "`doing open` defaults to using the editors.doing_file setting
4
+ in #{Doing.config.config_file} (#{Doing::Util.find_default_editor('doing_file')})."
5
5
  command :open do |c|
6
6
  c.example 'doing open', desc: 'Open the doing file in the default editor'
7
7
  c.desc 'Open with editor command (e.g. vim, mate)'
8
8
  c.arg_name 'COMMAND'
9
9
  c.flag %i[e editor]
10
10
 
11
- if `uname` =~ /Darwin/
11
+ if Sys::Platform.mac?
12
12
  c.desc 'Open with app name'
13
13
  c.arg_name 'APP_NAME'
14
14
  c.flag %i[a app]
@@ -29,7 +29,7 @@ command :open do |c|
29
29
 
30
30
  editor = TTY::Which.which(options[:editor])
31
31
  system %(#{editor} "#{File.expand_path(@wwid.doing_file)}")
32
- elsif `uname` =~ /Darwin/
32
+ elsif Sys::Platform.mac?
33
33
  if options[:app]
34
34
  system %(open -a "#{options[:app]}" "#{File.expand_path(@wwid.doing_file)}")
35
35
  elsif options[:bundle_id]