nxxd 1.3 → 1.4
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/bin/nxxd +24 -22
- data/lib/nxxd/version.rb +1 -1
- 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: bbf9ab29dd62c0a7e1f4d08c59fdf54f0e0417b644a4322708a842d2c1f54599
|
|
4
|
+
data.tar.gz: '09993305785a0ef2fe95ceee5d32e0976ce4e96e10e8630d96339e91ad45f1c9'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 58e8a9ba275d34d3f79422060d26b11a5e1d180f24f8c32854eff55607948c37548f063b18e97ffbb3b55665a2199a7a9c93c7348e2b55ef8829982c551e4bd5
|
|
7
|
+
data.tar.gz: 12d11bf3dc4304d1d8abcad03c58211458cb42d6a3eb312be24717cb339fc69d478a398518113986b9dcfca1a3e52471fd36403499919c9e3b9d159335499c81
|
data/bin/nxxd
CHANGED
|
@@ -48,37 +48,38 @@ module Nxxd
|
|
|
48
48
|
attr_reader :opts, :args
|
|
49
49
|
|
|
50
50
|
def initialize params
|
|
51
|
-
@opts
|
|
51
|
+
@opts = {}
|
|
52
|
+
@args = []
|
|
52
53
|
env = ENV[ OPT_ENV]
|
|
53
54
|
if env then
|
|
54
|
-
@params = env.split
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
case p
|
|
58
|
-
when /^--/ then $'.empty? or set $'
|
|
59
|
-
when /^-/ then set_short $'
|
|
60
|
-
else set p
|
|
61
|
-
end
|
|
62
|
-
end
|
|
55
|
+
@params, @args = env.split, []
|
|
56
|
+
parse_params
|
|
57
|
+
@args.empty? or @args.clear
|
|
63
58
|
end
|
|
64
59
|
@params = params
|
|
60
|
+
parse_params
|
|
61
|
+
rescue StandardError
|
|
62
|
+
$stderr.puts $!
|
|
63
|
+
exit 1
|
|
64
|
+
ensure
|
|
65
|
+
@params = nil
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
def parse_params
|
|
65
71
|
until @params.empty? do
|
|
66
72
|
p = @params.shift
|
|
67
73
|
case p
|
|
68
|
-
when /^--/ then $'.empty?
|
|
69
|
-
when /^-/ then set_short $'
|
|
74
|
+
when /^--/ then if $'.empty? then break else set $' end
|
|
75
|
+
when /^-/ then if $'.empty? then @args.push p else set_short $' end
|
|
70
76
|
else @args.push p
|
|
71
77
|
end
|
|
72
78
|
end
|
|
73
79
|
@args.concat @params
|
|
74
|
-
@params
|
|
75
|
-
rescue StandardError
|
|
76
|
-
$stderr.puts $!
|
|
77
|
-
exit 1
|
|
80
|
+
@params.clear
|
|
78
81
|
end
|
|
79
82
|
|
|
80
|
-
private
|
|
81
|
-
|
|
82
83
|
def set_short cont
|
|
83
84
|
@cont = cont
|
|
84
85
|
until @cont.empty? do
|
|
@@ -132,7 +133,7 @@ module Nxxd
|
|
|
132
133
|
_, arg, text = *defn
|
|
133
134
|
type = type_repr arg if Symbol === arg
|
|
134
135
|
end
|
|
135
|
-
puts " %-
|
|
136
|
+
puts " %-16s %-10s %s" % [(opt_repr opt), type, text]
|
|
136
137
|
}
|
|
137
138
|
end
|
|
138
139
|
|
|
@@ -149,10 +150,11 @@ module Nxxd
|
|
|
149
150
|
def initialize params
|
|
150
151
|
o = Options.new params
|
|
151
152
|
@opts, @args = o.opts, o.args
|
|
152
|
-
@output = (@opts.delete :output) || last_arg_if_not_existing
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
def run
|
|
156
|
+
@output = (@opts.delete :output) || last_arg_if_not_existing
|
|
157
|
+
@args.push nil if @args.empty?
|
|
156
158
|
open_output do |o|
|
|
157
159
|
if @opts.delete :reverse then
|
|
158
160
|
open_inputs do |f|
|
|
@@ -188,8 +190,8 @@ module Nxxd
|
|
|
188
190
|
private
|
|
189
191
|
|
|
190
192
|
def last_arg_if_not_existing
|
|
191
|
-
|
|
192
|
-
@args.pop
|
|
193
|
+
a = @args.last
|
|
194
|
+
@args.pop unless not a or a == "-" or File.exist? a
|
|
193
195
|
end
|
|
194
196
|
|
|
195
197
|
def open_inputs
|
data/lib/nxxd/version.rb
CHANGED