doing 2.1.30 → 2.1.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/.irbrc +1 -0
  3. data/CHANGELOG.md +4972 -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 +1 -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/commands.rb +8 -8
  14. data/bin/commands/completion.rb +61 -19
  15. data/bin/commands/config.rb +22 -19
  16. data/bin/commands/done.rb +2 -2
  17. data/bin/commands/flag.rb +1 -1
  18. data/bin/commands/grep.rb +6 -33
  19. data/bin/commands/last.rb +1 -1
  20. data/bin/commands/meanwhile.rb +2 -2
  21. data/bin/commands/now.rb +2 -2
  22. data/bin/commands/on.rb +6 -16
  23. data/bin/commands/open.rb +1 -1
  24. data/bin/commands/recent.rb +5 -17
  25. data/bin/commands/rotate.rb +17 -0
  26. data/bin/commands/sections.rb +82 -7
  27. data/bin/commands/show.rb +8 -28
  28. data/bin/commands/since.rb +5 -16
  29. data/bin/commands/tag_dir.rb +27 -3
  30. data/bin/commands/today.rb +3 -28
  31. data/bin/commands/view.rb +3 -3
  32. data/bin/commands/yesterday.rb +3 -36
  33. data/bin/doing +29 -139
  34. data/docs/doc/Array.html +1 -1
  35. data/docs/doc/BooleanTermParser/Clause.html +1 -1
  36. data/docs/doc/BooleanTermParser/Operator.html +1 -1
  37. data/docs/doc/BooleanTermParser/Query.html +1 -1
  38. data/docs/doc/BooleanTermParser/QueryParser.html +1 -1
  39. data/docs/doc/BooleanTermParser/QueryTransformer.html +1 -1
  40. data/docs/doc/BooleanTermParser.html +1 -1
  41. data/docs/doc/Doing/Color.html +1 -1
  42. data/docs/doc/Doing/Completion.html +324 -4
  43. data/docs/doc/Doing/Configuration.html +3 -3
  44. data/docs/doc/Doing/Errors/DoingNoTraceError.html +1 -1
  45. data/docs/doc/Doing/Errors/DoingRuntimeError.html +1 -1
  46. data/docs/doc/Doing/Errors/DoingStandardError.html +1 -1
  47. data/docs/doc/Doing/Errors/EmptyInput.html +1 -1
  48. data/docs/doc/Doing/Errors/NoResults.html +1 -1
  49. data/docs/doc/Doing/Errors/PluginException.html +1 -1
  50. data/docs/doc/Doing/Errors/UserCancelled.html +1 -1
  51. data/docs/doc/Doing/Errors/WrongCommand.html +1 -1
  52. data/docs/doc/Doing/Errors.html +1 -1
  53. data/docs/doc/Doing/Hooks.html +1 -1
  54. data/docs/doc/Doing/Item.html +144 -3
  55. data/docs/doc/Doing/Items.html +209 -1
  56. data/docs/doc/Doing/LogAdapter.html +1 -1
  57. data/docs/doc/Doing/Logger.html +1807 -0
  58. data/docs/doc/Doing/Note.html +109 -3
  59. data/docs/doc/Doing/Pager.html +1 -1
  60. data/docs/doc/Doing/Plugins.html +1 -1
  61. data/docs/doc/Doing/Prompt.html +1 -1
  62. data/docs/doc/Doing/Section.html +1 -1
  63. data/docs/doc/Doing/TemplateString.html +1 -1
  64. data/docs/doc/Doing/Types.html +3 -3
  65. data/docs/doc/Doing/Util/Backup.html +1 -1
  66. data/docs/doc/Doing/Util.html +1 -1
  67. data/docs/doc/Doing/WWID.html +8 -58
  68. data/docs/doc/Doing.html +4 -4
  69. data/docs/doc/FalseClass.html +1 -1
  70. data/docs/doc/GLI/Commands/Help.html +1 -1
  71. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +1 -1
  72. data/docs/doc/GLI/Commands.html +1 -1
  73. data/docs/doc/GLI.html +1 -1
  74. data/docs/doc/Hash.html +1 -1
  75. data/docs/doc/Object.html +1 -1
  76. data/docs/doc/PhraseParser/Operator.html +1 -1
  77. data/docs/doc/PhraseParser/PhraseClause.html +1 -1
  78. data/docs/doc/PhraseParser/Query.html +1 -1
  79. data/docs/doc/PhraseParser/QueryParser.html +1 -1
  80. data/docs/doc/PhraseParser/QueryTransformer.html +1 -1
  81. data/docs/doc/PhraseParser/TermClause.html +1 -1
  82. data/docs/doc/PhraseParser.html +1 -1
  83. data/docs/doc/Status.html +1 -1
  84. data/docs/doc/String.html +1 -1
  85. data/docs/doc/Symbol.html +1 -1
  86. data/docs/doc/Time.html +1 -1
  87. data/docs/doc/TrueClass.html +1 -1
  88. data/docs/doc/_index.html +12 -10
  89. data/docs/doc/class_list.html +1 -1
  90. data/docs/doc/file.README.html +2 -2
  91. data/docs/doc/index.html +2 -2
  92. data/docs/doc/method_list.html +424 -304
  93. data/docs/doc/top-level-namespace.html +105 -1
  94. data/docs/index.md +1 -1
  95. data/doing.gemspec +24 -24
  96. data/doing.rdoc +259 -26
  97. data/example_plugin.rb +7 -5
  98. data/inputrc +57 -0
  99. data/lib/completion/_doing.zsh +48 -52
  100. data/lib/completion/doing.bash +14 -25
  101. data/lib/completion/doing.fish +41 -15
  102. data/lib/doing/add_options.rb +152 -0
  103. data/lib/doing/array/array.rb +16 -0
  104. data/lib/doing/changelog/changes.rb +1 -1
  105. data/lib/doing/chronify/string.rb +1 -1
  106. data/lib/doing/completion/bash_completion.rb +12 -51
  107. data/lib/doing/completion/fish_completion.rb +17 -53
  108. data/lib/doing/completion/zsh_completion.rb +21 -59
  109. data/lib/doing/completion.rb +203 -17
  110. data/lib/doing/configuration.rb +7 -1
  111. data/lib/doing/item.rb +30 -5
  112. data/lib/doing/items.rb +53 -5
  113. data/lib/doing/{log_adapter.rb → logger.rb} +8 -2
  114. data/lib/doing/note.rb +24 -8
  115. data/lib/doing/plugins/export/dayone_export.rb +8 -6
  116. data/lib/doing/plugins/export/html_export.rb +4 -4
  117. data/lib/doing/plugins/export/json_export.rb +19 -20
  118. data/lib/doing/plugins/export/markdown_export.rb +2 -2
  119. data/lib/doing/plugins/export/template_export.rb +4 -4
  120. data/lib/doing/plugins/import/calendar_import.rb +2 -2
  121. data/lib/doing/plugins/import/doing_import.rb +2 -2
  122. data/lib/doing/plugins/import/timing_import.rb +2 -2
  123. data/lib/doing/string/highlight.rb +3 -4
  124. data/lib/doing/string/string.rb +8 -0
  125. data/lib/doing/string/tags.rb +1 -1
  126. data/lib/doing/types.rb +2 -2
  127. data/lib/doing/util.rb +1 -1
  128. data/lib/doing/util_backup.rb +12 -12
  129. data/lib/doing/version.rb +1 -1
  130. data/lib/doing/wwid.rb +119 -120
  131. data/lib/doing.rb +61 -3
  132. data/lib/examples/commands/wiki.rb +27 -19
  133. data/lib/examples/plugins/capture_thing_import.rb +1 -1
  134. data/lib/helpers/threaded_tests.rb +2 -0
  135. data/scripts/setting_replace.rb +11 -0
  136. metadata +109 -124
  137. data/.yardoc/checksums +0 -29
  138. data/.yardoc/complete +0 -0
  139. data/.yardoc/object_types +0 -0
  140. data/.yardoc/objects/root.dat +0 -0
  141. data/.yardoc/proxy_types +0 -0
  142. data/bin/commands/add_section.rb +0 -15
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.30)
4
+ doing (2.1.34)
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)
@@ -20,68 +20,16 @@ PATH
20
20
  GEM
21
21
  remote: http://rubygems.org/
22
22
  specs:
23
- activesupport (7.0.1)
24
- concurrent-ruby (~> 1.0, >= 1.0.2)
25
- i18n (>= 1.6, < 2)
26
- minitest (>= 5.1)
27
- tzinfo (~> 2.0)
28
- aruba (1.0.4)
29
- childprocess (>= 2.0, < 5.0)
30
- contracts (~> 0.16.0)
31
- cucumber (>= 2.4, < 6.0)
32
- rspec-expectations (~> 3.4)
33
- thor (~> 1.0)
34
- builder (3.2.4)
35
- childprocess (4.1.0)
36
23
  chronic (0.10.2)
37
- concurrent-ruby (1.1.9)
38
- contracts (0.16.1)
39
- cucumber (5.3.0)
40
- builder (~> 3.2, >= 3.2.4)
41
- cucumber-core (~> 8.0, >= 8.0.1)
42
- cucumber-create-meta (~> 2.0, >= 2.0.2)
43
- cucumber-cucumber-expressions (~> 10.3, >= 10.3.0)
44
- cucumber-gherkin (~> 15.0, >= 15.0.2)
45
- cucumber-html-formatter (~> 9.0, >= 9.0.0)
46
- cucumber-messages (~> 13.1, >= 13.1.0)
47
- cucumber-wire (~> 4.0, >= 4.0.1)
48
- diff-lcs (~> 1.4, >= 1.4.4)
49
- multi_test (~> 0.1, >= 0.1.2)
50
- sys-uname (~> 1.2, >= 1.2.1)
51
- cucumber-core (8.0.1)
52
- cucumber-gherkin (~> 15.0, >= 15.0.2)
53
- cucumber-messages (~> 13.0, >= 13.0.1)
54
- cucumber-tag-expressions (~> 2.0, >= 2.0.4)
55
- cucumber-create-meta (2.0.4)
56
- cucumber-messages (~> 13.1, >= 13.1.0)
57
- sys-uname (~> 1.2, >= 1.2.1)
58
- cucumber-cucumber-expressions (10.3.0)
59
- cucumber-gherkin (15.0.2)
60
- cucumber-messages (~> 13.0, >= 13.0.1)
61
- cucumber-html-formatter (9.0.0)
62
- cucumber-messages (~> 13.0, >= 13.0.1)
63
- cucumber-messages (13.2.1)
64
- protobuf-cucumber (~> 3.10, >= 3.10.8)
65
- cucumber-tag-expressions (2.0.4)
66
- cucumber-wire (4.0.1)
67
- cucumber-core (~> 8.0, >= 8.0.1)
68
- cucumber-cucumber-expressions (~> 10.3, >= 10.3.0)
69
- cucumber-messages (~> 13.0, >= 13.0.1)
70
24
  deep_merge (1.2.2)
71
- diff-lcs (1.5.0)
72
25
  ffi (1.15.5)
73
26
  github-markup (4.0.0)
74
27
  gli (2.20.1)
75
28
  haml (5.0.4)
76
29
  temple (>= 0.8.0)
77
30
  tilt
78
- i18n (1.8.11)
79
- concurrent-ruby (~> 1.0)
80
31
  kramdown (2.3.1)
81
32
  rexml
82
- middleware (0.1.0)
83
- minitest (5.15.0)
84
- multi_test (0.1.2)
85
33
  parallel (1.21.0)
86
34
  parallel_tests (3.7.3)
87
35
  parallel
@@ -90,20 +38,11 @@ GEM
90
38
  tty-color (~> 0.5)
91
39
  plist (3.6.0)
92
40
  power_assert (2.0.1)
93
- protobuf-cucumber (3.10.8)
94
- activesupport (>= 3.2)
95
- middleware
96
- thor
97
- thread_safe
98
41
  rake (13.0.6)
99
42
  rdoc (6.3.3)
100
43
  redcarpet (3.5.1)
101
44
  rexml (3.2.5)
102
45
  rouge (3.27.0)
103
- rspec-expectations (3.10.2)
104
- diff-lcs (>= 1.2.0, < 2.0)
105
- rspec-support (~> 3.10.0)
106
- rspec-support (3.10.3)
107
46
  safe_yaml (1.0.5)
108
47
  strings (0.2.1)
109
48
  strings-ansi (~> 0.2)
@@ -115,8 +54,6 @@ GEM
115
54
  temple (0.8.2)
116
55
  test-unit (3.4.9)
117
56
  power_assert
118
- thor (1.2.1)
119
- thread_safe (0.3.6)
120
57
  tilt (2.0.10)
121
58
  tty-color (0.6.0)
122
59
  tty-cursor (0.7.1)
@@ -141,8 +78,6 @@ GEM
141
78
  tty-spinner (0.9.3)
142
79
  tty-cursor (~> 0.7)
143
80
  tty-which (0.5.0)
144
- tzinfo (2.0.4)
145
- concurrent-ruby (~> 1.0)
146
81
  unicode-display_width (2.1.0)
147
82
  unicode_utils (1.4.0)
148
83
  webrick (1.7.0)
@@ -154,7 +89,6 @@ PLATFORMS
154
89
  ruby
155
90
 
156
91
  DEPENDENCIES
157
- aruba (~> 1.0.2)
158
92
  doing!
159
93
  github-markup (~> 4.0, >= 4.0.0)
160
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.29<!--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
@@ -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
 
@@ -43,7 +43,7 @@ command :config do |c|
43
43
 
44
44
  edit.desc 'Editor to use'
45
45
  edit.arg_name 'EDITOR'
46
- edit.flag %i[e editor], default_value: nil
46
+ edit.flag %i[e editor]
47
47
 
48
48
  if Sys::Platform.mac?
49
49
  edit.desc 'Application to use'
@@ -54,8 +54,8 @@ command :config do |c|
54
54
  edit.arg_name 'BUNDLE_ID'
55
55
  edit.flag %i[b bundle_id]
56
56
 
57
- edit.desc "Use the config_editor_app defined in ~/.config/doing/config.yml (#{@settings.key?('config_editor_app') ? @settings['config_editor_app'] : 'config_editor_app not set'})"
58
- edit.switch %i[x default]
57
+ edit.desc "Use the config editor defined in ~/.config/doing/config.yml (#{Doing.setting('editors.config', 'editors.config not set')})"
58
+ edit.switch %i[x default], negatable: false
59
59
  end
60
60
 
61
61
  edit.action do |global, options, args|
@@ -74,7 +74,7 @@ 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
79
  if Sys::Platform.mac?
80
80
  if options[:default]
@@ -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
@@ -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]
@@ -191,7 +191,10 @@ command :config do |c|
191
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,8 +204,8 @@ 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)
205
- old_value = @settings.dig(*real_path)
207
+ real_path = Doing.config.resolve_key_path(keypath, create: true)
208
+ old_value = Doing.config.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]
@@ -216,11 +219,11 @@ 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
 
223
- $stderr.puts "Updating #{config_file}".yellow
226
+ $stderr.puts "> Config: Updating #{config_file}".yellow
224
227
 
225
228
  if options[:remove]
226
229
  cfg.deep_set(real_path, nil)
@@ -228,10 +231,10 @@ command :config do |c|
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}"
232
- $stderr.puts "#{'Inherited:'.yellow} #{(old_value ? old_value.to_s : 'empty').boldwhite}"
233
- $stderr.puts "#{' Current:'.yellow} #{ (current_value ? current_value.to_s : 'empty').boldwhite }"
234
- $stderr.puts "#{' New:'.yellow} #{value.set_type(old_type).to_s.boldwhite}"
234
+ $stderr.puts "#{' Key path:'.yellow} #{real_path.join('.').boldwhite}"
235
+ $stderr.puts "#{' Inherited:'.yellow} #{(old_value ? old_value.to_s : 'empty').boldwhite}"
236
+ $stderr.puts "#{' Current:'.yellow} #{ (current_value ? current_value.to_s : 'empty').boldwhite }"
237
+ $stderr.puts "#{' New:'.yellow} #{value.set_type(old_type).to_s.boldwhite}"
235
238
  end
