atk_toolbox 0.0.137 → 0.0.138
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/lib/atk/console.rb +41 -11
- data/lib/atk_toolbox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1fca183d8a55e40db853c94d3dd8b3e3e299c85e5ac7ff2dbda79ec9801b5d0
|
4
|
+
data.tar.gz: de4210e5a7f73c9f59b2f44d0a1a9449b0ddcc3a831d135e8d0a584f1e33e352
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93a4d1176a611db19c2f86b61424c97b939532a15e1ee52c0cab15f44fb63275294c75ca09f17c51dfcc98faa50d18120a3d98bde8e225c32fab43767bf4d31a
|
7
|
+
data.tar.gz: 9fb9bc9461beca3359136240f51a8d6ccf5a10a9f5ac217b7ffa394a7c09c62f27922d4f890b39c35513184f76993d7485b86863f6988a1bcc8a1d9480dcced1
|
data/lib/atk/console.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative "./os.rb"
|
2
2
|
require_relative "../console_colors.rb"
|
3
|
+
require_relative "./remove_indent.rb"
|
3
4
|
|
4
5
|
# easy access to the commandline
|
5
6
|
class String
|
@@ -10,8 +11,9 @@ class String
|
|
10
11
|
end
|
11
12
|
|
12
13
|
class CommandResult
|
13
|
-
def initialize(io_object)
|
14
|
+
def initialize(io_object, process_object)
|
14
15
|
@io_object = io_object
|
16
|
+
@process_object = process_object
|
15
17
|
end
|
16
18
|
|
17
19
|
def read
|
@@ -26,6 +28,19 @@ class CommandResult
|
|
26
28
|
return Errno::ENOENT.new
|
27
29
|
end
|
28
30
|
end
|
31
|
+
|
32
|
+
class Error < Exception
|
33
|
+
attr_accessor :command_result, :message
|
34
|
+
|
35
|
+
def initialize(message, command_result)
|
36
|
+
@message = message
|
37
|
+
@command_result = command_result
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_s
|
41
|
+
return @message
|
42
|
+
end
|
43
|
+
end
|
29
44
|
end
|
30
45
|
|
31
46
|
|
@@ -99,10 +114,14 @@ Console = Class.new do
|
|
99
114
|
if command.is_a?(String)
|
100
115
|
# by default return a string with stderr included
|
101
116
|
begin
|
102
|
-
|
117
|
+
command_info = IO.popen(command, err: [:child, :out])
|
118
|
+
Process.wait(command_info.pid)
|
119
|
+
process_info = $?
|
120
|
+
result = CommandResult.new(command_info, process_info)
|
103
121
|
puts result.read
|
104
122
|
rescue
|
105
|
-
|
123
|
+
process_info = $?
|
124
|
+
result = CommandResult.new(nil, process_info)
|
106
125
|
end
|
107
126
|
return result
|
108
127
|
else
|
@@ -136,21 +155,32 @@ Console = Class.new do
|
|
136
155
|
#
|
137
156
|
def run(command)
|
138
157
|
if command.is_a?(String)
|
139
|
-
#
|
140
|
-
|
141
|
-
|
142
|
-
|
158
|
+
# by default return a string with stderr included
|
159
|
+
begin
|
160
|
+
command_info = IO.popen(command, err: [:child, :out])
|
161
|
+
Process.wait(command_info.pid)
|
162
|
+
process_info = $?
|
163
|
+
result = CommandResult.new(command_info, process_info)
|
164
|
+
puts result.read
|
165
|
+
rescue
|
166
|
+
process_info = $?
|
167
|
+
result = CommandResult.new(nil, process_info)
|
168
|
+
end
|
169
|
+
# if ended with error
|
170
|
+
if !process_info.success?
|
171
|
+
# then raise an error
|
172
|
+
raise CommandResult::Error.new(<<-HEREDOC.remove_indent, result)
|
143
173
|
|
144
174
|
|
145
175
|
From run(command)
|
146
176
|
The command: #{command.color_as :code}
|
147
|
-
Failed with a exitcode of: #{
|
177
|
+
Failed with a exitcode of: #{process_info.exitstatus}
|
148
178
|
|
149
|
-
#{"This likely means the command could not be found" if
|
150
|
-
#{"Hopefully there is additional error info above" if
|
179
|
+
#{"This likely means the command could not be found" if process_info.exitstatus == 127}
|
180
|
+
#{"Hopefully there is additional error info above" if process_info.exitstatus != 127}
|
151
181
|
HEREDOC
|
152
182
|
end
|
153
|
-
return
|
183
|
+
return result
|
154
184
|
else
|
155
185
|
raise <<-HEREDOC.remove_indent
|
156
186
|
|
data/lib/atk_toolbox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atk_toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.138
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Hykin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-prompt
|