shellopts 2.0.8 → 2.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shellopts/formatter.rb +14 -17
- data/lib/shellopts/parser.rb +0 -8
- data/lib/shellopts/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: a9d576d24bd0aec0dd43a2a3645ede04751d80ae22a4c88e8f66ed53bbe7e405
|
4
|
+
data.tar.gz: 9027ac55689a345099f6515e5280808528603dfafe385219e6cce77d1c166d96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b44a4d95aa0585dd0ec31abccde4942c98ad712d9e3bdf9f0c0b6ead7333ff4c5b555ec5b45786a6f539388b2460c93d12f3755b2e80cbb81fd269c42a9b4955
|
7
|
+
data.tar.gz: 3c948a743d809df7d22bc142dcfa9aa4e943fed144004c4fbf5d1995c314f4aea3f91b032533222eed953e5344a45c55666339797e5ae2b1be262eea17071cd5
|
data/lib/shellopts/formatter.rb
CHANGED
@@ -112,36 +112,33 @@ module ShellOpts
|
|
112
112
|
|
113
113
|
section = {
|
114
114
|
Paragraph => "DESCRIPTION",
|
115
|
-
OptionGroup => "
|
116
|
-
Command => "
|
115
|
+
OptionGroup => "OPTION",
|
116
|
+
Command => "COMMAND"
|
117
117
|
}
|
118
118
|
|
119
|
+
seen_sections = {}
|
119
120
|
newline = false # True if a newline should be printed before child
|
120
121
|
indent {
|
121
122
|
children.each { |child|
|
122
|
-
|
123
|
-
#
|
124
|
-
|
125
|
-
indent(-1).puts Ansi.bold child.name
|
126
|
-
section.delete_if { |_,v| v == child.name }
|
123
|
+
klass = child.is_a?(Section) ? section.key(child.name) : child.class
|
124
|
+
if s = section[klass] # Implicit section
|
125
|
+
section.delete(klass)
|
127
126
|
section.delete(Paragraph)
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
127
|
+
if klass <= OptionGroup
|
128
|
+
s = s + "S" if options.size > 1
|
129
|
+
elsif klass <= Command
|
130
|
+
s = s + "S" if commands.size > 1 || commands.first&.commands&.size != 0
|
131
|
+
end
|
132
|
+
puts
|
133
133
|
indent(-1).puts Ansi.bold s
|
134
|
-
section.delete(child.class)
|
135
|
-
section.delete(Paragraph)
|
136
134
|
newline = false
|
137
|
-
|
138
|
-
#
|
135
|
+
next if child.is_a?(Section)
|
136
|
+
else # Any other node adds a newline
|
139
137
|
puts if newline
|
140
138
|
newline = true
|
141
139
|
end
|
142
140
|
|
143
141
|
if child.is_a?(Command)
|
144
|
-
# prefix = child.parent != self ? nil : child.supercommand&.name
|
145
142
|
prefix = child.supercommand == self ? nil : child.supercommand&.name
|
146
143
|
child.puts_descr(prefix, brief: false, name: :path)
|
147
144
|
newline = true
|
data/lib/shellopts/parser.rb
CHANGED
@@ -163,14 +163,6 @@ module ShellOpts
|
|
163
163
|
@nodes = {}
|
164
164
|
end
|
165
165
|
|
166
|
-
# def add_stdopts
|
167
|
-
# version_token = Token.new(:option, 1, 1, "--version")
|
168
|
-
# version_brief = Token.new(:brief, 1, 1, "Gryf gryf")
|
169
|
-
# group = Grammar::OptionGroup.new(@program, version_token)
|
170
|
-
# option = Grammar::Option.parse(group, version_token)
|
171
|
-
# brief = Grammr::Brief.parse(option, version_brief)
|
172
|
-
# end
|
173
|
-
|
174
166
|
def parse()
|
175
167
|
@program = Grammar::Program.parse(@tokens.shift)
|
176
168
|
oneline = @tokens.first.lineno == @tokens.last.lineno
|
data/lib/shellopts/version.rb
CHANGED