na 1.1.5 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3bf171b4029a85c4a1277e989eef561e81306c925e1f816b75158885020df8d
4
- data.tar.gz: e006d499ca796b2d40ee5079fd67c48a36c492882cecb252786805eaeddc3f3e
3
+ metadata.gz: 7a47eb8254efd672fd4a240639516c3100244bada4809f40c6eba9fcb6ba4ea7
4
+ data.tar.gz: b44d9bbd6d91db44c3929bf64d2a45356297272de4a3ee246cf59921c9579d0c
5
5
  SHA512:
6
- metadata.gz: ad1811c1c5c6a9e9198d43ecb2b2fd8b3b14e6290a0b31e48822b4123bf156b5774d97334dba4ecb6f239e645356d087a98e238c64392cc50f47645dd4d2f05b
7
- data.tar.gz: 235473855acaefc65b28eb88cfb21646a98573ad2e2d37fe2c33e5415671ea9b2f8d03e070913a534e21a31632794c3a44ca604da9acbe9e75b8f3c720cd1393
6
+ metadata.gz: f8951228d935af6e614ea068df59060a73c42078f2e63f71242f8a95dfab9225cb86298269a375d684fa3c7617061ef8fb12560fe16429eb80e6e8e7b3a71c25
7
+ data.tar.gz: d944ca6cf975bc996b481ae1764b824298440b63baa098d920fc3ac717c7504d9ab988f38965f2e20ce9844b763809dbb546836319cfc19a504c80ef177477c8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ### 1.1.7
2
+
3
+ 2022-10-02 12:20
4
+
5
+ #### IMPROVED
6
+
7
+ - You can use !token to add negative values to tag/search queries, e.g. `na tagged +maybe !waiting`
8
+
9
+ ### 1.1.6
10
+
11
+ 2022-10-02 11:46
12
+
13
+ #### CHANGED
14
+
15
+ - `na find` and `na tagged` now operate on all actions, not just actions tagged @na. If you want to limit to @na actions, just include +na in the query.
16
+
1
17
  ### 1.1.5
2
18
 
3
19
  2022-10-01 11:32
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- na (1.1.6)
4
+ na (1.1.7)
5
5
  gli (~> 2.21.0)
6
6
  tty-reader (~> 0.9, >= 0.9.0)
7
7
  tty-screen (~> 0.8, >= 0.8.1)
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  _If you're one of the rare people like me who find this useful, feel free to
10
10
  [buy me some coffee][donate]._
11
11
 
12
- The current version of `na` is 1.1.5
12
+ The current version of `na` is 1.1.7
13
13
  .
14
14
 
15
15
  `na` ("next action") is a command line tool designed to make it easy to see what your next actions are for any project, right from the command line. It works with TaskPaper-formatted files (but any plain text format will do), looking for `@na` tags (or whatever you specify) in todo files in your current folder.
data/bin/na CHANGED
@@ -233,16 +233,18 @@ class App
233
233
  else
234
234
  tokens = []
235
235
  args.each do |arg|
236
- m = arg.match(/^(?<req>\+)?(?<tok>.*?)$/)
236
+ m = arg.match(/^(?<req>[+\-!])?(?<tok>.*?)$/)
237
237
  tokens.push({
238
238
  token: m['tok'],
239
- required: !m['req'].nil?
239
+ required: !m['req'].nil? && m['req'] == '+',
240
+ negate: !m['req'].nil? && m['req'] =~ /[!\-]/
240
241
  })
241
242
  end
242
243
  end
243
244
 
244
245
  files, actions = NA.parse_actions(depth: depth,
245
- search: tokens)
246
+ search: tokens,
247
+ require_na: false)
246
248
  NA.output_actions(actions, depth, files: files)
247
249
  end
248
250
  end
@@ -272,17 +274,19 @@ class App
272
274
  tags = []
273
275
  args.each do |arg|
274
276
  # TODO: <> comparisons do nothing right now
275
- m = arg.match(/^(?<req>\+)?(?<tag>[^ =<>]+)(?:(?<op>[=<>]+)(?<val>\S+))?$/)
277
+ m = arg.match(/^(?<req>[+\-!])?(?<tag>[^ =<>]+)(?:(?<op>[=<>]+)(?<val>\S+))?$/)
276
278
  tags.push({
277
279
  tag: m['tag'],
278
280
  comp: m['op'],
279
281
  value: m['val'],
280
- required: !m['req'].nil?
282
+ required: !m['req'].nil? && m['req'] == '+',
283
+ negate: !m['req'].nil? && m['req'] =~ /[!\-]/
281
284
  })
