na 1.2.46 → 1.2.47

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: '0847ca8c8b5746d6e0f099c5bfc38d00dd01353acc7bceda6c5c6423ed16630f'
4
- data.tar.gz: 6e7eecaf402a4268826095e6b46b4f1fad26a7e454b6162a6ef113f04e91a660
3
+ metadata.gz: ed76ea2928d227d65651ad179f0950c2505611c540673f96494feae0ce621ca1
4
+ data.tar.gz: da06581a2771d1675ef1e69229803de2a677b6e30b5a4e2531e8497677cfe40a
5
5
  SHA512:
6
- metadata.gz: 794d54bd290f665f51bb1d74846c83a4406ba76568132591ab19fe146bbbbce844be4e6fff2be05c73170f3666a87edc5446bf1380d1a7c8ded9848fbba9c4a9
7
- data.tar.gz: de1cea81c7612bf8beaa0b73243aa687e9325d46e0c93d139cda87d6792fb99a2614812671b68f6ae9961adde9040c669ce73c5ae1f39d1215820187345ca21b
6
+ metadata.gz: 63e8b9f8fdd3ad3c394dbe022030ab334f3826dbba22d7a0d6971ab02a7d47db243cc308517825a84589bae8ea4333d9aceb393640dd4f13d4d6e67f7a5fa0ef
7
+ data.tar.gz: 4145b57e31f6f876c965b540adf187584e91acb8f2438b9eef8fced56c2938a2c7dd004f7c65a5a5b9040bfd2fc55675e1fc18a579c1318d17f7efe3a80a70b5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ### 1.2.47
2
+
3
+ 2023-09-07 10:47
4
+
5
+ #### NEW
6
+
7
+ - `na update --search OLD_TEXT --replace NEW_TEXT` (added --replace)
8
+
9
+ #### IMPROVED
10
+
11
+ - When not showing notes, add an asterisk in the template note
12
+ - When showing notes, indent to the beginning of the action
13
+
1
14
  ### 1.2.46
2
15
 
3
16
  2023-09-06 21:25
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- na (1.2.46)
4
+ na (1.2.47)
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.46
12
+ The current version of `na` is 1.2.47
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.46
80
+ 1.2.47
81
81
 
82
82
  GLOBAL OPTIONS
83
83
  -a, --add - Add a next action (deprecated, for backwards compatibility)
@@ -503,7 +503,9 @@ COMMAND OPTIONS
503
503
  -p, --priority=PRIO - Add/change a priority level 1-5 (default: 0)
504
504
  --proj, --project=PROJECT[/SUBPROJECT] - Affect actions from a specific project (default: none)
505
505
  -r, --remove=TAG - Remove a tag from the action, use multiple times or combine multiple tags with a comma, wildcards (* and ?) allowed (may be used more than once, default: none)
506
+ --replace=TEXT - Use with --find to find and replace with new text. Enables --exact when used (default: none)
506
507
  --restore - Remove @done tag from action
508
+ --search, --find, --grep=QUERY - Filter results using search terms (may be used more than once, default: none)
507
509
  -t, --tag=TAG - Add a tag to the action, @tag(values) allowed, use multiple times or combine multiple tags with a comma (may be used more than once, default: none)
508
510
  --tagged=TAG - Match actions containing tag. Allows value comparisons (may be used more than once, default: none)
509
511
  --to, --move=PROJECT - Move action to specific project (default: none)
@@ -556,6 +558,7 @@ COMMAND OPTIONS
556
558
  -n, --note - Prompt for additional notes. Input will be appended to any existing note. If STDIN input (piped) is detected, it will be used as a note.
557
559
  -o, --overwrite - Overwrite note instead of appending
558
560
  --proj, --project=PROJECT[/SUBPROJECT] - Affect actions from a specific project (default: none)
561
+ --search, --find, --grep=QUERY - Filter results using search terms (may be used more than once, default: none)
559
562
  --tagged=TAG - Match actions containing tag. Allows value comparisons (may be used more than once, default: none)
560
563
  --to, --move=PROJECT - Move action to specific project (default: none)
561
564
  -x, --exact - Match pattern exactly
@@ -591,6 +594,7 @@ COMMAND OPTIONS
591
594
  -n, --note - Prompt for additional notes. Input will be appended to any existing note. If STDIN input (piped) is detected, it will be used as a note.
592
595
  -o, --overwrite - Overwrite note instead of appending
