na 1.1.12 → 1.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/na/next_action.rb +60 -51
- data/lib/na/string.rb +9 -0
- data/lib/na/version.rb +1 -1
- data/src/README.md +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03c240ef72b49cbb692ba1f55da9a36036d72bd51bb29549ea87262cceedfd51
|
4
|
+
data.tar.gz: e61a921f6af384ae5615f54116cb4e4e0c9472ab76d4a347fc50ea5633fc80a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e577876361f3022e29d4c56e06d7c507fe05ac81da752debe476b481f92f671ee85ab25cb06e32a0608baf1b926454ea4e68aa6391e32ee7c5e7e02a5751dd11
|
7
|
+
data.tar.gz: 660039f2b13e23365ffa88fa8a59266f50941275830175458f867a26bfcbcd3553c8e5dc6ef70da1d1ab5946fc9d7a3361bdf932f8d63eda23c3c692657a5074
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
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.
|
12
|
+
The current version of `na` is 1.1.13
|
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/lib/na/next_action.rb
CHANGED
@@ -136,28 +136,16 @@ module NA
|
|
136
136
|
end
|
137
137
|
else
|
138
138
|
search.each do |t|
|
139
|
-
|
140
|
-
|
141
|
-
if negate
|
142
|
-
optional.push(new_rx) if t[:negate]
|
143
|
-
required.push(new_rx) if t[:required] && t[:negate]
|
144
|
-
negated.push(new_rx) unless t[:negate]
|
145
|
-
else
|
146
|
-
optional.push(new_rx) unless t[:negate]
|
147
|
-
required.push(new_rx) if t[:required] && !t[:negate]
|
148
|
-
negated.push(new_rx) if t[:negate]
|
149
|
-
end
|
139
|
+
optional, required, negated = parse_search(t, negate)
|
150
140
|
end
|
151
141
|
end
|
152
142
|
end
|
153
143
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
files = match_working_dir(query)
|
160
|
-
end
|
144
|
+
files = if query.nil?
|
145
|
+
find_files(depth: depth)
|
146
|
+
else
|
147
|
+
match_working_dir(query)
|
148
|
+
end
|
161
149
|
|
162
150
|
files.each do |file|
|
163
151
|
save_working_dir(File.expand_path(file))
|
@@ -207,6 +195,40 @@ module NA
|
|
207
195
|
[files, actions]
|
208
196
|
end
|
209
197
|
|
198
|
+
def edit_file(file: nil, app: nil)
|
199
|
+
os_open(file, app: app) if file && File.exist?(file)
|
200
|
+
end
|
201
|
+
|
202
|
+
##
|
203
|
+
## Platform-agnostic open command
|
204
|
+
##
|
205
|
+
## @param file [String] The file to open
|
206
|
+
##
|
207
|
+
def os_open(file, app: nil)
|
208
|
+
os = RbConfig::CONFIG['target_os']
|
209
|
+
case os
|
210
|
+
when /darwin.*/i
|
211
|
+
darwin_open(file, app: app)
|
212
|
+
when /mingw|mswin/i
|
213
|
+
win_open(file)
|
214
|
+
else
|
215
|
+
linux_open(file)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def weed_cache_file
|
220
|
+
db_dir = File.expand_path('~/.local/share/na')
|
221
|
+
db_file = 'tdlist.txt'
|
222
|
+
file = File.join(db_dir, db_file)
|
223
|
+
if File.exist?(file)
|
224
|
+
dirs = IO.read(file).split("\n")
|
225
|
+
dirs.delete_if { |f| !File.exist?(f) }
|
226
|
+
File.open(file, 'w') { |f| f.puts dirs.join("\n") }
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
private
|
231
|
+
|
210
232
|
##
|
211
233
|
## Generate a menu of options and allow user selection
|
212
234
|
##
|
@@ -234,6 +256,25 @@ module NA
|
|
234
256
|
res
|
235
257
|
end
|
236
258
|
|
259
|
+
def parse_search(tag, negate)
|
260
|
+
required = []
|
261
|
+
optional = []
|
262
|
+
negated = []
|
263
|
+
new_rx = tag[:token].to_s.wildcard_to_rx
|
264
|
+
|
265
|
+
if negate
|
266
|
+
optional.push(new_rx) if tag[:negate]
|
267
|
+
required.push(new_rx) if tag[:required] && tag[:negate]
|
268
|
+
negated.push(new_rx) unless tag[:negate]
|
269
|
+
else
|
270
|
+
optional.push(new_rx) unless tag[:negate]
|
271
|
+
required.push(new_rx) if tag[:required] && !tag[:negate]
|
272
|
+
negated.push(new_rx) if tag[:negate]
|
273
|
+
end
|
274
|
+
|
275
|
+
[optional, required, negated]
|
276
|
+
end
|
277
|
+
|
237
278
|
##
|
238
279
|
## Get path to database of known todo files
|
239
280
|
##
|
@@ -276,7 +317,7 @@ module NA
|
|
276
317
|
notify('{r}No na database found', exit_code: 1) unless File.exist?(file)
|
277
318
|
|
278
319
|
dirs = IO.read(file).split("\n")
|
279
|
-
dirs.delete_if { |d| !d.
|
320
|
+
dirs.delete_if { |d| !d.dir_matches(any: optional, all: required) }
|
280
321
|
dirs.sort.uniq
|
281
322
|
end
|
282
323
|
|
@@ -289,21 +330,6 @@ module NA
|
|
289
330
|
File.open(file, 'w') { |f| f.puts dirs.join("\n") }
|
290
331
|
end
|
291
332
|
|
292
|
-
def weed_cache_file
|
293
|
-
db_dir = File.expand_path('~/.local/share/na')
|
294
|
-
db_file = 'tdlist.txt'
|
295
|
-
file = File.join(db_dir, db_file)
|
296
|
-
if File.exist?(file)
|
297
|
-
dirs = IO.read(file).split("\n")
|
298
|
-
dirs.delete_if { |f| !File.exist?(f) }
|
299
|
-
File.open(file, 'w') { |f| f.puts dirs.join("\n") }
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
def edit_file(file: nil, app: nil)
|
304
|
-
os_open(file, app: app) if file && File.exist?(file)
|
305
|
-
end
|
306
|
-
|
307
333
|
def darwin_open(file, app: nil)
|
308
334
|
if app
|
309
335
|
`open -a "#{app}" #{Shellwords.escape(file)}`
|
@@ -323,22 +349,5 @@ module NA
|
|
323
349
|
notify('{r}Unable to determine executable for `xdg-open`.')
|
324
350
|
end
|
325
351
|
end
|
326
|
-
|
327
|
-
##
|
328
|
-
## Platform-agnostic open command
|
329
|
-
##
|
330
|
-
## @param file [String] The file to open
|
331
|
-
##
|
332
|
-
def os_open(file, app: nil)
|
333
|
-
os = RbConfig::CONFIG['target_os']
|
334
|
-
case os
|
335
|
-
when /darwin.*/i
|
336
|
-
darwin_open(file, app: app)
|
337
|
-
when /mingw|mswin/i
|
338
|
-
win_open(file)
|
339
|
-
else
|
340
|
-
linux_open(file)
|
341
|
-
end
|
342
|
-
end
|
343
352
|
end
|
344
353
|
end
|
data/lib/na/string.rb
CHANGED
@@ -24,6 +24,14 @@ 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 dir_to_rx
|
28
|
+
split(%r{[/:]}).join('.*?/.*?') + '[^/]+$'
|
29
|
+
end
|
30
|
+
|
31
|
+
def dir_matches(any: [], all: [])
|
32
|
+
matches_any(any.map { |token| token.dir_to_rx }) && matches_all(all.map { |token| token.dir_to_rx })
|
33
|
+
end
|
34
|
+
|
27
35
|
def matches(any: [], all: [], none: [])
|
28
36
|
matches_any(any) && matches_all(all) && matches_none(none)
|
29
37
|
end
|
@@ -36,6 +44,7 @@ class ::String
|
|
36
44
|
end
|
37
45
|
|
38
46
|
def matches_any(regexes)
|
47
|
+
string = dup
|
39
48
|
regexes.each do |rx|
|
40
49
|
return true if match(Regexp.new(rx, Regexp::IGNORECASE))
|
41
50
|
end
|
data/lib/na/version.rb
CHANGED
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.
|
12
|
+
The current version of `na` is <!--VER-->1.1.12<!--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
|
|