shellopts 2.0.0 → 2.0.1
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/shellopts/args.rb +4 -6
- data/lib/shellopts/interpreter.rb +1 -1
- data/lib/shellopts/version.rb +1 -1
- data/lib/shellopts.rb +2 -1
- data/main +8 -8
- 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: 4f5448df8e0fdd882072ab927e185511b09ebd8b594a9556937fdfd20d41070d
|
4
|
+
data.tar.gz: 2743f77e88de6ff10562a2f7d3980b1bfc730d0e024e60e6472da48342a2f153
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e08795c96b4f745a00cb6c38e5ea63beef08ceb640a0427d4bc46ee705189cab188a227a9d1775177d6530596155744d6e8624fa378c87c47f94c36e1adf98b
|
7
|
+
data.tar.gz: cb12f16c665fe6fc0e0751ad2328aa7d8e1e48baad9d9d27addb4d88f6a083d780c61ee0b8b57e8218ee829a6e107afa8c076067dfa5d24a973bf353489d7433
|
data/lib/shellopts/args.rb
CHANGED
@@ -3,12 +3,8 @@ module ShellOpts
|
|
3
3
|
# Specialization of Array for arguments lists. Args extends Array with a
|
4
4
|
# #extract and an #expect method to extract elements from the array. The
|
5
5
|
# methods raise a ShellOpts::UserError exception in case of errors
|
6
|
+
#
|
6
7
|
class Args < Array
|
7
|
-
def initialize(shellopts, *args)
|
8
|
-
@shellopts = shellopts
|
9
|
-
super(*args)
|
10
|
-
end
|
11
|
-
|
12
8
|
# Remove and return elements from beginning of the array
|
13
9
|
#
|
14
10
|
# If +count_or_range+ is a number, that number of elements will be
|
@@ -19,6 +15,7 @@ module ShellOpts
|
|
19
15
|
#
|
20
16
|
# #extract raise a ShellOpts::UserError exception if there's is not enough
|
21
17
|
# elements in the array to satisfy the request
|
18
|
+
#
|
22
19
|
def extract(count_or_range, message = nil)
|
23
20
|
case count_or_range
|
24
21
|
when Range
|
@@ -44,6 +41,7 @@ module ShellOpts
|
|
44
41
|
#
|
45
42
|
# #expect raise a ShellOpts::UserError exception if the array is not emptied
|
46
43
|
# by the operation
|
44
|
+
#
|
47
45
|
def expect(count_or_range, message = nil)
|
48
46
|
case count_or_range
|
49
47
|
when Range
|
@@ -57,7 +55,7 @@ module ShellOpts
|
|
57
55
|
|
58
56
|
private
|
59
57
|
def inoa(message = nil)
|
60
|
-
raise
|
58
|
+
raise ArgumentError, message || "Illegal number of arguments"
|
61
59
|
end
|
62
60
|
end
|
63
61
|
end
|
data/lib/shellopts/version.rb
CHANGED
data/lib/shellopts.rb
CHANGED
@@ -21,6 +21,7 @@ require 'shellopts/stack.rb'
|
|
21
21
|
require 'shellopts/token.rb'
|
22
22
|
require 'shellopts/grammar.rb'
|
23
23
|
require 'shellopts/program.rb'
|
24
|
+
require 'shellopts/args.rb'
|
24
25
|
require 'shellopts/lexer.rb'
|
25
26
|
require 'shellopts/argument_type.rb'
|
26
27
|
require 'shellopts/parser.rb'
|
@@ -163,7 +164,7 @@ module ShellOpts
|
|
163
164
|
def self.process(spec, argv, **opts)
|
164
165
|
::ShellOpts.instance = shellopts = ShellOpts.new(**opts)
|
165
166
|
shellopts.process(spec, argv)
|
166
|
-
[shellopts.program, shellopts.
|
167
|
+
[shellopts.program, shellopts.args]
|
167
168
|
end
|
168
169
|
|
169
170
|
# Write short usage and error message to standard error and terminate
|
data/main
CHANGED
@@ -19,13 +19,13 @@ SPEC = %(
|
|
19
19
|
)
|
20
20
|
|
21
21
|
opts, args = ShellOpts.process(SPEC, ARGV)
|
22
|
-
puts "opts.alpha?: #{opts.alpha?.inspect}"
|
22
|
+
#puts "opts.alpha?: #{opts.alpha?.inspect}"
|
23
23
|
#puts "opts.alpha: #{opts.alpha.inspect}"
|
24
|
-
puts "opts.beta?: #{opts.beta?.inspect}"
|
25
|
-
puts "opts.beta: #{opts.beta.inspect}"
|
26
|
-
exit
|
27
|
-
ShellOpts::ShellOpts.brief
|
28
|
-
exit
|
24
|
+
#puts "opts.beta?: #{opts.beta?.inspect}"
|
25
|
+
#puts "opts.beta: #{opts.beta.inspect}"
|
26
|
+
#exit
|
27
|
+
#ShellOpts::ShellOpts.brief
|
28
|
+
#exit
|
29
29
|
|
30
30
|
|
31
31
|
|
@@ -277,11 +277,11 @@ shellopts.compile(SPEC)
|
|
277
277
|
#shellopts.tokens.each(&:dump)
|
278
278
|
#exit
|
279
279
|
|
280
|
-
|
280
|
+
shellopts.usage
|
281
281
|
#shellopts.brief
|
282
282
|
#shellopts.help
|
283
283
|
#shellopts.help("cmd")
|
284
|
-
shellopts.help(ARGV.first)
|
284
|
+
#shellopts.help(ARGV.first)
|
285
285
|
|
286
286
|
#p shellopts.tokens
|
287
287
|
|