na 1.2.15 → 1.2.17

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: 4d2ce71562668eb958d8056e6f226329839fe872575eb0f6dba5220aedbc09a5
4
- data.tar.gz: c1461870c50b6665a0269c7be2e05130cf8c94ab1fd8a929b4566c391b81a8e4
3
+ metadata.gz: 230088b77bc3f8e3aa56fe5ba96505678d0ef3b809a38eccf96fb8be2109cf3d
4
+ data.tar.gz: 87d16ea051d5c9c8e719777399cc4c3bb8ee3806c8ccbffaba80e1a429784844
5
5
  SHA512:
6
- metadata.gz: f5fe87068b1ad84b747f35e255ddd64687c90733b9526e41c258e13557ccc9396b8025ef42acf3fd90a7facb6049a4907f099c36f8ef4977ac479aab5d451a07
7
- data.tar.gz: 702e69f47f8baf069fe398ac3daac5615c56095377df31b91e93edb6a94dae8682ab4fb2574c8f57b419a6ddf2fc61938def7c598990c60aeb722ccb7af9f97b
6
+ metadata.gz: 98e10fb95e67d9a86c89b34a5b21f5aefb61a66a239b205720a9ecf2979a5e57a39009c52cd17a12dde1a772e29b6ec3f3feb074d408ea233b5b64abb76d0494
7
+ data.tar.gz: c7880dd277c7a82c12bc1781b5d1ed5be84b2eaf21a4e4dcbcc8ddd3d28820252cc3f67c57794b3239331a43ce81e303b087358d76ec32a40618d9bee3c4e367
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ### 1.2.17
2
+
3
+ 2023-01-17 11:23
4
+
5
+ #### IMPROVED
6
+
7
+ - `--nest` works with `find` and `tagged`
8
+ - `--nest` creates heirarchy of parent projects, indented TaskPaper style
9
+
10
+ ### 1.2.16
11
+
12
+ 2023-01-17 10:13
13
+
14
+ #### NEW
15
+
16
+ - `na next --nest` will output a TaskPaper format list of actions grouped under their respective files with the filename as the containing project
17
+
18
+ #### FIXED
19
+
20
+ - Better solution to target_proj nil error
21
+
1
22
  ### 1.2.15
2
23
 
3
24
  2022-11-28 10:58
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- na (1.2.15)
4
+ na (1.2.17)
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.15
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.15
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)
@@ -272,6 +273,7 @@ COMMAND OPTIONS
272
273
  --[no-]done - Include @done actions
273
274
  --[no-]exact - Search query is exact text match (not tokens)
274
275
  --in, --todo=TODO_FILE - Display matches from a known todo file (may be used more than once, default: none)
276
+ --[no-]nest - Output actions nested by file
275
277
  --[no-]notes - Include notes in output
276
278
  --proj, --project=PROJECT[/SUBPROJECT] - Show actions from a specific project (default: none)
277
279
  --[no-]regex - Search query is regular expression
@@ -376,6 +378,7 @@ COMMAND OPTIONS
376
378
  --[no-]done - Include @done actions
377
379
  --[no-]exact - Search query is exact text match (not tokens)
378
380
  --in, --todo=TODO_FILE - Display matches from a known todo file (may be used more than once, default: none)
381
+ --[no-]nest - Output actions nested by file
379
382
  --[no-]notes - Include notes in output
380
383
  --proj, --project=PROJECT[/SUBPROJECT] - Show actions from a specific project (default: none)
381
384
  --[no-]regex - Search query is regular expression
data/bin/na CHANGED
@@ -115,6 +115,9 @@ class App
115
115
  c.desc 'Include @done actions'
116
116
  c.switch %i[done]
117
117
 
118
+ c.desc 'Output actions nested by file'
119
+ c.switch %[nest]
120
+
118
121
  c.action do |global_options, options, args|
119
122
  if global_options[:add]
120
123
  cmd = ['add']
@@ -196,7 +199,7 @@ class App
196
199
  project: options[:project],
197
200
  require_na: require_na)
198
201
 