593
596
  --proj, --project=PROJECT[/SUBPROJECT] - Affect actions from a specific project (default: none)
597
+ --search, --find, --grep=QUERY - Filter results using search terms (may be used more than once, default: none)
594
598
  --tagged=TAG - Match actions containing tag. Allows value comparisons (may be used more than once, default: none)
595
599
  -x, --exact - Match pattern exactly
596
600
 
@@ -37,6 +37,10 @@ class App
37
37
  c.desc 'Act on all matches immediately (no menu)'
38
38
  c.switch %i[all], negatable: false
39
39
 
40
+ c.desc 'Filter results using search terms'
41
+ c.arg_name 'QUERY'
42
+ c.flag %i[search find grep], multiple: true
43
+
40
44
  c.desc 'Interpret search pattern as regular expression'
41
45
  c.switch %i[e regex], negatable: false
42
46
 
@@ -48,9 +52,13 @@ class App
48
52
  c.flag %i[in todo]
49
53
 
50
54
  c.action do |global, options, args|
55
+ args.concat(options[:search])
56
+
51
57
  if options[:done]
52
58
  options[:tagged] << 'done'
53
59
  options[:all] = true
60
+ else
61
+ options[:tagged] << '-done'
54
62
  end
55
63
 
56
64
  options[:done] = true
@@ -40,6 +40,10 @@ class App
40
40
  c.arg_name 'DEPTH'
41
41
  c.flag %i[d depth], must_match: /^[1-9]$/, type: :integer, default_value: 1
42
42
 
43
+ c.desc 'Filter results using search terms'
44
+ c.arg_name 'QUERY'
45
+ c.flag %i[search find grep], multiple: true
46
+
43
47
  c.desc 'Match actions containing tag. Allows value comparisons'
44
48
  c.arg_name 'TAG'
45
49
  c.flag %i[tagged], multiple: true
@@ -54,6 +58,8 @@ class App
54
58
  c.switch %i[x exact], negatable: false
55
59
 
56
60
  c.action do |global, options, args|
61
+ args.concat(options[:search])
62
+
57
63
  options[:finish] = true
58
64
  options[:f] = true
59
65
  options[:to] = 'Archive' if options[:archive] && !options[:to]
@@ -55,6 +55,10 @@ class App
55
55
  c.arg_name 'TAG'
56
56
  c.flag %i[r remove], multiple: true
57
57
 
58
+ c.desc 'Use with --find to find and replace with new text. Enables --exact when used'
59
+ c.arg_name 'TEXT'
60
+ c.flag %i[replace]
61
+
58
62
  c.desc 'Add a @done tag to action'
59
63
  c.switch %i[f finish], negatable: false
60
64
 
@@ -79,6 +83,10 @@ class App
79
83
  c.arg_name 'DEPTH'
80
84
  c.flag %i[d depth], must_match: /^[1-9]$/, type: :integer, default_value: 1
81
85
 
86
+ c.desc 'Filter results using search terms'
87
+ c.arg_name 'QUERY'
88
+ c.flag %i[search find grep], multiple: true
89
+
82
90
  c.desc 'Match actions containing tag. Allows value comparisons'
83
91
  c.arg_name 'TAG'
84
92
  c.flag %i[tagged], multiple: true
@@ -95,6 +103,8 @@ class App
95
103
  c.action do |global_options, options, args|
96
104
  reader = TTY::Reader.new
97
105
 
106
+ args.concat(options[:search])
107
+
98
108
  append = options[:at] ? options[:at] =~ /^[ae]/i : global_options[:add_at] =~ /^[ae]/i
99
109
 
100
110
  if options[:restore] || (!options[:remove].nil? && options[:remove].include?('done'))
@@ -106,6 +116,8 @@ class App
106
116
  options[:tagged] << '-done'
107
117
  end
108
118
 
119
+ options[:exact] = true unless options[:replace].nil?
120
+
109
121
  action = if args.count.positive?
110
122
  args.join(' ').strip
111
123
  else
@@ -244,6 +256,7 @@ class App
244
256
  priority: priority,
245
257
  project: options[:project],
246
258
  remove_tag: remove_tags,
259
+ replace: options[:replace],
247
260
  tagged: tags)
248
261
  end
249
262
  end
data/lib/na/action.rb CHANGED
@@ -95,13 +95,6 @@ module NA
95
95
  file_tpl = "#{template[:file]}#{file} {x}"