236
239
 
237
240
  res = Doing::Prompt.yn('Update selected config', default_response: true)
data/bin/commands/done.rb CHANGED
@@ -47,7 +47,7 @@ command %i[done did] do |c|
47
47
  add_options(:add_entry, c)
48
48
 
49
49
  c.action do |_global_options, options, args|
50
- @wwid.auto_tag = !options[:noauto]
50
+ Doing.auto_tag = !options[:noauto]
51
51
 
52
52
  took = 0
53
53
  donedate = nil
@@ -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
@@ -28,40 +28,21 @@ command %i[grep search] do |c|
28
28
  c.arg_name 'TEMPLATE_STRING'
29
29
  c.flag [:template]
30
30
 
31
- c.desc 'Show time intervals on @done tasks'
32
- c.switch %i[t times], default_value: true, negatable: true
33
-
34
- c.desc 'Show elapsed time on entries without @done tag'
35
- c.switch [:duration]
36
-
37
- c.desc 'Show intervals with totals at the end of output'
38
- c.switch [:totals], default_value: false, negatable: false
39
-
40
- c.desc 'Sort tags by (name|time)'
41
- default = @settings['tag_sort'].normalize_tag_sort || :name
42
- c.arg_name 'KEY'
43
- c.flag [:tag_sort], must_match: REGEX_TAG_SORT, default_value: default, type: TagSortSymbol
44
-
45
- c.desc 'Only show items with recorded time intervals'
46
- c.switch [:only_timed], default_value: false, negatable: false
47
-
48
31
  # c.desc '[DEPRECATED] Use alternative fuzzy matching for search string'
49
32
  # c.switch [:fuzzy], default_value: false, negatable: false
50
33
 
51
34
  c.desc 'Force exact string matching (case sensitive)'
52
- c.switch %i[x exact], default_value: @config.exact_match?, negatable: @config.exact_match?
35
+ c.switch %i[x exact], default_value: Doing.config.exact_match?, negatable: Doing.config.exact_match?
53
36
 
54
- c.desc 'Show items that *don\'t* match search string'
55
- c.switch [:not], default_value: false, negatable: false
56
37
 
57
38
  c.desc 'Case sensitivity for search string matching [(c)ase-sensitive, (i)gnore, (s)mart]'
58
39
  c.arg_name 'TYPE'
59
40
  c.flag [:case], must_match: REGEX_CASE,
60
- default_value: @settings.dig('search', 'case').normalize_case,
41
+ default_value: Doing.settings.dig('search', 'case').normalize_case,
61
42
  type: CaseSymbol
62
43
 
63
44
  c.desc "Highlight search matches in output. Only affects command line output"
64
- c.switch %i[h hilite], default_value: @settings.dig('search', 'highlight')
45
+ c.switch %i[h hilite], default_value: Doing.settings.dig('search', 'highlight')
65
46
 
66
47
  c.desc "Edit matching entries with #{Doing::Util.default_editor}"
67
48
  c.switch %i[e editor], negatable: false, default_value: false
@@ -72,23 +53,15 @@ command %i[grep search] do |c|
72
53
  c.desc 'Display an interactive menu of results to perform further operations'
73
54
  c.switch %i[i interactive], default_value: false, negatable: false
74
55
 
75
- c.desc 'Perform a tag value query ("@done > two hours ago" or "@progress < 50"). May be used multiple times, combined with --bool'
76
- c.arg_name 'QUERY'
77
- c.flag [:val], multiple: true, must_match: REGEX_VALUE_QUERY
78
-
79
- c.desc 'Combine multiple tags or value queries using AND, OR, or NOT'
80
- c.arg_name 'BOOLEAN'
81
- c.flag [:bool], must_match: REGEX_BOOL,
82
- default_value: :pattern,
83
- type: BooleanSymbol
84
-
56
+ add_options(:tag_filter, c)
85
57
  add_options(:date_filter, c)
58
+ add_options(:time_display, c)
86
59
 
87
60
  c.action do |_global_options, options, args|
88
61
  options[:fuzzy] = false
89
62
  raise DoingRuntimeError, %(Invalid output type "#{options[:output]}") if options[:output] && options[:output] !~ Doing::Plugins.plugin_regex(type: :export)
90
63
 
91
- template = @settings['templates'][options[:config_template]].deep_merge(@settings)
64
+ template = Doing.setting(['templates', options[:config_template]]).deep_merge(Doing.settings)
92
65
  tags_color = template.key?('tags_color') ? template['tags_color'] : nil
93
66
 
94
67
  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]
@@ -21,7 +21,7 @@ command :meanwhile do |c|
21
21
  add_options(:add_entry, c)
22
22
 
23
23
  c.action do |_global_options, options, args|
24
- @wwid.auto_tag = !options[:noauto]
24
+ Doing.auto_tag = !options[:noauto]
25
25
 
26
26
  if options[:back]
27
27
  date = options[:back]
@@ -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
@@ -37,7 +37,7 @@ command %i[now next] do |c|
37
37
  # # c.flag [:a, :app]
38
38
 
39
39
  c.action do |_global_options, options, args|
40
- @wwid.auto_tag = !options[:noauto]
40
+ Doing.auto_tag = !options[:noauto]
41
41
 
42
42
  raise InvalidArgument, '--back and --from cannot be used together' if options[:back] && options[:from]
43
43
 
@@ -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
@@ -13,20 +13,6 @@ command :on do |c|
13
13
  c.arg_name 'NAME'
14
14
  c.flag %i[s section], default_value: 'All'
15
15
 
16
- c.desc 'Show time intervals on @done tasks'
17
- c.switch %i[t times], default_value: true, negatable: true
18
-
19
- c.desc 'Show elapsed time on entries without @done tag'
20
- c.switch [:duration]
21
-
22
- c.desc 'Show time totals at the end of output'
23
- c.switch [:totals], default_value: false, negatable: false
24
-
25
- c.desc 'Sort tags by (name|time)'
26
- default = @settings['tag_sort'].normalize_tag_sort || :name
27
- c.arg_name 'KEY'
28
- c.flag [:tag_sort], must_match: REGEX_TAG_SORT, default_value: default, type: TagSortSymbol
29
-
30
16
  c.desc "Output to export format (#{Doing::Plugins.plugin_names(type: :export)})"
31
17
  c.arg_name 'FORMAT'
32
18
  c.flag %i[o output]
@@ -39,6 +25,11 @@ command :on do |c|
39
25
  c.arg_name 'TEMPLATE_STRING'
40
26
  c.flag [:template]
41
27
 
28
+ add_options(:time_display, c)
29
+ add_options(:search, c)
30
+ add_options(:tag_filter, c)
31
+ add_options(:time_filter, c)
32
+
42
33
  c.action do |_global_options, options, args|
43
34
  raise DoingRuntimeError, %(Invalid output type "#{options[:output]}") if options[:output] && options[:output] !~ Doing::Plugins.plugin_regex(type: :export)
44
35
 
@@ -59,7 +50,6 @@ command :on do |c|
59
50
  options[:times] = true if options[:totals]
60
51
  options[:sort_tags] = options[:tag_sort]
61
52
 
62
- Doing::Pager.page @wwid.list_date([start, finish], options[:section], options[:times], options[:output],
63
- { template: options[:template], config_template: options[:config_template], duration: options[:duration], totals: options[:totals], sort_tags: options[:sort_tags] }).chomp
53
+ Doing::Pager.page @wwid.list_date([start, finish], options[:section], options[:times], options[:output], options).chomp
64
54
  end
65
55
  end