atk_toolbox 0.0.135 → 0.0.136
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/atk/commands/project.rb +12 -2
- data/lib/atk/console.rb +90 -3
- data/lib/atk/info.rb +1 -1
- 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: d5313d9ba2e7a1a788b336a26e113440e6a1c6c9f64ffec02bd4a388dd877aca
|
4
|
+
data.tar.gz: 247ad26779fe3ebaf983ca02619a03c10e265efaa539bc702bcf1d5bb6892d45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b69f1aa5000ed9a2c3b3bdfd0b2161ca9d835ee40c344ccbbaede78b0d67090ebe288b6f2fdc9e749aea8ecef1806c5f067bc917b5b5796decde814bc34a83d2
|
7
|
+
data.tar.gz: 13dfed1e563b45eff0d68580a3233538f978cec9fe05218731e33f502773967dd3aba8dba581c4c991e1664cbb8991e00064e11b575f863faebc0348c35d9b00
|
data/lib/atk/commands/project.rb
CHANGED
@@ -136,12 +136,22 @@ module Atk
|
|
136
136
|
# temporairly set the dir to be the same as the info.yaml
|
137
137
|
FS.in_dir(Info.folder()) do
|
138
138
|
if command.is_a?(String)
|
139
|
-
|
139
|
+
result = system(command+' '+command_args.join(' '))
|
140
140
|
elsif command.is_a?(Code)
|
141
|
-
command.run(*command_args)
|
141
|
+
result = command.run(*command_args)
|
142
142
|
elsif command == nil
|
143
143
|
puts "I don't think that command is in the info.yaml file"
|
144
144
|
end
|
145
|
+
|
146
|
+
# if command resulted in error then raise an error
|
147
|
+
if not result
|
148
|
+
colored_command_name = command_name.color_as :key_term
|
149
|
+
raise <<-HEREDOC.remove_indent
|
150
|
+
|
151
|
+
When running: #{"project execute ".color_as :code}#{colored_command_name}
|
152
|
+
The script for #{colored_command_name} hit an error and had an exit code of: #{$?.exitstatus}
|
153
|
+
HEREDOC
|
154
|
+
end
|
145
155
|
end
|
146
156
|
#
|
147
157
|
# commands
|
data/lib/atk/console.rb
CHANGED
@@ -4,13 +4,31 @@ require_relative "../console_colors.rb"
|
|
4
4
|
# easy access to the commandline
|
5
5
|
class String
|
6
6
|
# add a - operator to strings that makes it behave like a system() call
|
7
|
-
# but it returns a success value for chaining commands with || or &&
|
8
7
|
def -@
|
9
|
-
|
10
|
-
return $?.success?
|
8
|
+
return system(self)
|
11
9
|
end
|
12
10
|
end
|
13
11
|
|
12
|
+
class CommandResult
|
13
|
+
def initialize(io_object)
|
14
|
+
@io_object = io_object
|
15
|
+
end
|
16
|
+
|
17
|
+
def read
|
18
|
+
if @read == nil && @io_object
|
19
|
+
@read = @io_object.read
|
20
|
+
end
|
21
|
+
return @read
|
22
|
+
end
|
23
|
+
|
24
|
+
def exitcode
|
25
|
+
if !@io_object
|
26
|
+
return Errno::ENOENT.new
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
14
32
|
|
15
33
|
#
|
16
34
|
# Console
|
@@ -74,6 +92,75 @@ Console = Class.new do
|
|
74
92
|
return @stdin
|
75
93
|
end
|
76
94
|
|
95
|
+
#
|
96
|
+
# returns the command object, ignores errors
|
97
|
+
#
|
98
|
+
def run!(command)
|
99
|
+
if command.is_a?(String)
|
100
|
+
# by default return a string with stderr included
|
101
|
+
begin
|
102
|
+
result = CommandResult.new(IO.popen(command, err: [:child, :out]))
|
103
|
+
puts result.read
|
104
|
+
rescue
|
105
|
+
result = CommandResult.new(nil)
|
106
|
+
end
|
107
|
+
return result
|
108
|
+
else
|
109
|
+
raise <<-HEREDOC.remove_indent
|
110
|
+
|
111
|
+
|
112
|
+
The argument for run!() must be a string
|
113
|
+
this restriction will be lifted in the future
|
114
|
+
HEREDOC
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
#
|
119
|
+
# returns true if successful, false/nil on error
|
120
|
+
#
|
121
|
+
def run?(command)
|
122
|
+
if command.is_a?(String)
|
123
|
+
return system(command)
|
124
|
+
else
|
125
|
+
raise <<-HEREDOC.remove_indent
|
126
|
+
|
127
|
+
|
128
|
+
The argument for run?() must be a string
|
129
|
+
this restriction will be lifted in the future
|
130
|
+
HEREDOC
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
#
|
135
|
+
# returns process info if successful, raises error if command failed
|
136
|
+
#
|
137
|
+
def run(command)
|
138
|
+
if command.is_a?(String)
|
139
|
+
# if the command failed
|
140
|
+
if !system(command)
|
141
|
+
# throw an error
|
142
|
+
raise <<-HEREDOC.remove_indent
|
143
|
+
|
144
|
+
|
145
|
+
From run(command)
|
146
|
+
The command: #{command.color_as :code}
|
147
|
+
Failed with a exitcode of: #{$?.exitstatus}
|
148
|
+
|
149
|
+
#{"This likely means the command could not be found" if $?.exitstatus == 127}
|
150
|
+
#{"Hopefully there is additional error info above" if $?.exitstatus != 127}
|
151
|
+
HEREDOC
|
152
|
+
end
|
153
|
+
return $?
|
154
|
+
else
|
155
|
+
raise <<-HEREDOC.remove_indent
|
156
|
+
|
157
|
+
|
158
|
+
The argument for run() must be a string
|
159
|
+
this restriction will be lifted in the future
|
160
|
+
HEREDOC
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
77
164
|
def path_for(name_of_executable)
|
78
165
|
return OS.path_for_executable(name_of_executable)
|
79
166
|
end
|
data/lib/atk/info.rb
CHANGED
@@ -68,7 +68,7 @@ end
|
|
68
68
|
# a file needs to be created in the root dir so that things like __dir__ work properly
|
69
69
|
# the first line of the temp file deletes itself so that it appears as if no file ever existed
|
70
70
|
IO.write(temp_file, "File.delete('./.info_language_runner_cache.rb')\n#{@value}")
|
71
|
-
|
71
|
+
system("ruby", temp_file, *args)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
register_tag('!language/ruby', RubyCode)
|
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.136
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-prompt
|