na 1.2.73 → 1.2.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/commands/find.rb CHANGED
@@ -2,111 +2,111 @@
2
2
 
3
3
  class App
4
4
  extend GLI::App
5
- desc 'Find actions matching a search pattern'
6
- long_desc 'Search tokens are separated by spaces. Actions matching all tokens in the pattern will be shown
5
+ desc "Find actions matching a search pattern"
6
+ long_desc "Search tokens are separated by spaces. Actions matching all tokens in the pattern will be shown
7
7
  (partial matches allowed). Add a + before a token to make it required, e.g. `na find +feature +maybe`,
8
- add a - or ! to ignore matches containing that token.'
9
- arg_name 'PATTERN'
8
+ add a - or ! to ignore matches containing that token."
9
+ arg_name "PATTERN"
10
10
  command %i[find grep search] do |c|
11
- c.example 'na find feature idea swift', desc: 'Find all actions containing feature, idea, and swift'
12
- c.example 'na find feature idea -swift', desc: 'Find all actions containing feature and idea but NOT swift'
13
- c.example 'na find -x feature idea', desc: 'Find all actions containing the exact text "feature idea"'
11
+ c.example "na find feature idea swift", desc: "Find all actions containing feature, idea, and swift"
12
+ c.example "na find feature idea -swift", desc: "Find all actions containing feature and idea but NOT swift"
13
+ c.example "na find -x feature idea", desc: 'Find all actions containing the exact text "feature idea"'
14
14
 
15
- c.desc 'Interpret search pattern as regular expression'
15
+ c.desc "Interpret search pattern as regular expression"
16
16
  c.switch %i[e regex], negatable: false
17
17
 
18
- c.desc 'Match pattern exactly'
18
+ c.desc "Match pattern exactly"
19
19
  c.switch %i[x exact], negatable: false
20
20
 
21
- c.desc 'Recurse to depth'
22
- c.arg_name 'DEPTH'
21
+ c.desc "Recurse to depth"
22
+ c.arg_name "DEPTH"
23
23
  c.flag %i[d depth], type: :integer, must_match: /^\d+$/
24
24
 
25
- c.desc 'Show actions from a specific todo file in history. May use wildcards (* and ?)'
26
- c.arg_name 'TODO_PATH'
25
+ c.desc "Show actions from a specific todo file in history. May use wildcards (* and ?)"
26
+ c.arg_name "TODO_PATH"
27
27
  c.flag %i[in]
28
28
 
29
- c.desc 'Include notes in output'
29
+ c.desc "Include notes in output"
30
30
  c.switch %i[notes], negatable: true, default_value: false
31
31
 
32
- c.desc 'Include notes in search'
32
+ c.desc "Include notes in search"
33
33
  c.switch %i[search_notes], negatable: true, default_value: true
34
34
 
35
- c.desc 'Combine search tokens with OR, displaying actions matching ANY of the terms'
35
+ c.desc "Combine search tokens with OR, displaying actions matching ANY of the terms"
36
36
  c.switch %i[o or], negatable: false
37
37
 
38
- c.desc 'Show actions from a specific project'
39
- c.arg_name 'PROJECT[/SUBPROJECT]'
38
+ c.desc "Show actions from a specific project"
39
+ c.arg_name "PROJECT[/SUBPROJECT]"
40
40
  c.flag %i[proj project]
41
41
 
42
- c.desc 'Match actions containing tag. Allows value comparisons'
43
- c.arg_name 'TAG'
42
+ c.desc "Match actions containing tag. Allows value comparisons"
43
+ c.arg_name "TAG"
44
44
  c.flag %i[tagged], multiple: true
45
45
 
46
- c.desc 'Include @done actions'
46
+ c.desc "Include @done actions"
47
47
  c.switch %i[done]
48
48
 
49
- c.desc 'Show actions not matching search pattern'
49
+ c.desc "Show actions not matching search pattern"
50
50
  c.switch %i[v invert], negatable: false
51
51
 
52
- c.desc 'Save this search for future use'
53
- c.arg_name 'TITLE'
52
+ c.desc "Save this search for future use"
53
+ c.arg_name "TITLE"
54
54
  c.flag %i[save]
55
55
 
56
- c.desc 'Output actions nested by file'
56
+ c.desc "Output actions nested by file"
57
57
  c.switch %[nest], negatable: false
58
58
 
59
- c.desc 'Output actions nested by file and project'
59
+ c.desc "Output actions nested by file and project"
60
60
  c.switch %[omnifocus], negatable: false
61
61
 
62
62
  c.action do |global_options, options, args|
63
63
  options[:nest] = true if options[:omnifocus]
64
64
 
65
65
  if options[:save]
66
- title = options[:save].gsub(/[^a-z0-9]/, '_').gsub(/_+/, '_')
67
- cmd = NA.command_line.join(' ').sub(/ --save[= ]*\S+/, '').split(' ').map { |t| %("#{t}") }.join(' ')
66
+ title = options[:save].gsub(/[^a-z0-9]/, "_").gsub(/_+/, "_")
67
+ cmd = NA.command_line.join(" ").sub(/ --save[= ]*\S+/, "").split(" ").map { |t| %("#{t}") }.join(" ")
68
68
  NA.save_search(title, cmd)
69
69
  end
70
70
 
71
71
  depth = if global_options[:recurse] && options[:depth].nil? && global_options[:depth] == 1
72
- 3
73
- else
74
- options[:depth].nil? ? global_options[:depth].to_i : options[:depth].to_i
75
- end
72
+ 3
73
+ else
74
+ options[:depth].nil? ? global_options[:depth].to_i : options[:depth].to_i
75
+ end
76
76
 
77
77
  if options[:exact] || options[:regex]
78
- search = args.join(' ')
78
+ search = args.join(" ")
79
79
  else
80
80
  rx = [
81
81
  '(?<=\A|[ ,])(?<req>[+!-])?@(?<tag>[^ *=<>$*\^,@(]+)',
82
82
  '(?:\((?<value>.*?)\)| *(?<op>[=<>~]{1,2}|[*$\^]=) *',
83
- '(?<val>.*?(?=\Z|[,@])))?'
84
- ].join('')
85
- search = args.join(' ').gsub(Regexp.new(rx)) do
83
+ '(?<val>.*?(?=\Z|[,@])))?',
84
+ ].join("")
85
+ search = args.join(" ").gsub(Regexp.new(rx)) do
86
86
  m = Regexp.last_match
87
- string = if m['value']
88
- "#{m['req']}#{m['tag']}=#{m['value']}"
89
- else
90
- m[0]
91
- end
92
- options[:tagged] << string.sub(/@/, '')
93
- ''
87
+ string = if m["value"]
88
+ "#{m["req"]}#{m["tag"]}=#{m["value"]}"
89
+ else
90
+ m[0]
91
+ end
92
+ options[:tagged] << string.sub(/@/, "")
93
+ ""
94
94
  end
95
95
  end
96
96
 
97
- search = search.gsub(/ +/, ' ').strip
97
+ search = search.gsub(/ +/, " ").strip
98
98
 
99
- all_req = options[:tagged].join(' ') !~ /(?<=[, ])[+!-]/ && !options[:or]
99
+ all_req = options[:tagged].join(" ") !~ /(?<=[, ])[+!-]/ && !options[:or]
100
100
  tags = []
101
- options[:tagged].join(',').split(/ *, */).each do |arg|
101
+ options[:tagged].join(",").split(/ *, */).each do |arg|
102
102
  m = arg.match(/^(?<req>[+!-])?(?<tag>[^ =<>$~\^]+?) *(?:(?<op>[=<>~]{1,2}|[*$\^]=) *(?<val>.*?))?$/)
103
103
 
104
104
  tags.push({
105
- tag: m['tag'].wildcard_to_rx,
106
- comp: m['op'],
107
- value: m['val'],
108
- required: all_req || (!m['req'].nil? && m['req'] == '+'),
109
- negate: !m['req'].nil? && m['req'] =~ /[!-]/ ? true : false
105
+ tag: m["tag"].wildcard_to_rx,
106
+ comp: m["op"],
107
+ value: m["val"],
108
+ required: all_req || (!m["req"].nil? && m["req"] == "+"),
109
+ negate: !m["req"].nil? && m["req"] =~ /[!-]/ ? true : false,
110
110
  })
111
111
  end
112
112
 
@@ -127,9 +127,9 @@ class App
127
127
  m = arg.match(/^(?<req>[+\-!])?(?<tok>.*?)$/)
128
128
 
129
129
  tokens.push({
130
- token: m['tok'],
131
- required: all_req || (!m['req'].nil? && m['req'] == '+'),
132
- negate: !m['req'].nil? && m['req'] =~ /[!-]/ ? true : false
130
+ token: m["tok"],
131
+ required: all_req || (!m["req"].nil? && m["req"] == "+"),
132
+ negate: !m["req"].nil? && m["req"] =~ /[!-]/ ? true : false,
133
133
  })
134
134
  end
135
135
  end
@@ -140,9 +140,9 @@ class App
140
140
  options[:in].split(/ *, */).each do |a|
141
141
  m = a.match(/^(?<req>[+\-!])?(?<tok>.*?)$/)
142
142
  todos.push({
143
- token: m['tok'],
144
- required: all_req || (!m['req'].nil? && m['req'] == '+'),
145
- negate: !m['req'].nil? && m['req'] =~ /[!-]/
143
+ token: m["tok"],
144
+ required: all_req || (!m["req"].nil? && m["req"] == "+"),
145
+ negate: !m["req"].nil? && m["req"] =~ /[!-]/,
146
146
  })
147
147
  end
148
148
  end
@@ -157,21 +157,21 @@ class App
157
157
  negate: options[:invert],
158
158
  regex: options[:regex],
159
159
  project: options[:project],
160
- require_na: false
160
+ require_na: false,
161
161
  })
162
162
 
163
163
  regexes = if tokens.is_a?(Array)
164
- tokens.delete_if { |token| token[:negate] }.map { |token| token[:token].wildcard_to_rx }
165
- else
166
- [tokens]
167
- end
164
+ tokens.delete_if { |token| token[:negate] }.map { |token| token[:token].wildcard_to_rx }
165
+ else
166
+ [tokens]
167
+ end
168
168
 
169
169
  todo.actions.output(depth,
170
- files: todo.files,
171
- regexes: regexes,
172
- notes: options[:notes],
173
- nest: options[:nest],
174
- nest_projects: options[:omnifocus])
170
+ { files: todo.files,
171
+ regexes: regexes,
172
+ notes: options[:notes],
173
+ nest: options[:nest],
174
+ nest_projects: options[:omnifocus] })
175
175
  end
176
176
  end
177
177
  end
data/bin/commands/next.rb CHANGED
@@ -2,108 +2,108 @@
2
2
 
3
3
  class App
4
4
  extend GLI::App
5
- desc 'Show next actions'
5
+ desc "Show next actions"
6
6
  long_desc 'Next actions are actions which contain the next action tag (default @na),
7
7
  do not contain @done, and are not in the Archive project.
8
8
 
9
9
  Arguments will target a todo file from history, whether it\'s in the current
10
10
  directory or not. Todo file queries can include path components separated by /
11
11
  or :, and may use wildcards (`*` to match any text, `?` to match a single character). Multiple queries allowed (separate arguments or separated by comma).'
12
- arg_name 'QUERY', optional: true
12
+ arg_name "QUERY", optional: true
13
13
  command %i[next show] do |c|
14
- c.example 'na next', desc: 'display the next actions from any todo files in the current directory'
15
- c.example 'na next -d 3', desc: 'display the next actions from the current directory, traversing 3 levels deep'
16
- c.example 'na next marked', desc: 'display next actions for a project you visited in the past'
14
+ c.example "na next", desc: "display the next actions from any todo files in the current directory"
15
+ c.example "na next -d 3", desc: "display the next actions from the current directory, traversing 3 levels deep"
16
+ c.example "na next marked", desc: "display next actions for a project you visited in the past"
17
17
 
18
- c.desc 'Recurse to depth'
19
- c.arg_name 'DEPTH'
18
+ c.desc "Recurse to depth"
19
+ c.arg_name "DEPTH"
20
20
  c.flag %i[d depth], type: :integer, must_match: /^[1-9]$/
21
21
 