96
96
  filename = NA::Color.template(file_tpl)
97
97
 
98
- # Add notes if needed
99
- note = if notes && @note.count.positive?
100
- NA::Color.template("\n#{@note.map { |l| " #{template[:note]}• #{l}{x}" }.join("\n")}")
101
- else
102
- ''
103
- end
104
-
105
98
  # colorize the action and highlight tags
106
99
  @action.gsub!(/\{(.*?)\}/, '\\{\1\\}')
107
100
  action = NA::Color.template("#{template[:action]}#{@action.sub(/ @#{NA.na_tag}\b/, '')}{x}")
@@ -112,9 +105,27 @@ module NA
112
105
 
113
106
  if detect_width
114
107
  width = TTY::Screen.columns
115
- prefix = NA::Color.uncolor(pretty(template: { templates: { output: template[:templates][:output].sub(/%action/, '') } }, detect_width: false))
108
+ prefix = NA::Color.uncolor(pretty(template: { templates: { output: template[:templates][:output].sub(/%action/, '').sub(/%note/, '') } }, detect_width: false))
116
109
  indent = prefix.length
110
+
111
+ # Add notes if needed
112
+ note = if notes && @note.count.positive?
113
+ NA::Color.template(@note.wrap(width, indent, template[:note]))
114
+ elsif !notes && @note.count.positive?
115
+ action += "#{template[:note]}*"
116
+ else
117
+ ''
118
+ end
119
+
117
120
  action = action.wrap(width, indent)
121
+ else
122
+ note = if notes && @note.count.positive?
123
+ NA::Color.template("\n#{@note.map { |l| " #{template[:note]}• #{l.wrap(width, indent)}{x}" }.join("\n")}")
124
+ elsif !notes && @note.count.positive?
125
+ action += "#{template[:note]}*"
126
+ else
127
+ ''
128
+ end
118
129
  end
119
130
 
120
131
  # Replace variables in template string and output colorized
data/lib/na/actions.rb CHANGED
@@ -79,7 +79,7 @@ module NA
79
79
 
80
80
  files.map { |f| NA.notify(f, debug: true) } if files
81
81
 
82
- output = map { |action| action.pretty(template: { output: template }, regexes: regexes, notes: notes) }
82
+ output = map { |action| action.pretty(template: { templates: { output: template } }, regexes: regexes, notes: notes) }
83
83
  NA::Pager.page(output.join("\n"))
84
84
  end
85
85
  end
data/lib/na/array.rb CHANGED
@@ -10,4 +10,11 @@ class ::Array
10
10
  def remove_bad
11
11
  compact.map { |x| x.is_a?(String) ? x.strip : x }.select(&:good?)
12
12
  end
13
+
14
+ def wrap(width, indent, color)
15
+ map! do |l|
16
+ "#{color}#{' ' * indent }• #{l.wrap(width, indent)}{x}"
17
+ end
18
+ "\n#{join("\n")}"
19
+ end
13
20
  end
@@ -244,6 +244,7 @@ module NA
244
244
  project: nil,
245
245
  move: nil,
246
246
  remove_tag: [],
247
+ replace: nil,
247
248
  tagged: nil)
248
249
 
249
250
  projects = find_projects(target)
@@ -328,6 +329,9 @@ module NA
328
329
  action.note = new_note
329
330
  end
330
331
 
332
+ # If replace is defined, use search to search and replace text in action
333
+ action.action.sub!(Regexp.new(Regexp.escape(search), Regexp::IGNORECASE), replace) if replace
334
+
331
335
  action.process(priority: priority, finish: finish, add_tag: add_tag, remove_tag: remove_tag)
332
336
 
333
337
  target_proj = if target_proj
data/lib/na/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Na
2
- VERSION = '1.2.46'
2
+ VERSION = '1.2.47'
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.45<!--END VER-->.
12
+ The current version of `na` is <!--VER-->1.2.46<!--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.46
4
+ version: 1.2.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
@@ -246,7 +246,6 @@ files:
246
246
  - na.rdoc
247
247
  - scripts/fixreadme.rb
248
248
  - src/_README.md
249
- - test2.txt
250
249
  homepage: https://brettterpstra.com/projects/na/
251
250
  licenses:
252
251
  - MIT
data/test2.txt DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- comment: 2023
3
- keywords:
4
- ---
5
-
6
- Inbox:
7
- - Test @na