199
- NA.output_actions(actions, depth, files: files, notes: options[:notes])
202
+ NA.output_actions(actions, depth, files: files, notes: options[:notes], nest: options[:nest])
200
203
  end
201
204
  end
202
205
 
@@ -652,6 +655,9 @@ class App
652
655
  c.arg_name 'TITLE'
653
656
  c.flag %i[save]
654
657
 
658
+ c.desc 'Output actions nested by file'
659
+ c.switch %[nest]
660
+
655
661
  c.action do |global_options, options, args|
656
662
  if options[:save]
657
663
  title = options[:save].gsub(/[^a-z0-9]/, '_').gsub(/_+/, '_')
@@ -725,7 +731,7 @@ class App
725
731
  [tokens]
726
732
  end
727
733
 
728
- 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])
729
735
  end
730
736
  end
731
737
 
@@ -783,6 +789,9 @@ class App
783
789
  c.arg_name 'TITLE'
784
790
  c.flag %i[save]
785
791
 
792
+ c.desc 'Output actions nested by file'
793
+ c.switch %[nest]
794
+
786
795
  c.action do |global_options, options, args|
787
796
  if options[:save]
788
797
  title = options[:save].gsub(/[^a-z0-9]/, '_').gsub(/_+/, '_')
@@ -862,7 +871,7 @@ class App
862
871
  else
863
872
  [tokens]
864
873
  end
865
- 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])
866
875
  end
867
876
  end
868
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
  ##
@@ -330,12 +329,8 @@ module NA
330
329
  contents.slice!(action.line, action.note.count + 1)
331
330
  next if delete
332
331
 
333
- target_proj = action.project if target_proj.nil?
334
-
335
332
  projects = shift_index_after(projects, action.line, action.note.count + 1)
336
333
 
337
- target_proj = projects.select { |proj| proj.project =~ /^#{target_proj.project}$/ }.first
338
-
339
334
  action = process_action(action, priority: priority, finish: finish, add_tag: add_tag, remove_tag: remove_tag)
340
335
 
341
336
  target_proj = if target_proj
@@ -407,6 +402,38 @@ module NA
407
402
  update_action(file, nil, add: action, project: project, add_tag: add_tag, priority: priority, finish: finish, append: append)
408
403
  end
409
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
+
410
437
  ##
411
438
  ## Pretty print a list of actions
412
439
  ##
@@ -415,29 +442,52 @@ module NA
415
442
  ## @param files [Array] The files actions originally came from
416
443
  ## @param regexes [Array] The regexes used to gather actions
417
444
  ##
418
- def output_actions(actions, depth, files: nil, regexes: [], notes: false)
445
+ def output_actions(actions, depth, files: nil, regexes: [], notes: false, nest: false)
419
446
  return if files.nil?
420
447
 
421
- template = if files.count.positive?
422
- if files.count == 1
423
- '%parent%action'
424
- else
425
- '%filename%parent%action'
426
- end
427
- elsif find_files(depth: depth).count > 1
428
- if depth > 1
429
- '%filename%parent%action'
448
+ if nest
449
+ template = '%parent%action'
450
+
451
+ parent_files = {}
452
+
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
460
+
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
469
+
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
430
482
  else
431
- '%project%parent%action'
483
+ '%parent%action'
432
484
  end
433
- else
434
- '%parent%action'
435
- end
436
- template += '%note' if notes
485
+ template += '%note' if notes
437
486
 
438
- files.map { |f| notify("{dw}#{f}", debug: true) } if files
487
+ files.map { |f| notify("{dw}#{f}", debug: true) } if files
439
488
 
440
- puts(actions.map { |action| action.pretty(template: { output: template }, regexes: regexes, notes: notes) })
489
+ puts(actions.map { |action| action.pretty(template: { output: template }, regexes: regexes, notes: notes) })
490
+ end
441
491
  end
442
492
 
443
493
  ##
data/lib/na/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Na
2
- VERSION = '1.2.15'
2
+ VERSION = '1.2.17'
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.14<!--END VER-->.
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
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: na
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.15
4
+ version: 1.2.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-28 00:00:00.000000000 Z
11
+ date: 2023-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake