na 1.1.6 → 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: 03c4375b396333ce69e4064947e572686950926d68fdb5ae667525507d0a4ec7
4
- data.tar.gz: 0eec2704ac51ed2c9840f41c235e86f0420ea4d67323afe6be743ae7a6ec1601
3
+ metadata.gz: 7a47eb8254efd672fd4a240639516c3100244bada4809f40c6eba9fcb6ba4ea7
4
+ data.tar.gz: b44d9bbd6d91db44c3929bf64d2a45356297272de4a3ee246cf59921c9579d0c
5
5
  SHA512:
6
- metadata.gz: 0c707ed84fcb1ecba18dcaa159e58a445df4e4be3940a6abc3c58c8a909293a98262c21fa48215d65abbd8234e56835279a94f9a8d214909c428b8713ac75f36
7
- data.tar.gz: f46959d5c7869b53c32a6d454f805e966e3ed7fa2f5ae0eff03b65f173c4741bf285d17cde9cdb94a78fe1acac38a49fdcc04e3b57b7ef9499e7e976e0106ef8
6
+ metadata.gz: f8951228d935af6e614ea068df59060a73c42078f2e63f71242f8a95dfab9225cb86298269a375d684fa3c7617061ef8fb12560fe16429eb80e6e8e7b3a71c25
7
+ data.tar.gz: d944ca6cf975bc996b481ae1764b824298440b63baa098d920fc3ac717c7504d9ab988f38965f2e20ce9844b763809dbb546836319cfc19a504c80ef177477c8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
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
+
1
9
  ### 1.1.6
2
10
 
3
11
  2022-10-02 11:46
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.6
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,10 +233,11 @@ 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
@@ -273,12 +274,13 @@ class App
273
274
  tags = []
274
275
  args.each do |arg|
275
276
  # TODO: <> comparisons do nothing right now
276
- m = arg.match(/^(?<req>\+)?(?<tag>[^ =<>]+)(?:(?<op>[=<>]+)(?<val>\S+))?$/)
277
+ m = arg.match(/^(?<req>[+\-!])?(?<tag>[^ =<>]+)(?:(?<op>[=<>]+)(?<val>\S+))?$/)
277
278
  tags.push({
278
279
  tag: m['tag'],
279
280
  comp: m['op'],
280
281
  value: m['val'],
281
- required: !m['req'].nil?
282
+ required: !m['req'].nil? && m['req'] == '+',
283
+ negate: !m['req'].nil? && m['req'] =~ /[!\-]/
282
284
  })
283
285
  end
284
286
 
@@ -101,14 +101,16 @@ module NA
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
@@ -158,8 +160,8 @@ module NA
158
160
  elsif line =~ /^[ \t]*- / && line !~ / @done/
159
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.6'
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.5<!--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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: na
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra