shellopts 2.0.19 → 2.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TODO +16 -0
- data/lib/shellopts/program.rb +17 -9
- data/lib/shellopts/version.rb +1 -1
- data/lib/shellopts.rb +0 -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: 83e0ce72f27c72eec2087bee9296378fc0d84fc1124f830af27f21340cefffcc
|
4
|
+
data.tar.gz: 6c3b2363c1ca392b0950c792c48e353181f352ca22bfe16e7c42490248511b29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcc6e2271a451f494e007c78e9054c49bbb6f65f0f0fcf5be07158488157782c8216fc0f6fce7e4c25dda6bf0e39ac8ae2096f733cb4af7c4b1360b28a978129
|
7
|
+
data.tar.gz: e1d60f792447e5884f2ad939fbf408d5c053ef413328e2e2a42a082e34e9672537d8d64916fbc136f11797ac2c87894c148939d4feac9cc43489d3c66faa538d
|
data/TODO
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
|
2
|
+
o Make opts[] point at the main object
|
3
|
+
opts[].subcommand is the direct subcommand of main
|
4
|
+
o Make opts be the aggrated set of options in a subcommand
|
5
|
+
opts.subcommand is the concatenated path of subcommands
|
6
|
+
o Make opts[:some_command] be the set of options for that subcommand (already done)
|
7
|
+
o Sub-command options can overshadow options of outer commands but it is an
|
8
|
+
error to access them using opts. Use opts[] or opts[:some_command] instead
|
9
|
+
|
10
|
+
o Add a default argument to extract:
|
11
|
+
def extract(range, *defaults)
|
12
|
+
end
|
13
|
+
|
14
|
+
extract(3..4, 'dbo')
|
15
|
+
|
16
|
+
o More strict parsing of option and command lines
|
1
17
|
o --option can't be escaped if on the start of a block line?
|
2
18
|
o Use require_relative
|
3
19
|
o In the following list is a command with a mandatory sub-command
|
data/lib/shellopts/program.rb
CHANGED
@@ -84,19 +84,27 @@ module ShellOpts
|
|
84
84
|
}
|
85
85
|
end
|
86
86
|
|
87
|
-
# Returns a hash
|
88
|
-
#
|
87
|
+
# Returns a hash from option ident to value
|
88
|
+
#
|
89
|
+
# The value depends on the option type: If it is not repeatable, the value
|
90
|
+
# is the argument or nil if not present (or allowed). If the option is
|
91
|
+
# repeatable and has an argument, the value is an array of the arguments,
|
92
|
+
# if it doesn't have an argument, the value is the number of occurrences
|
93
|
+
#
|
89
94
|
def to_h(*keys)
|
90
95
|
keys = ::Kernel::Array(keys).flatten
|
91
|
-
|
92
|
-
self.to_h(@__grammar__.options.map(&:ident))
|
93
|
-
else
|
94
|
-
keys.map { |key|
|
95
|
-
self.__send__("#{key}?".to_sym) ? [key, self.__send__(key)] : nil
|
96
|
-
}.compact.to_h
|
97
|
-
end
|
96
|
+
__option_values__.select { |key,_| keys.empty? || keys.include?(key) }
|
98
97
|
end
|
99
98
|
|
99
|
+
# Like #to_h but present options without arguments have a true value
|
100
|
+
#
|
101
|
+
def to_h?(*keys)
|
102
|
+
keys = ::Kernel::Array(keys).flatten
|
103
|
+
keys = keys.empty? ? __option_values__.keys : keys
|
104
|
+
keys.filter_map { |key| __option_values__.key?(key) && [key, self.__send__(key)] }.to_h
|
105
|
+
end
|
106
|
+
|
107
|
+
|
100
108
|
# Subcommand identifier or nil if not present. #subcommand is often used in
|
101
109
|
# case statement to branch out to code that handles the given subcommand:
|
102
110
|
#
|
data/lib/shellopts/version.rb
CHANGED
data/lib/shellopts.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shellopts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: forward_to
|