na 1.2.29 → 1.2.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/Gemfile.lock +1 -1
- data/README.md +28 -20
- data/bin/commands/add.rb +167 -164
- data/bin/commands/archive.rb +54 -51
- data/bin/commands/changes.rb +18 -15
- data/bin/commands/complete.rb +50 -47
- data/bin/commands/completed.rb +99 -0
- data/bin/commands/edit.rb +37 -34
- data/bin/commands/find.rb +109 -106
- data/bin/commands/init.rb +22 -19
- data/bin/commands/next.rb +135 -131
- data/bin/commands/projects.rb +27 -24
- data/bin/commands/prompt.rb +41 -38
- data/bin/commands/saved.rb +42 -34
- data/bin/commands/tagged.rb +137 -134
- data/bin/commands/todos.rb +23 -20
- data/bin/commands/update.rb +215 -207
- data/bin/na +7 -1166
- data/lib/na/array.rb +13 -0
- data/lib/na/help_monkey_patch.rb +32 -0
- data/lib/na/next_action.rb +3 -2
- data/lib/na/pager.rb +94 -0
- data/lib/na/string.rb +10 -0
- data/lib/na/version.rb +1 -1
- data/lib/na.rb +2 -0
- metadata +7 -3
data/lib/na/array.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ::Array
|
4
|
+
##
|
5
|
+
## Like Array#compact -- removes nil items, but also
|
6
|
+
## removes empty strings, zero or negative numbers and FalseClass items
|
7
|
+
##
|
8
|
+
## @return [Array] Array without "bad" elements
|
9
|
+
##
|
10
|
+
def remove_bad
|
11
|
+
compact.map { |x| x.is_a?(String) ? x.strip : x }.select(&:good?)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GLI
|
4
|
+
module Commands
|
5
|
+
# Help Command Monkeypatch for paginated output
|
6
|
+
class Help < Command
|
7
|
+
def show_help(global_options, options, arguments, out, error)
|
8
|
+
NA::Pager.paginate = true
|
9
|
+
|
10
|
+
command_finder = HelpModules::CommandFinder.new(@app, arguments, error)
|
11
|
+
if options[:c]
|
12
|
+
help_output = HelpModules::HelpCompletionFormat.new(@app, command_finder, arguments).format
|
13
|
+
out.puts help_output unless help_output.nil?
|
14
|
+
elsif arguments.empty? || options[:c]
|
15
|
+
NA::Pager.page HelpModules::GlobalHelpFormat.new(@app, @sorter, @text_wrapping_class).format
|
16
|
+
else
|
17
|
+
name = arguments.shift
|
18
|
+
command = command_finder.find_command(name)
|
19
|
+
unless command.nil?
|
20
|
+
NA::Pager.page HelpModules::CommandHelpFormat.new(
|
21
|
+
command,
|
22
|
+
@app,
|
23
|
+
@sorter,
|
24
|
+
@synopsis_formatter_class,
|
25
|
+
@text_wrapping_class
|
26
|
+
).format
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/na/next_action.rb
CHANGED
@@ -512,7 +512,7 @@ module NA
|
|
512
512
|
end
|
513
513
|
end
|
514
514
|
end
|
515
|
-
|
515
|
+
NA::Pager.page out.join("\n")
|
516
516
|
else
|
517
517
|
template = if files.count.positive?
|
518
518
|
if files.count == 1
|
@@ -533,7 +533,8 @@ module NA
|
|
533
533
|
|
534
534
|
files.map { |f| notify("{dw}#{f}", debug: true) } if files
|
535
535
|
|
536
|
-
|
536
|
+
output = actions.map { |action| action.pretty(template: { output: template }, regexes: regexes, notes: notes) }
|
537
|
+
NA::Pager.page(output.join("\n"))
|
537
538
|
end
|
538
539
|
end
|
539
540
|
|
data/lib/na/pager.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
module NA
|
6
|
+
# Pagination
|
7
|
+
module Pager
|
8
|
+
class << self
|
9
|
+
# Boolean determines whether output is paginated
|
10
|
+
def paginate
|
11
|
+
@paginate ||= false
|
12
|
+
end
|
13
|
+
|
14
|
+
# Enable/disable pagination
|
15
|
+
#
|
16
|
+
# @param should_paginate [Boolean] true to paginate
|
17
|
+
def paginate=(should_paginate)
|
18
|
+
@paginate = should_paginate
|
19
|
+
end
|
20
|
+
|
21
|
+
# Page output. If @paginate is false, just dump to
|
22
|
+
# STDOUT
|
23
|
+
#
|
24
|
+
# @param text [String] text to paginate
|
25
|
+
#
|
26
|
+
def page(text)
|
27
|
+
unless @paginate
|
28
|
+
puts text
|
29
|
+
return
|
30
|
+
end
|
31
|
+
|
32
|
+
pager = which_pager
|
33
|
+
|
34
|
+
read_io, write_io = IO.pipe
|
35
|
+
|
36
|
+
input = $stdin
|
37
|
+
|
38
|
+
pid = Kernel.fork do
|
39
|
+
write_io.close
|
40
|
+
input.reopen(read_io)
|
41
|
+
read_io.close
|
42
|
+
|
43
|
+
# Wait until we have input before we start the pager
|
44
|
+
IO.select [input]
|
45
|
+
|
46
|
+
begin
|
47
|
+
NA.notify("{dw}Pager #{pager}", debug: true)
|
48
|
+
exec(pager)
|
49
|
+
rescue SystemCallError => e
|
50
|
+
raise Errors::DoingStandardError, "Pager error, #{e}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
begin
|
55
|
+
read_io.close
|
56
|
+
write_io.write(text)
|
57
|
+
write_io.close
|
58
|
+
rescue SystemCallError # => e
|
59
|
+
# raise Errors::DoingStandardError, "Pager error, #{e}"
|
60
|
+
end
|
61
|
+
|
62
|
+
_, status = Process.waitpid2(pid)
|
63
|
+
status.success?
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def git_pager
|
69
|
+
TTY::Which.exist?('git') ? `#{TTY::Which.which('git')} config --get-all core.pager` : nil
|
70
|
+
end
|
71
|
+
|
72
|
+
def pagers
|
73
|
+
[
|
74
|
+
ENV['PAGER'],
|
75
|
+
'less -FXr',
|
76
|
+
ENV['GIT_PAGER'],
|
77
|
+
git_pager,
|
78
|
+
'more -r'
|
79
|
+
].remove_bad
|
80
|
+
end
|
81
|
+
|
82
|
+
def find_executable(*commands)
|
83
|
+
execs = commands.empty? ? pagers : commands
|
84
|
+
execs
|
85
|
+
.remove_bad.uniq
|
86
|
+
.find { |cmd| TTY::Which.exist?(cmd.split.first) }
|
87
|
+
end
|
88
|
+
|
89
|
+
def which_pager
|
90
|
+
@which_pager ||= find_executable(*pagers)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/lib/na/string.rb
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
# String helpers
|
4
4
|
class ::String
|
5
|
+
##
|
6
|
+
## Tests if object is nil or empty
|
7
|
+
##
|
8
|
+
## @return [Boolean] true if object is defined and
|
9
|
+
## has content
|
10
|
+
##
|
11
|
+
def good?
|
12
|
+
!strip.empty?
|
13
|
+
end
|
14
|
+
|
5
15
|
def read_file
|
6
16
|
file = File.expand_path(self)
|
7
17
|
raise "Missing file #{file}" unless File.exist?(file)
|
data/lib/na/version.rb
CHANGED
data/lib/na.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'na/version'
|
4
|
+
require 'na/pager'
|
4
5
|
require 'time'
|
5
6
|
require 'fileutils'
|
6
7
|
require 'shellwords'
|
@@ -11,6 +12,7 @@ require 'tty-which'
|
|
11
12
|
require 'na/hash'
|
12
13
|
require 'na/colors'
|
13
14
|
require 'na/string'
|
15
|
+
require 'na/array'
|
14
16
|
require 'na/project'
|
15
17
|
require 'na/action'
|
16
18
|
require 'na/next_action'
|
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.
|
4
|
+
version: 1.2.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -210,6 +210,7 @@ files:
|
|
210
210
|
- bin/commands/archive.rb
|
211
211
|
- bin/commands/changes.rb
|
212
212
|
- bin/commands/complete.rb
|
213
|
+
- bin/commands/completed.rb
|
213
214
|
- bin/commands/edit.rb
|
214
215
|
- bin/commands/find.rb
|
215
216
|
- bin/commands/init.rb
|
@@ -223,9 +224,12 @@ files:
|
|
223
224
|
- bin/na
|
224
225
|
- lib/na.rb
|
225
226
|
- lib/na/action.rb
|
227
|
+
- lib/na/array.rb
|
226
228
|
- lib/na/colors.rb
|
227
229
|
- lib/na/hash.rb
|
230
|
+
- lib/na/help_monkey_patch.rb
|
228
231
|
- lib/na/next_action.rb
|
232
|
+
- lib/na/pager.rb
|
229
233
|
- lib/na/project.rb
|
230
234
|
- lib/na/prompt.rb
|
231
235
|
- lib/na/string.rb
|
@@ -260,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
260
264
|
- !ruby/object:Gem::Version
|
261
265
|
version: '0'
|
262
266
|
requirements: []
|
263
|
-
rubygems_version: 3.2.
|
267
|
+
rubygems_version: 3.2.15
|
264
268
|
signing_key:
|
265
269
|
specification_version: 4
|
266
270
|
summary: A command line tool for adding and listing project todos
|