282
285
  end
283
286
 
284
287
  files, actions = NA.parse_actions(depth: depth,
285
- tag: tags)
288
+ tag: tags,
289
+ require_na: false)
286
290
  NA.output_actions(actions, depth, files: files)
287
291
  end
288
292
  end
@@ -97,18 +97,20 @@ module NA
97
97
  puts actions.map { |action| action.pretty(template: { output: template }) }
98
98
  end
99
99
 
100
- def parse_actions(depth: 1, query: nil, tag: nil, search: nil)
100
+ def parse_actions(depth: 1, query: nil, tag: nil, search: nil, require_na: true)
101
101
  actions = []
102
102
  required = []
103
103
  optional = []
104
+ negated = []
104
105
 
105
106
  tag&.each do |t|
106
107
  unless t[:tag].nil?
107
108
  new_rx = " @#{t[:tag]}"
108
109
  new_rx = "#{new_rx}\\(#{t[:value]}\\)" if t[:value]
109
110
 
110
- optional.push(new_rx)
111
- required.push(new_rx) if t[:required]
111
+ optional.push(new_rx) unless t[:negate]
112
+ required.push(new_rx) if t[:required] && !t[:negate]
113
+ negated.push(new_rx) if t[:negate]
112
114
  end
113
115
  end
114
116
 
@@ -120,8 +122,9 @@ module NA
120
122
  search.each do |t|
121
123
  new_rx = t[:token].to_s
122
124
 
123
- optional.push(new_rx)
124
- required.push(new_rx) if t[:required]
125
+ optional.push(new_rx) unless t[:negate]
126
+ required.push(new_rx) if t[:required] && !t[:negate]
127
+ negated.push(new_rx) if t[:negate]
125
128
  end
126
129
  end
127
130
  end
@@ -140,7 +143,6 @@ module NA
140
143
  indent_level = 0
141
144
  parent = []
142
145
  content.split("\n").each do |line|
143
- new_action = nil
144
146
  if line =~ /([ \t]*)([^\-]+.*?): *(@\S+ *)*$/
145
147
  proj = Regexp.last_match(2)
146
148
  indent = line.indent_level
@@ -156,10 +158,10 @@ module NA
156
158
 
157
159
  indent_level = indent
158
160
  elsif line =~ /^[ \t]*- / && line !~ / @done/
159
- next unless line =~ /@#{NA.na_tag}\b/
161
+ next if require_na && line !~ /@#{NA.na_tag}\b/
160
162
 
161
- unless optional.empty? && required.empty?
162
- next unless line.matches(any: optional, all: required)
163
+ unless optional.empty? && required.empty? && negated.empty?
164
+ next unless line.matches(any: optional, all: required, none: negated)
163
165
 
164
166
  end
165
167
 
data/lib/na/string.rb CHANGED
@@ -24,8 +24,15 @@ class ::String
24
24
  gsub(/(\s|m)(@[^ ("']+)(?:(\()(.*?)(\)))?/, "\\1#{tag_color}\\2#{paren_color}\\3#{value_color}\\4#{paren_color}\\5#{last_color}")
25
25
  end
26
26
 
27
- def matches(any: [], all: [])
28
- matches_any(any) && matches_all(all)
27
+ def matches(any: [], all: [], none: [])
28
+ matches_any(any) && matches_all(all) && matches_none(none)
29
+ end
30
+
31
+ def matches_none(regexes)
32
+ regexes.each do |rx|
33
+ return false if match(Regexp.new(rx, Regexp::IGNORECASE))
34
+ end
35
+ true
29
36
  end
30
37
 
31
38
  def matches_any(regexes)
data/lib/na/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Na
2
- VERSION = '1.1.5'
2
+ VERSION = '1.1.7'
3
3
  end
data/src/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  _If you're one of the rare people like me who find this useful, feel free to
10
10
  [buy me some coffee][donate]._
11
11
 
12
- The current version of `na` is <!--VER-->1.1.4<!--END VER-->.
12
+ The current version of `na` is <!--VER-->1.1.6<!--END VER-->.
13
13
 
14
14
  `na` ("next action") is a command line tool designed to make it easy to see what your next actions are for any project, right from the command line. It works with TaskPaper-formatted files (but any plain text format will do), looking for `@na` tags (or whatever you specify) in todo files in your current folder.
15
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: na
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-01 00:00:00.000000000 Z
11
+ date: 2022-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake