na 1.1.6 → 1.1.8

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: 5b233e64c028a52fe153ef2a02449e90f511a9950c6454d9ed6f198fa79340f0
4
+ data.tar.gz: 0d2a00e4b387fb2917b22180f34a353038c8eb5a7944fea9570418de10e24c6b
5
5
  SHA512:
6
- metadata.gz: 0c707ed84fcb1ecba18dcaa159e58a445df4e4be3940a6abc3c58c8a909293a98262c21fa48215d65abbd8234e56835279a94f9a8d214909c428b8713ac75f36
7
- data.tar.gz: f46959d5c7869b53c32a6d454f805e966e3ed7fa2f5ae0eff03b65f173c4741bf285d17cde9cdb94a78fe1acac38a49fdcc04e3b57b7ef9499e7e976e0106ef8
6
+ metadata.gz: ab2fe89531b2b4b278375cc35e62922e16101c910d9e95c913202bb1a5879facc00ce868420943cb2fcceb18309a9691bb2b76f8990b7b49f4675d93adb837e6
7
+ data.tar.gz: 4881155bbc7cb33600462ef01d939847bdca6456fe9c862ef194f9175503246bfc23ecf10983da555d381a113638dd6e6f6b09e17a985f29cdead7c3e082ef38
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ### 1.1.8
2
+
3
+ 2022-10-02 16:40
4
+
5
+ #### FIXED
6
+
7
+ - `na next -t X` didn't replace @na tag in search, but appended to it
8
+
9
+ ### 1.1.7
10
+
11
+ 2022-10-02 12:20
12
+
13
+ #### IMPROVED
14
+
15
+ - You can use !token to add negative values to tag/search queries, e.g. `na tagged +maybe !waiting`
16
+
1
17
  ### 1.1.6
2
18
 
3
19
  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.8)
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.8
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.
@@ -22,6 +22,11 @@ It can also auto-display next actions when you enter a project directory, automa
22
22
 
23
23
  Assuming you have Ruby and RubyGems installed, you can just run `gem install na`. If you run into errors, use `sudo gem install na`.
24
24
 
25
+ If you're using Homebrew, you have the option to install via [brew-gem](https://github.com/sportngin/brew-gem):
26
+
27
+ brew install brew-gem
28
+ brew gem install na
29
+
25
30
  If you don't have Ruby/RubyGems, you can install them pretty easily with Homebrew, rvm, or asdf. I can't swear this tool is worth the time, but there _are_ a lot of great gems available...
26
31
 
27
32
 
data/bin/na CHANGED
@@ -91,11 +91,19 @@ class App
91
91
  end
92
92
  end
93
93
 
94
- tag = options[:tag] == NA.na_tag ? nil : options[:tag]
94
+ if options[:tag] == NA.na_tag
95
+ tag = nil
96
+ require_na = true
97
+ else
98
+ tag = options[:tag]
99
+ require_na = false
100
+ end
101
+
95
102
  tag = [{ tag: tag, value: nil }]
96
103
  files, actions = NA.parse_actions(depth: depth,
97
104
  query: tokens,
98
- tag: tag)
105
+ tag: tag,
106
+ require_na: require_na)
99
107
 
100
108
  NA.output_actions(actions, depth, files: files)
101
109
  end
@@ -233,10 +241,11 @@ class App
233
241
  else
234
242
  tokens = []
235
243
  args.each do |arg|
236
- m = arg.match(/^(?<req>\+)?(?<tok>.*?)$/)
244
+ m = arg.match(/^(?<req>[+\-!])?(?<tok>.*?)$/)
237
245
  tokens.push({
238
246
  token: m['tok'],
239
- required: !m['req'].nil?
247
+ required: !m['req'].nil? && m['req'] == '+',
248
+ negate: !m['req'].nil? && m['req'] =~ /[!\-]/
240
249
  })
241
250
  end
242
251
  end
@@ -273,12 +282,13 @@ class App
273
282
  tags = []
274
283
  args.each do |arg|
275
284
  # TODO: <> comparisons do nothing right now
276
- m = arg.match(/^(?<req>\+)?(?<tag>[^ =<>]+)(?:(?<op>[=<>]+)(?<val>\S+))?$/)
285
+ m = arg.match(/^(?<req>[+\-!])?(?<tag>[^ =<>]+)(?:(?<op>[=<>]+)(?<val>\S+))?$/)
277
286
  tags.push({
278
287
  tag: m['tag'],
279
288
  comp: m['op'],
280
289
  value: m['val'],
281
- required: !m['req'].nil?
290
+ required: !m['req'].nil? && m['req'] == '+',
291
+ negate: !m['req'].nil? && m['req'] =~ /[!\-]/
282
292
  })
283
293
  end
284
294
 
@@ -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.8'
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.7<!--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
 
@@ -21,6 +21,11 @@ It can also auto-display next actions when you enter a project directory, automa
21
21
 
22
22
  Assuming you have Ruby and RubyGems installed, you can just run `gem install na`. If you run into errors, use `sudo gem install na`.
23
23
 
24
+ If you're using Homebrew, you have the option to install via [brew-gem](https://github.com/sportngin/brew-gem):
25
+
26
+ brew install brew-gem
27
+ brew gem install na
28
+
24
29
  If you don't have Ruby/RubyGems, you can install them pretty easily with Homebrew, rvm, or asdf. I can't swear this tool is worth the time, but there _are_ a lot of great gems available...
25
30
 
26
31
  <!--JEKYLL> You can find the na source code (MIT license) on [GitHub][].-->
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.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra