na 1.2.16 → 1.2.17
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -2
- data/bin/na +9 -7
- data/lib/na/next_action.rb +69 -41
- 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: 230088b77bc3f8e3aa56fe5ba96505678d0ef3b809a38eccf96fb8be2109cf3d
|
4
|
+
data.tar.gz: 87d16ea051d5c9c8e719777399cc4c3bb8ee3806c8ccbffaba80e1a429784844
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98e10fb95e67d9a86c89b34a5b21f5aefb61a66a239b205720a9ecf2979a5e57a39009c52cd17a12dde1a772e29b6ec3f3feb074d408ea233b5b64abb76d0494
|
7
|
+
data.tar.gz: c7880dd277c7a82c12bc1781b5d1ed5be84b2eaf21a4e4dcbcc8ddd3d28820252cc3f67c57794b3239331a43ce81e303b087358d76ec32a40618d9bee3c4e367
|
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.2.
|
12
|
+
The current version of `na` is 1.2.17
|
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.
|
@@ -77,7 +77,7 @@ SYNOPSIS
|
|
77
77
|
na [global options] command [command options] [arguments...]
|
78
78
|
|
79
79
|
VERSION
|
80
|
-
1.2.
|
80
|
+
1.2.17
|
81
81
|
|
82
82
|
GLOBAL OPTIONS
|
83
83
|
-a, --[no-]add - Add a next action (deprecated, for backwards compatibility)
|
@@ -210,6 +210,7 @@ COMMAND OPTIONS
|
|
210
210
|
--[no-]done - Include @done actions
|
211
211
|
-e, --regex - Interpret search pattern as regular expression
|
212
212
|
--in=TODO_PATH - Show actions from a specific todo file in history. May use wildcards (* and ?) (default: none)
|
213
|
+
--[no-]nest - Output actions nested by file
|
213
214
|
--[no-]notes - Include notes in output
|
214
215
|
-o, --or - Combine search tokens with OR, displaying actions matching ANY of the terms
|
215
216
|
--proj, --project=PROJECT[/SUBPROJECT] - Show actions from a specific project (default: none)
|
data/bin/na
CHANGED
@@ -199,11 +199,7 @@ class App
|
|
199
199
|
project: options[:project],
|
200
200
|
require_na: require_na)
|
201
201
|
|
202
|
-
|
203
|
-
NA.output_actions_by_file(actions, depth, files: files, notes: options[:notes])
|
204
|
-
else
|
205
|
-
NA.output_actions(actions, depth, files: files, notes: options[:notes])
|
206
|
-
end
|
202
|
+
NA.output_actions(actions, depth, files: files, notes: options[:notes], nest: options[:nest])
|
207
203
|
end
|
208
204
|
end
|
209
205
|
|
@@ -659,6 +655,9 @@ class App
|
|
659
655
|
c.arg_name 'TITLE'
|
660
656
|
c.flag %i[save]
|
661
657
|
|
658
|
+
c.desc 'Output actions nested by file'
|
659
|
+
c.switch %[nest]
|
660
|
+
|
662
661
|
c.action do |global_options, options, args|
|
663
662
|
if options[:save]
|
664
663
|
title = options[:save].gsub(/[^a-z0-9]/, '_').gsub(/_+/, '_')
|
@@ -732,7 +731,7 @@ class App
|
|
732
731
|
[tokens]
|
733
732
|
end
|
734
733
|
|
735
|
-
NA.output_actions(actions, depth, files: files, regexes: regexes, notes: options[:notes])
|
734
|
+
NA.output_actions(actions, depth, files: files, regexes: regexes, notes: options[:notes], nest: options[:nest])
|
736
735
|
end
|
737
736
|
end
|
738
737
|
|
@@ -790,6 +789,9 @@ class App
|
|
790
789
|
c.arg_name 'TITLE'
|
791
790
|
c.flag %i[save]
|
792
791
|
|
792
|
+
c.desc 'Output actions nested by file'
|
793
|
+
c.switch %[nest]
|
794
|
+
|
793
795
|
c.action do |global_options, options, args|
|
794
796
|
if options[:save]
|
795
797
|
title = options[:save].gsub(/[^a-z0-9]/, '_').gsub(/_+/, '_')
|
@@ -869,7 +871,7 @@ class App
|
|
869
871
|
else
|
870
872
|
[tokens]
|
871
873
|
end
|
872
|
-
NA.output_actions(actions, depth, files: files, regexes: regexes, notes: options[:notes])
|
874
|
+
NA.output_actions(actions, depth, files: files, regexes: regexes, notes: options[:notes], nest: options[:nest])
|
873
875
|
end
|
874
876
|
end
|
875
877
|
|
data/lib/na/next_action.rb
CHANGED
@@ -18,7 +18,6 @@ module NA
|
|
18
18
|
|
19
19
|
$stderr.puts NA::Color.template("{x}#{msg}{x}")
|
20
20
|
Process.exit exit_code if exit_code
|
21
|
-
|
22
21
|
end
|
23
22
|
|
24
23
|
##
|
@@ -403,6 +402,38 @@ module NA
|
|
403
402
|
update_action(file, nil, add: action, project: project, add_tag: add_tag, priority: priority, finish: finish, append: append)
|
404
403
|
end
|
405
404
|
|
405
|
+
def project_hierarchy(actions)
|
406
|
+
parents = { actions: []}
|
407
|
+
actions.each do |a|
|
408
|
+
parent = a.parent
|
409
|
+
current_parent = parents
|
410
|
+
parent.each do |par|
|
411
|
+
if !current_parent.key?(par)
|
412
|
+
current_parent[par] = { actions: [] }
|
413
|
+
end
|
414
|
+
current_parent = current_parent[par]
|
415
|
+
end
|
416
|
+
|
417
|
+
current_parent[:actions].push(a.action)
|
418
|
+
end
|
419
|
+
parents
|
420
|
+
end
|
421
|
+
|
422
|
+
def output_children(children, level = 1)
|
423
|
+
out = []
|
424
|
+
indent = "\t" * level
|
425
|
+
children.each do |k, v|
|
426
|
+
if k.to_s =~ /actions/
|
427
|
+
indent += "\t"
|
428
|
+
v.each { |a| out.push("#{indent}- #{a}")}
|
429
|
+
else
|
430
|
+
out.push("#{indent}#{k}:")
|
431
|
+
out.concat(output_children(v, level + 1))
|
432
|
+
end
|
433
|
+
end
|
434
|
+
out
|
435
|
+
end
|
436
|
+
|
406
437
|
##
|
407
438
|
## Pretty print a list of actions
|
408
439
|
##
|
@@ -411,55 +442,52 @@ module NA
|
|
411
442
|
## @param files [Array] The files actions originally came from
|
412
443
|
## @param regexes [Array] The regexes used to gather actions
|
413
444
|
##
|
414
|
-
def output_actions(actions, depth, files: nil, regexes: [], notes: false)
|
445
|
+
def output_actions(actions, depth, files: nil, regexes: [], notes: false, nest: false)
|
415
446
|
return if files.nil?
|
416
447
|
|
417
|
-
|
418
|
-
|
419
|
-
'%parent%action'
|
420
|
-
else
|
421
|
-
'%filename%parent%action'
|
422
|
-
end
|
423
|
-
elsif find_files(depth: depth).count > 1
|
424
|
-
if depth > 1
|
425
|
-
'%filename%parent%action'
|
426
|
-
else
|
427
|
-
'%project%parent%action'
|
428
|
-
end
|
429
|
-
else
|
430
|
-
'%parent%action'
|
431
|
-
end
|
432
|
-
template += '%note' if notes
|
433
|
-
|
434
|
-
files.map { |f| notify("{dw}#{f}", debug: true) } if files
|
448
|
+
if nest
|
449
|
+
template = '%parent%action'
|
435
450
|
|
436
|
-
|
437
|
-
end
|
451
|
+
parent_files = {}
|
438
452
|
|
439
|
-
|
440
|
-
|
453
|
+
actions.each do |action|
|
454
|
+
if parent_files.key?(action.file)
|
455
|
+
parent_files[action.file].push(action)
|
456
|
+
else
|
457
|
+
parent_files[action.file] = [action]
|
458
|
+
end
|
459
|
+
end
|
441
460
|
|
442
|
-
|
461
|
+
out = []
|
462
|
+
parent_files.each do |file, actions|
|
463
|
+
projects = project_hierarchy(actions)
|
464
|
+
out.push("#{file.sub(%r{^./}, '')}:")
|
465
|
+
out.concat(output_children(projects, 0))
|
466
|
+
end
|
467
|
+
puts out.join("\n")
|
468
|
+
else
|
443
469
|
|
444
|
-
|
470
|
+
template = if files.count.positive?
|
471
|
+
if files.count == 1
|
472
|
+
'%parent%action'
|
473
|
+
else
|
474
|
+
'%filename%parent%action'
|
475
|
+
end
|
476
|
+
elsif find_files(depth: depth).count > 1
|
477
|
+
if depth > 1
|
478
|
+
'%filename%parent%action'
|
479
|
+
else
|
480
|
+
'%project%parent%action'
|
481
|
+
end
|
482
|
+
else
|
483
|
+
'%parent%action'
|
484
|
+
end
|
485
|
+
template += '%note' if notes
|
445
486
|
|
446
|
-
|
447
|
-
if parent_files.key?(action.file)
|
448
|
-
parent_files[action.file].push(action)
|
449
|
-
else
|
450
|
-
parent_files[action.file] = [action]
|
451
|
-
end
|
452
|
-
end
|
487
|
+
files.map { |f| notify("{dw}#{f}", debug: true) } if files
|
453
488
|
|
454
|
-
|
455
|
-
parent_files.each do |k, v|
|
456
|
-
out.push("#{k.sub(%r{^\./}, '')}:")
|
457
|
-
v.each do |a|
|
458
|
-
out.push(" - [#{a.parent.join('/')}] #{a.action}")
|
459
|
-
end
|
489
|
+
puts(actions.map { |action| action.pretty(template: { output: template }, regexes: regexes, notes: notes) })
|
460
490
|
end
|
461
|
-
|
462
|
-
puts out.join("\n")
|
463
491
|
end
|
464
492
|
|
465
493
|
##
|
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.2.
|
12
|
+
The current version of `na` is <!--VER-->1.2.16<!--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
|
|