22
- c.desc 'Show next actions from all known todo files (in any directory)'
22
+ c.desc "Show next actions from all known todo files (in any directory)"
23
23
  c.switch %i[all], negatable: false, default_value: false
24
24
 
25
- c.desc 'Display matches from a known todo file anywhere in history (short name)'
26
- c.arg_name 'TODO'
25
+ c.desc "Display matches from a known todo file anywhere in history (short name)"
26
+ c.arg_name "TODO"
27
27
  c.flag %i[in todo], multiple: true
28
28
 
29
- c.desc 'Display matches from specific todo file ([relative] path)'
30
- c.arg_name 'TODO_FILE'
29
+ c.desc "Display matches from specific todo file ([relative] path)"
30
+ c.arg_name "TODO_FILE"
31
31
  c.flag %i[file]
32
32
 
33
- c.desc 'Alternate tag to search for'
34
- c.arg_name 'TAG'
33
+ c.desc "Alternate tag to search for"
34
+ c.arg_name "TAG"
35
35
  c.flag %i[t tag]
36
36
 
37
- c.desc 'Show actions from a specific project'
38
- c.arg_name 'PROJECT[/SUBPROJECT]'
37
+ c.desc "Show actions from a specific project"
38
+ c.arg_name "PROJECT[/SUBPROJECT]"
39
39
  c.flag %i[proj project]
40
40
 
41
- c.desc 'Match actions containing tag. Allows value comparisons'
42
- c.arg_name 'TAG'
41
+ c.desc "Match actions containing tag. Allows value comparisons"
42
+ c.arg_name "TAG"
43
43
  c.flag %i[tagged], multiple: true
44
44
 
45
- c.desc 'Match actions with priority, allows <>= comparison'
46
- c.arg_name 'PRIORITY'
45
+ c.desc "Match actions with priority, allows <>= comparison"
46
+ c.arg_name "PRIORITY"
47
47
  c.flag %i[p prio priority], multiple: true
48
48
 
49
- c.desc 'Filter results using search terms'
50
- c.arg_name 'QUERY'
49
+ c.desc "Filter results using search terms"
50
+ c.arg_name "QUERY"
51
51
  c.flag %i[search find grep], multiple: true
52
52
 
53
- c.desc 'Include notes in search'
53
+ c.desc "Include notes in search"
54
54
  c.switch %i[search_notes], negatable: true, default_value: true
55
55
 
56
- c.desc 'Search query is regular expression'
56
+ c.desc "Search query is regular expression"
57
57
  c.switch %i[regex], negatable: false
58
58
 
59
- c.desc 'Search query is exact text match (not tokens)'
59
+ c.desc "Search query is exact text match (not tokens)"
60
60
  c.switch %i[exact], negatable: false
61
61
 
62
- c.desc 'Include notes in output'
62
+ c.desc "Include notes in output"
63
63
  c.switch %i[notes], negatable: true, default_value: false
64
64
 
65
- c.desc 'Include @done actions'
65
+ c.desc "Include @done actions"
66
66
  c.switch %i[done]
67
67
 
68
- c.desc 'Output actions nested by file'
68
+ c.desc "Output actions nested by file"
69
69
  c.switch %i[nest], negatable: false
70
70
 
71
- c.desc 'No filename in output'
71
+ c.desc "No filename in output"
72
72
  c.switch %i[no_file], negatable: false
73
73
 
74
- c.desc 'Output actions nested by file and project'
74
+ c.desc "Output actions nested by file and project"
75
75
  c.switch %i[omnifocus], negatable: false
76
76
 
77
- c.desc 'Save this search for future use'
78
- c.arg_name 'TITLE'
77
+ c.desc "Save this search for future use"
78
+ c.arg_name "TITLE"
79
79
  c.flag %i[save]
80
80
 
81
81
  c.action do |global_options, options, args|
82
82
  # For backward compatibility with na -a
83
83
  if global_options[:add]
84
- cmd = ['add']
85
- cmd.push('--note') if global_options[:note]
86
- cmd.concat(['--priority', global_options[:priority]]) if global_options[:priority]
84
+ cmd = ["add"]
85
+ cmd.push("--note") if global_options[:note]
86
+ cmd.concat(["--priority", global_options[:priority]]) if global_options[:priority]
87
87
  cmd.push(NA.command_line) if NA.command_line.count > 1
88
88
  cmd.unshift(*NA.globals)
89
89
  exit run(cmd)
90
90
  end
91
91
 
92
92
  if options[:save]
93
- title = options[:save].gsub(/[^a-z0-9]/, '_').gsub(/_+/, '_')
94
- NA.save_search(title, "#{NA.command_line.join(' ').sub(/ --save[= ]*\S+/, '').split(' ').map { |t| %("#{t}") }.join(' ')}")
93
+ title = options[:save].gsub(/[^a-z0-9]/, "_").gsub(/_+/, "_")
94
+ NA.save_search(title, "#{NA.command_line.join(" ").sub(/ --save[= ]*\S+/, "").split(" ").map { |t| %("#{t}") }.join(" ")}")
95
95
  end
96
96
 
97
97
  options[:nest] = true if options[:omnifocus]
98
98
 
99
99
  depth = if global_options[:recurse] && options[:depth].nil? && global_options[:depth] == 1
100
- 3
101
- else
102
- options[:depth].nil? ? global_options[:depth].to_i : options[:depth].to_i
103
- end
100
+ 3
101
+ else
102
+ options[:depth].nil? ? global_options[:depth].to_i : options[:depth].to_i
103
+ end
104
104
 
105
105
  if options[:exact] || options[:regex]
106
- search = options[:search].join(' ')
106
+ search = options[:search].join(" ")
107
107
  else
108
108
  # This regex matches the following:
109
109
  # @tag(value)
@@ -113,74 +113,74 @@ class App
113
113
  rx = [
114
114
  '(?<=\A|[ ,])(?<req>[+!-])?@(?<tag>[^ *=<>$~\^,@(]+)',
115
115
  '(?:\((?<value>.*?)\)| *(?<op>=~|[=<>~]{1,2}|[*$\^]=) *',
116
- '(?<val>.*?(?=\Z|[,@])))?'
117
- ].join('')
116
+ '(?<val>.*?(?=\Z|[,@])))?',
117
+ ].join("")
118
118
  # convert tag(value) to tag=value
119
- search = options[:search].join(' ').gsub(Regexp.new(rx)) do
119
+ search = options[:search].join(" ").gsub(Regexp.new(rx)) do
120
120
  m = Regexp.last_match
121
- string = if m['value']
122
- "#{m['req']}#{m['tag']}=#{m['value']}"
123
- else
124
- m[0]
125
- end
126
- options[:tagged] << string.sub(/@/, '')
127
- ''
121
+ string = if m["value"]
122
+ "#{m["req"]}#{m["tag"]}=#{m["value"]}"
123
+ else
124
+ m[0]
125
+ end
126
+ options[:tagged] << string.sub(/@/, "")
127
+ ""
128
128
  end
129
129
  end
130
130
 
131
- search = search.gsub(/,/, '').gsub(/ +/, ' ') unless search.nil?
131
+ search = search.gsub(/,/, "").gsub(/ +/, " ") unless search.nil?
132
132
 
133
133
  if options[:priority].count.positive?
134
- prios = options[:priority].join(',').split(/,/)
134
+ prios = options[:priority].join(",").split(/,/)
135
135
  options[:or] = true if prios.count > 1
136
136
  prios.map! do |p|
137
137
  p.sub(/([hml])$/) do
138
138
  case Regexp.last_match[1]
139
- when 'h'
140
- NA.priority_map['h']
141
- when 'm'
142
- NA.priority_map['m']
143
- when 'l'
144
- NA.priority_map['l']
139
+ when "h"
140
+ NA.priority_map["h"]
141
+ when "m"
142
+ NA.priority_map["m"]
143
+ when "l"
144
+ NA.priority_map["l"]
145
145
  end
146
146
  end
147
147
  end
148
148
  prios.each do |p|
149
149
  options[:tagged] << if p =~ /^[<>=]{1,2}/
150
- "priority#{p}"
151
- else
152
- "priority=#{p}"
153
- end
150
+ "priority#{p}"
151
+ else
152
+ "priority=#{p}"
153
+ end
154
154
  end
155
155
  end
156
156
 
157
- all_req = options[:tagged].join(' ') !~ /(?<=[, ])[+!-]/ && !options[:or]
157
+ all_req = options[:tagged].join(" ") !~ /(?<=[, ])[+!-]/ && !options[:or]
158
158
  tags = []
159
- options[:tagged].join(',').split(/ *, */).each do |arg|
159
+ options[:tagged].join(",").split(/ *, */).each do |arg|
160
160
  m = arg.match(/^(?<req>[+!-])?(?<tag>[^ =<>$~\^]+?) *(?:(?<op>[=<>~]{1,2}|[*$\^]=) *(?<val>.*?))?$/)
161
161
 
162
162
  tags.push({
163
- tag: m['tag'].wildcard_to_rx,
164
- comp: m['op'],
165
- value: m['val'],
166
- required: all_req || (!m['req'].nil? && m['req'] == '+'),
167
- negate: !m['req'].nil? && m['req'] =~ /[!-]/ ? true : false
163
+ tag: m["tag"].wildcard_to_rx,
164
+ comp: m["op"],
165
+ value: m["val"],
166
+ required: all_req || (!m["req"].nil? && m["req"] == "+"),
167
+ negate: !m["req"].nil? && m["req"] =~ /[!-]/ ? true : false,
168
168
  })
169
169
  end
170
170
 
171
171
  args.concat(options[:in])
172
- args << '*' if options[:all]
172
+ args << "*" if options[:all]
173
173
  if args.count.positive?
174
- all_req = args.join(' ') !~ /(?<=[, ])[+!-]/
174
+ all_req = args.join(" ") !~ /(?<=[, ])[+!-]/
175
175
 
176
176
  tokens = []
177
177
  args.each do |arg|
178
178
  arg.split(/ *, */).each do |a|
179
179
  m = a.match(/^(?<req>[+!-])?(?<tok>.*?)$/)
180
180
  tokens.push({
181
- token: m['tok'],
182
- required: !m['req'].nil? && m['req'] == '+',
183
- negate: !m['req'].nil? && m['req'] =~ /[!-]/ ? true : false
181
+ token: m["tok"],
182
+ required: !m["req"].nil? && m["req"] == "+",
183
+ negate: !m["req"].nil? && m["req"] =~ /[!-]/ ? true : false,
184
184
  })
185
185
  end
186
186
  end
@@ -200,9 +200,9 @@ class App
200
200
  search.split(/ /).each do |arg|
201
201
  m = arg.match(/^(?<req>[+\-!])?(?<tok>.*?)$/)
202
202
  search_tokens.push({
203
- token: m['tok'],
204
- required: all_req || (!m['req'].nil? && m['req'] == '+'),
205
- negate: !m['req'].nil? && m['req'] =~ /[!-]/ ? true : false
203
+ token: m["tok"],
204
+ required: all_req || (!m["req"].nil? && m["req"] == "+"),
205
+ negate: !m["req"].nil? && m["req"] =~ /[!-]/ ? true : false,
206
206
  })
207
207
  end
208
208
  end
@@ -211,7 +211,7 @@ class App
211
211
  require_na = true
212
212
 
213
213
  tag = [{ tag: NA.na_tag, value: nil, required: true, negate: false }]
214
- tag << { tag: 'done', value: nil, negate: true } unless options[:done]
214
+ tag << { tag: "done", value: nil, negate: true } unless options[:done]
215
215
  tag.concat(tags)
216
216
 
217
217
  file_path = options[:file] ? File.expand_path(options[:file]) : nil
@@ -231,11 +231,11 @@ class App
231
231
  end
232
232
  NA::Pager.paginate = false if options[:omnifocus]
233
233
  todo.actions.output(depth,
234
- files: todo.files,
235
- nest: options[:nest],
236
- nest_projects: options[:omnifocus],
237
- notes: options[:notes],
238
- no_files: options[:no_file])
234
+ { files: todo.files,
235
+ nest: options[:nest],
236
+ nest_projects: options[:omnifocus],
237
+ notes: options[:notes],
238
+ no_files: options[:no_file] })
239
239
  end
240
240
  end
241
241
  end