nub 0.0.28 → 0.0.29
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/nub/commander.rb +4 -2
- data/lib/nub/log.rb +2 -11
- data/lib/nub/sys.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2d2c2ee5ea0dfbc1a6ab81edabe2df53d1ca2381a64f70645b314fab80ae46c
|
4
|
+
data.tar.gz: 4e757be870d2e93d4a997750390b365240a06872e89716d6571a667b48f2eecf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca89d8100c847e6cfee9e72f32bc2242729ad7f5e4f5003f20cc7695e9b5de0582ee73b1cf614c750d3b6e045c31947051114a37a8fd8f213593ba0bc44169f5
|
7
|
+
data.tar.gz: b173a64794b3304deea13bf2ea297ecac74e410f81d71a9ff03f7de978048a4633016d4c048b86af0948e98b3a39f30f6eb86b70954ef50f0d4df7275430cf0a
|
data/lib/nub/commander.rb
CHANGED
@@ -157,8 +157,10 @@ class Commander
|
|
157
157
|
# @returns [String] the app's help string
|
158
158
|
def help
|
159
159
|
help = "#{banner}\n"
|
160
|
-
|
161
|
-
|
160
|
+
if !@examples.nil? && !@examples.empty?
|
161
|
+
newline = Sys.strip_colorize(@examples)[-1] != "\n" ? "\n" : ""
|
162
|
+
help += "Examples:\n#{@examples}\n#{newline}"
|
163
|
+
end
|
162
164
|
help += "Usage: ./#{@app} [commands] [options]\n"
|
163
165
|
help += " #{'-h|--help'.ljust(@just)}Print command/options help: Flag\n"
|
164
166
|
help += "COMMANDS:\n"
|
data/lib/nub/log.rb
CHANGED
@@ -121,7 +121,7 @@ module Log
|
|
121
121
|
str = format(str) if stamp
|
122
122
|
|
123
123
|
if !str.empty?
|
124
|
-
@file << strip_colorize(str) if @path
|
124
|
+
@file << Sys.strip_colorize(str) if @path
|
125
125
|
@@_queue << str if @@_queue
|
126
126
|
$stdout.print(str) if @@_stdout
|
127
127
|
end
|
@@ -145,7 +145,7 @@ module Log
|
|
145
145
|
str = format(str) if stamp
|
146
146
|
|
147
147
|
# Handle output
|
148
|
-
@file.puts(strip_colorize(str)) if @path
|
148
|
+
@file.puts(Sys.strip_colorize(str)) if @path
|
149
149
|
@@_queue << "#{str}\n" if @@_queue
|
150
150
|
$stdout.puts(str) if @@_stdout
|
151
151
|
|
@@ -189,15 +189,6 @@ module Log
|
|
189
189
|
return @@_queue ? @@_queue.empty? : true
|
190
190
|
end
|
191
191
|
|
192
|
-
# Strip the ansi color codes from the given string
|
193
|
-
# @param str [String] string with ansi color codes
|
194
|
-
# @returns [String] string without any ansi codes
|
195
|
-
def strip_colorize(str)
|
196
|
-
@@_monitor.synchronize{
|
197
|
-
return str.gsub(/\e\[0;[39]\d;49m/, '').gsub(/\e\[0m/, '')
|
198
|
-
}
|
199
|
-
end
|
200
|
-
|
201
192
|
# Tokenize the given colorized string
|
202
193
|
# @param str [String] string with ansi color codes
|
203
194
|
# @returns [Array] array of Token
|
data/lib/nub/sys.rb
CHANGED
@@ -49,6 +49,14 @@ module Sys
|
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|
52
|
+
|
53
|
+
# Strip the ansi color codes from the given string
|
54
|
+
# @param str [String] string with ansi color codes
|
55
|
+
# @returns [String] string without any ansi codes
|
56
|
+
def self.strip_colorize(str)
|
57
|
+
return str.gsub(/\e\[0;[39]\d;49m/, '').gsub(/\e\[0m/, '')
|
58
|
+
end
|
59
|
+
|
52
60
|
end
|
53
61
|
|
54
62
|
# vim: ft=ruby:ts=2:sw=2:sts=2
|