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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6c52f313fee54283e1d5e704dd8b75a96239db6cff70584eefe747cf56270c1
4
- data.tar.gz: 67b50b7b3a993bf77533246c9634ce7850d765891381244fedf2b1ecf3f6bc76
3
+ metadata.gz: a9d576d24bd0aec0dd43a2a3645ede04751d80ae22a4c88e8f66ed53bbe7e405
4
+ data.tar.gz: 9027ac55689a345099f6515e5280808528603dfafe385219e6cce77d1c166d96
5
5
  SHA512:
6
- metadata.gz: 3cf5cd91d92bce24b1d04a3a526d6f43f8fe761f760319bf60191e2e638c3301fdbf9c63aa9f465aa8755cd18aa56293f0ae68e01870d6a877928bc1c0eebf5c
7
- data.tar.gz: 0e1fa649cff6a072d676a33dab6a3cbb038cb6799b59088f7ebff1144e6983843fe16658c80fa75308f057caf24e5b232aea15c92f80290d0969d868e653159e
6
+ metadata.gz: b44a4d95aa0585dd0ec31abccde4942c98ad712d9e3bdf9f0c0b6ead7333ff4c5b555ec5b45786a6f539388b2460c93d12f3755b2e80cbb81fd269c42a9b4955
7
+ data.tar.gz: 3c948a743d809df7d22bc142dcfa9aa4e943fed144004c4fbf5d1995c314f4aea3f91b032533222eed953e5344a45c55666339797e5ae2b1be262eea17071cd5
@@ -112,36 +112,33 @@ module ShellOpts
112
112
 
113
113
  section = {
114
114
  Paragraph => "DESCRIPTION",
115
- OptionGroup => "OPTIONS",
116
- Command => "COMMANDS"
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
- if child.is_a?(Section) # Explicit section
123
- # p :A
124
- puts
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
- newline = false
129
- next
130
- elsif s = section[child.class] # Implicit section
131
- # p :B
132
- puts
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
- else # Any other node add a newline
138
- # p :C
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ShellOpts
2
- VERSION = "2.0.8"
2
+ VERSION = "2.0.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shellopts
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen