doing 2.1.30 → 2.1.31pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.irbrc +1 -0
  3. data/.yardoc/checksums +9 -8
  4. data/.yardoc/object_types +0 -0
  5. data/.yardoc/objects/root.dat +0 -0
  6. data/CHANGELOG.md +4923 -0
  7. data/Gemfile.lock +1 -1
  8. data/README.md +1 -1
  9. data/bin/commands/again.rb +1 -1
  10. data/bin/commands/archive.rb +3 -3
  11. data/bin/commands/cancel.rb +1 -1
  12. data/bin/commands/commands.rb +8 -8
  13. data/bin/commands/completion.rb +61 -19
  14. data/bin/commands/config.rb +9 -9
  15. data/bin/commands/done.rb +1 -1
  16. data/bin/commands/flag.rb +1 -1
  17. data/bin/commands/grep.rb +5 -5
  18. data/bin/commands/last.rb +1 -1
  19. data/bin/commands/meanwhile.rb +1 -1
  20. data/bin/commands/now.rb +1 -1
  21. data/bin/commands/on.rb +1 -1
  22. data/bin/commands/open.rb +1 -1
  23. data/bin/commands/recent.rb +4 -4
  24. data/bin/commands/show.rb +8 -8
  25. data/bin/commands/since.rb +1 -1
  26. data/bin/commands/today.rb +1 -1
  27. data/bin/commands/view.rb +3 -3
  28. data/bin/commands/yesterday.rb +2 -2
  29. data/bin/doing +22 -133
  30. data/docs/doc/Array.html +1 -1
  31. data/docs/doc/BooleanTermParser/Clause.html +1 -1
  32. data/docs/doc/BooleanTermParser/Operator.html +1 -1
  33. data/docs/doc/BooleanTermParser/Query.html +1 -1
  34. data/docs/doc/BooleanTermParser/QueryParser.html +1 -1
  35. data/docs/doc/BooleanTermParser/QueryTransformer.html +1 -1
  36. data/docs/doc/BooleanTermParser.html +1 -1
  37. data/docs/doc/Doing/Color.html +1 -1
  38. data/docs/doc/Doing/Completion.html +324 -4
  39. data/docs/doc/Doing/Configuration.html +1 -1
  40. data/docs/doc/Doing/Errors/DoingNoTraceError.html +1 -1
  41. data/docs/doc/Doing/Errors/DoingRuntimeError.html +1 -1
  42. data/docs/doc/Doing/Errors/DoingStandardError.html +1 -1
  43. data/docs/doc/Doing/Errors/EmptyInput.html +1 -1
  44. data/docs/doc/Doing/Errors/NoResults.html +1 -1
  45. data/docs/doc/Doing/Errors/PluginException.html +1 -1
  46. data/docs/doc/Doing/Errors/UserCancelled.html +1 -1
  47. data/docs/doc/Doing/Errors/WrongCommand.html +1 -1
  48. data/docs/doc/Doing/Errors.html +1 -1
  49. data/docs/doc/Doing/Hooks.html +1 -1
  50. data/docs/doc/Doing/Item.html +125 -1
  51. data/docs/doc/Doing/Items.html +1 -1
  52. data/docs/doc/Doing/LogAdapter.html +1 -1
  53. data/docs/doc/Doing/Note.html +109 -3
  54. data/docs/doc/Doing/Pager.html +1 -1
  55. data/docs/doc/Doing/Plugins.html +1 -1
  56. data/docs/doc/Doing/Prompt.html +1 -1
  57. data/docs/doc/Doing/Section.html +1 -1
  58. data/docs/doc/Doing/TemplateString.html +1 -1
  59. data/docs/doc/Doing/Types.html +1 -1
  60. data/docs/doc/Doing/Util/Backup.html +1 -1
  61. data/docs/doc/Doing/Util.html +1 -1
  62. data/docs/doc/Doing/WWID.html +6 -6
  63. data/docs/doc/Doing.html +2 -2
  64. data/docs/doc/FalseClass.html +1 -1
  65. data/docs/doc/GLI/Commands/Help.html +1 -1
  66. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +1 -1
  67. data/docs/doc/GLI/Commands.html +1 -1
  68. data/docs/doc/GLI.html +1 -1
  69. data/docs/doc/Hash.html +1 -1
  70. data/docs/doc/Object.html +1 -1
  71. data/docs/doc/PhraseParser/Operator.html +1 -1
  72. data/docs/doc/PhraseParser/PhraseClause.html +1 -1
  73. data/docs/doc/PhraseParser/Query.html +1 -1
  74. data/docs/doc/PhraseParser/QueryParser.html +1 -1
  75. data/docs/doc/PhraseParser/QueryTransformer.html +1 -1
  76. data/docs/doc/PhraseParser/TermClause.html +1 -1
  77. data/docs/doc/PhraseParser.html +1 -1
  78. data/docs/doc/Status.html +1 -1
  79. data/docs/doc/String.html +1 -1
  80. data/docs/doc/Symbol.html +1 -1
  81. data/docs/doc/Time.html +1 -1
  82. data/docs/doc/TrueClass.html +1 -1
  83. data/docs/doc/_index.html +3 -1
  84. data/docs/doc/file.README.html +2 -2
  85. data/docs/doc/index.html +2 -2
  86. data/docs/doc/method_list.html +337 -241
  87. data/docs/doc/top-level-namespace.html +105 -1
  88. data/doing.rdoc +25 -9
  89. data/example_plugin.rb +7 -5
  90. data/lib/completion/_doing.zsh +2 -2
  91. data/lib/completion/doing.bash +2 -2
  92. data/lib/completion/doing.fish +2 -3
  93. data/lib/doing/add_options.rb +117 -0
  94. data/lib/doing/array/array.rb +16 -0
  95. data/lib/doing/completion/bash_completion.rb +12 -51
  96. data/lib/doing/completion/fish_completion.rb +16 -52
  97. data/lib/doing/completion/zsh_completion.rb +12 -56
  98. data/lib/doing/completion.rb +203 -17
  99. data/lib/doing/item.rb +21 -3
  100. data/lib/doing/items.rb +5 -5
  101. data/lib/doing/note.rb +24 -8
  102. data/lib/doing/plugins/export/dayone_export.rb +8 -6
  103. data/lib/doing/plugins/export/html_export.rb +4 -4
  104. data/lib/doing/plugins/export/json_export.rb +19 -20
  105. data/lib/doing/plugins/export/markdown_export.rb +2 -2
  106. data/lib/doing/plugins/export/template_export.rb +4 -4
  107. data/lib/doing/plugins/import/calendar_import.rb +1 -1
  108. data/lib/doing/plugins/import/doing_import.rb +1 -1
  109. data/lib/doing/plugins/import/timing_import.rb +1 -1
  110. data/lib/doing/string/highlight.rb +3 -4
  111. data/lib/doing/string/string.rb +8 -0
  112. data/lib/doing/util.rb +1 -1
  113. data/lib/doing/util_backup.rb +12 -12
  114. data/lib/doing/version.rb +1 -1
  115. data/lib/doing/wwid.rb +76 -77
  116. data/lib/doing.rb +57 -0
  117. data/lib/examples/commands/wiki.rb +27 -19
  118. data/scripts/setting_replace.rb +11 -0
  119. metadata +6 -4
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.31pre)
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.29<!--END VER-->.
11
+ The current version of `doing` is <!--VER-->2.1.30<!--END VER-->.
12
12
 
13
13
  Find all of the documentation in the [doing wiki][wiki].
14
14
 
@@ -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
 
@@ -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]
@@ -201,7 +201,7 @@ command :config do |c|
201
201
 
202
202
  value = options[:remove] ? nil : args.pop
203
203
  keypath = args.join('.')
204
- real_path = @config.resolve_key_path(keypath, create: true)
204
+ real_path = Doing.config.resolve_key_path(keypath, create: true)
205
205
  old_value = @settings.dig(*real_path)
206
206
  old_type = old_value&.class.to_s || nil
207
207
 
@@ -216,7 +216,7 @@ command :config do |c|
216
216
 
217
217
  end
218
218
 
219
- config_file = @config.choose_config(create: true)
219
+ config_file = Doing.config.choose_config(create: true)
220
220
 
221
221
  cfg = Doing::Util.safe_load_file(config_file) || {}
222
222
 
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,7 +1,7 @@
1
1
  # @@open
2
2
  desc 'Open the "doing" file in an editor'
3
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')})."
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)'
@@ -30,7 +30,7 @@ command :recent do |c|
30
30
  c.switch [:totals], default_value: false, negatable: false
31
31
 
32
32
  c.desc 'Sort tags by (name|time)'
33
- default = @settings['tag_sort'].normalize_tag_sort || :name
33
+ default = Doing.setting('tag_sort').normalize_tag_sort || :name
34
34
  c.arg_name 'KEY'
35
35
  c.flag [:tag_sort], must_match: REGEX_TAG_SORT, default_value: default, type: TagSortSymbol
36
36
 
@@ -41,8 +41,8 @@ command :recent do |c|
41
41
  section = @wwid.guess_section(options[:section]) || options[:section].cap_first
42
42
 
43
43
  unless global_options[:version]
44
- if @settings['templates']['recent'].key?('count')
45
- config_count = @settings['templates']['recent']['count'].to_i
44
+ if Doing.setting('templates.recent.count')
45
+ config_count = Doing.setting('templates.recent.count').to_i
46
46
  else
47
47
  config_count = 10
48
48
  end
@@ -56,7 +56,7 @@ command :recent do |c|
56
56
  options[:times] = true if options[:totals]
57
57
  options[:sort_tags] = options[:tag_sort]
58
58
 
59
- template = @settings['templates']['recent'].deep_merge(@settings['templates']['default'])
59
+ template = Doing.setting('templates.recent').deep_merge(Doing.setting('templates.default'))
60
60
  tags_color = template.key?('tags_color') ? template['tags_color'] : nil
61
61
 
62
62
  opts = {
data/bin/commands/show.rb CHANGED
@@ -27,7 +27,7 @@ command :show do |c|
27
27
  c.flag %i[a age], default_value: :newest, type: AgeSymbol
28
28
 
29
29
  c.desc "Highlight search matches in output. Only affects command line output"
30
- c.switch %i[h hilite], default_value: @settings.dig('search', 'highlight')
30
+ c.switch %i[h hilite], default_value: Doing.settings.dig('search', 'highlight')
31
31
 
32
32
  c.desc 'Sort order (asc/desc)'
33
33
  c.arg_name 'ORDER'
@@ -43,7 +43,7 @@ command :show do |c|
43
43
  c.switch [:totals], default_value: false, negatable: false
44
44
 
45
45
  c.desc 'Sort tags by (name|time)'
46
- default = @settings['tag_sort'].normalize_tag_sort || :name
46
+ default = Doing.setting('tag_sort').normalize_tag_sort || :name
47
47
  c.arg_name 'KEY'
48
48
  c.flag [:tag_sort], must_match: REGEX_TAG_SORT, default_value: default, type: TagSortSymbol
49
49
 
@@ -118,7 +118,7 @@ command :show do |c|
118
118
  end
119
119
  end
120
120
  else
121
- section = options[:menu] ? @wwid.choose_section(include_all: true) : @settings['current_section']
121
+ section = options[:menu] ? @wwid.choose_section(include_all: true) : Doing.setting('current_section')
122
122
  section ||= 'All'
123
123
  end
124
124
 
@@ -126,11 +126,11 @@ command :show do |c|
126
126
 
127
127
  options[:times] = true if options[:totals]
128
128
 
129
- template = @settings['templates'][options[:config_template]].deep_merge({
130
- 'wrap_width' => @settings['wrap_width'] || 0,
131
- 'date_format' => @settings['default_date_format'],
132
- 'order' => @settings['order']&.normalize_order || :asc,
133
- 'tags_color' => @settings['tags_color']
129
+ template = Doing.setting(['templates', options[:config_template]]).deep_merge({
130
+ 'wrap_width' => Doing.setting('wrap_width') || 0,
131
+ 'date_format' => Doing.setting('default_date_format'),
132
+ 'order' => Doing.setting('order')&.normalize_order || :asc,
133
+ 'tags_color' => Doing.setting('tags_color')
134
134
  })
135
135
 
136
136
  if options[:search]
@@ -21,7 +21,7 @@ command :since do |c|
21
21
  c.switch [:totals], default_value: false, negatable: false
22
22
 
23
23
  c.desc 'Sort tags by (name|time)'
24
- default = @settings['tag_sort'].normalize_tag_sort || :name
24
+ default = Doing.setting('tag_sort').normalize_tag_sort || :name
25
25
  c.arg_name 'KEY'
26
26
  c.flag [:tag_sort], must_match: REGEX_TAG_SORT, default_value: default, type: TagSortSymbol
27
27
 
@@ -22,7 +22,7 @@ command :today do |c|
22
22
  c.switch [:totals], default_value: false, negatable: false
23
23
 
24
24
  c.desc 'Sort tags by (name|time)'
25
- default = @settings['tag_sort'].normalize_tag_sort || :name
25
+ default = Doing.setting('tag_sort').normalize_tag_sort || :name
26
26
  c.arg_name 'KEY'
27
27
  c.flag [:tag_sort], must_match: REGEX_TAG_SORT, default_value: default, type: TagSortSymbol
28
28
 
data/bin/commands/view.rb CHANGED
@@ -36,7 +36,7 @@ command :view do |c|
36
36
  c.switch [:color], default_value: true, negatable: true
37
37
 
38
38
  c.desc "Highlight search matches in output. Only affects command line output"
39
- c.switch %i[h hilite], default_value: @settings.dig('search', 'highlight')
39
+ c.switch %i[h hilite], default_value: Doing.settings.dig('search', 'highlight')
40
40
 
41
41
  c.desc 'Sort tags by (name|time)'
42
42
  c.arg_name 'KEY'
@@ -82,7 +82,7 @@ command :view do |c|
82
82
  section = if options[:section]
83
83
  @wwid.guess_section(options[:section]) || options[:section].cap_first
84
84
  else
85
- @settings['current_section']
85
+ Doing.setting('current_section')
86
86
  end
87
87
 
88
88
  view = @wwid.get_view(title)
@@ -134,7 +134,7 @@ command :view do |c|
134
134
  section = if options[:section]
135
135
  section
136
136
  else
137
- view['section'] || @settings['current_section']
137
+ view['section'] || Doing.setting('current_section')
138
138
  end
139
139
  order = if view.key?('order')
140
140
  view['order'].normalize_order
@@ -33,7 +33,7 @@ command :yesterday do |c|
33
33
  c.switch [:totals], default_value: false, negatable: false
34
34
 
35
35
  c.desc 'Sort tags by (name|time)'
36
- default = @settings['tag_sort'].normalize_tag_sort || :name
36
+ default = Doing.setting('tag_sort').normalize_tag_sort || :name
37
37
  c.arg_name 'KEY'
38
38
  c.flag [:tag_sort], must_match: REGEX_TAG_SORT, default_value: default, type: TagSortSymbol
39
39
 
@@ -65,7 +65,7 @@ command :yesterday do |c|
65
65
  end
66
66
 
67
67
  opt = options.clone
68
- opt[:order] = @settings.dig('templates', options[:config_template], 'order')
68
+ opt[:order] = Doing.setting(['templates', options[:config_template], 'order'])
69
69
 
70
70
  Doing::Pager.page @wwid.yesterday(options[:section], options[:times], options[:output], opt).chomp
71
71
  end