na 1.2.16 → 1.2.18

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d8da07f9b65304b26e03aeeb38af43e72fb378eb016efdee8eac61b9c992609
4
- data.tar.gz: 62710fb19fec1f6ddf4e06c4cc12b3f5c3d7a8fd646dc792593d72a4c01065df
3
+ metadata.gz: 580a58387aafdf48e220483783dff100a26f370e5ac685239dcf2cff416793cc
4
+ data.tar.gz: 04ec4cd4089b00ab65688e6fb88509971f01ef605b88956e9ecf4e523b175067
5
5
  SHA512:
6
- metadata.gz: e7dee3f47d88e9dcdea8d10f585685452124de43e32b1279a057167bc86a96fc709c662064951c5690ff5b7c7f685b77268b29931e8cd5cd562220e95df96847
7
- data.tar.gz: 794c1a1e458d61326165e56a21de4e2792a7a0247404fc584c7a6ecebea029892fd988ea602039a48006c5f5aeed7e883f8bff114346d01c5df1b5eb3a7e7d26
6
+ metadata.gz: 4ff3cd0df2c68db3baa5022d5d9cb6dc7f61684aef2b50485cf4022ea4169dcc547b433fd2e42e454c21e29fb8dcd4f04fc7caaf9ae64de9e42dd0c57d4a882d
7
+ data.tar.gz: da239f2e39fbfbc514c321867b1068b1cc1e16e02e6b068cc1cd53024354baac2955442d0db8aed9ff495bb62ed68116f1f06ae6c0ddc0915cbe168ddc2a91b9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ### 1.2.18
2
+
3
+ 2023-01-17 13:38
4
+
5
+ #### IMPROVED
6
+
7
+ - Format tags OmniFocus wouldn't recognize as @tags(TAG) in --nest output
8
+ - Include notes in --nest output
9
+
10
+ ### 1.2.17
11
+
12
+ 2023-01-17 11:23
13
+
14
+ #### IMPROVED
15
+
16
+ - `--nest` works with `find` and `tagged`
17
+ - `--nest` creates heirarchy of parent projects, indented TaskPaper style
18
+
1
19
  ### 1.2.16
2
20
 
3
21
  2023-01-17 10:13
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- na (1.2.16)
4
+ na (1.2.18)
5
5
  chronic (~> 0.10, >= 0.10.2)
6
6
  gli (~> 2.21.0)
7
7
  mdless (~> 1.0, >= 1.0.32)
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.16
12
+ The current version of `na` is 1.2.18
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.16
80
+ 1.2.18
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
- if options[:nest]
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
 
@@ -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,58 @@ 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)
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
+
429
+ v.each do |a|
430
+ item = "#{indent}- #{a.action}"
431
+
432
+ unless a.tags.empty?
433
+ tags = []
434
+ a.tags.each do |k, v|
435
+ next if k =~ /^(due|flagged|done)$/
436
+
437
+ tag = k
438
+ tag += "-#{v}" unless v.nil? || v.empty?
439
+ tags.push(tag)
440
+ end
441
+
442
+ item += " @tags(#{tags.join(',')})" unless tags.empty?
443
+ end
444
+
445
+ item += "\n#{indent}\t#{a.note.join("\n#{indent}\t")}" if !a.note.empty?
446
+
447
+ out.push(item)
448
+ end
449
+ else
450
+ out.push("#{indent}#{k}:")
451
+ out.concat(output_children(v, level + 1))
452
+ end
453
+ end
454
+ out
455
+ end
456
+
406
457
  ##
407
458
  ## Pretty print a list of actions
408
459
  ##
@@ -411,55 +462,52 @@ module NA
411
462
  ## @param files [Array] The files actions originally came from
412
463
  ## @param regexes [Array] The regexes used to gather actions
413
464
  ##
414
- def output_actions(actions, depth, files: nil, regexes: [], notes: false)
465
+ def output_actions(actions, depth, files: nil, regexes: [], notes: false, nest: false)
415
466
  return if files.nil?
416
467
 
417
- template = if files.count.positive?
418
- if files.count == 1
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
468
+ if nest
469
+ template = '%parent%action'
435
470
 
436
- puts(actions.map { |action| action.pretty(template: { output: template }, regexes: regexes, notes: notes) })
437
- end
471
+ parent_files = {}
438
472
 
439
- def output_actions_by_file(actions, depth, files: nil, regexes: [], notes: false)
440
- return if files.nil?
473
+ actions.each do |action|
474
+ if parent_files.key?(action.file)
475
+ parent_files[action.file].push(action)
476
+ else
477
+ parent_files[action.file] = [action]
478
+ end
479
+ end
441
480
 
442
- template = '%parent%action'
481
+ out = []
482
+ parent_files.each do |file, actions|
483
+ projects = project_hierarchy(actions)
484
+ out.push("#{file.sub(%r{^./}, '').shorten_path}:")
485
+ out.concat(output_children(projects, 0))
486
+ end
487
+ puts out.join("\n")
488
+ else
443
489
 
444
- parent_files = {}
490
+ template = if files.count.positive?
491
+ if files.count == 1
492
+ '%parent%action'
493
+ else
494
+ '%filename%parent%action'
495
+ end
496
+ elsif find_files(depth: depth).count > 1
497
+ if depth > 1
498
+ '%filename%parent%action'
499
+ else
500
+ '%project%parent%action'
501
+ end
502
+ else
503
+ '%parent%action'
504
+ end
505
+ template += '%note' if notes
445
506
 
446
- actions.each do |action|
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
507
+ files.map { |f| notify("{dw}#{f}", debug: true) } if files
453
508
 
454
- out = []
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
509
+ puts(actions.map { |action| action.pretty(template: { output: template }, regexes: regexes, notes: notes) })
460
510
  end
461
-
462
- puts out.join("\n")
463
511
  end
464
512
 
465
513
  ##
data/lib/na/string.rb CHANGED
@@ -167,6 +167,15 @@ class ::String
167
167
  end
168
168
  end
169
169
 
170
+ ##
171
+ ## Replace home directory with tilde
172
+ ##
173
+ ## @return [String] shortened path
174
+ ##
175
+ def shorten_path
176
+ sub(/^#{ENV['HOME']}/, '~')
177
+ end
178
+
170
179
  private
171
180
 
172
181
  def matches_none(regexes)
data/lib/na/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Na
2
- VERSION = '1.2.16'
2
+ VERSION = '1.2.18'
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.2.15<!--END VER-->.
12
+ The current version of `na` is <!--VER-->1.2.17<!--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.2.16
4
+ version: 1.2.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra