simple-cli 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/simple/cli/helpers.rb +8 -9
- data/lib/simple/cli/logger/colored_logger.rb +8 -6
- data/lib/simple/cli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7533ba5ce80d0d6f173f3bc5cc071ff22590977
|
4
|
+
data.tar.gz: 2e416315dbb0addf9eedaa7e84fc0cebaf17dfbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 552c4c85dd75a898b035b53bfc67d2d74b3e1f37569099d7fb6ec88e61827272d23f28a0252bf30bf674d817b64040f1c25e3606baf31860a2ae0c73eb2e6768
|
7
|
+
data.tar.gz: b58f646e7a7aefe93c66731d228e2f14dfe2266112da195041e0f13f580c4d22b9ce280a3b8eb0dc3809306d97151e69ac7fe5065bf3774bdaa5c51bd948cc08
|
data/Gemfile.lock
CHANGED
data/lib/simple/cli/helpers.rb
CHANGED
@@ -50,21 +50,20 @@ module Simple::CLI::Helpers
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def sh
|
53
|
-
|
53
|
+
::Simple::CLI.logger.info "> #{self}"
|
54
54
|
stdout_str, @process_status = Open3.capture2(*@args, binmode: true)
|
55
55
|
stdout_str
|
56
56
|
end
|
57
57
|
|
58
58
|
def run
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
::Simple::CLI.logger.info "> #{self}"
|
60
|
+
if @args.length > 1
|
61
|
+
system to_s
|
62
|
+
else
|
63
|
+
system @args.first
|
64
|
+
end
|
65
|
+
ensure
|
66
66
|
@process_status = $?
|
67
|
-
rv
|
68
67
|
end
|
69
68
|
|
70
69
|
def success?
|
@@ -84,14 +84,16 @@ module Simple::CLI::Logger::ColoredLogger
|
|
84
84
|
if log_level < Logger::INFO
|
85
85
|
padding = " " * (90 - msg_length) if msg_length < 90
|
86
86
|
msg = "#{msg}#{padding}"
|
87
|
-
|
88
|
-
source = caller[2]
|
89
|
-
source.gsub!( Dir.getwd, "." )
|
90
|
-
source.gsub!( File.expand_path("~"), "~" )
|
91
|
-
|
92
|
-
msg = "#{msg}from #{source}"
|
87
|
+
msg = "#{msg}from #{source_from_caller}"
|
93
88
|
end
|
94
89
|
|
95
90
|
STDERR.puts msg
|
96
91
|
end
|
92
|
+
|
93
|
+
# The heuristic used to determine the caller is not perfect, but should
|
94
|
+
# do well in most cases.
|
95
|
+
def source_from_caller
|
96
|
+
source = caller.find { |loc| !loc.include? "/simple-cli/lib/simple/cli" }
|
97
|
+
source || caller[2]
|
98
|
+
end
|
97
99
|
end
|
data/lib/simple/cli/version.rb
CHANGED