Class: ShellOpts::Grammar::Program

Inherits:
Command show all
Defined in:
lib/shellopts/parser.rb,
lib/shellopts/grammar.rb,
lib/shellopts/formatter.rb

Constant Summary

Constants inherited from Command

Command::COMMANDS_ABBR, Command::DESCRS_ABBR, Command::OPTIONS_ABBR

Constants inherited from Node

Node::ALLOWED_PARENTS

Instance Attribute Summary collapse

Attributes inherited from Command

#brief, #commands, #description, #descrs, #option_groups, #options, #specs

Attributes inherited from IdrNode

#attr, #command, #ident, #name, #path

Attributes inherited from Node

#children, #parent, #token

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

#[], #collect_options, command, #compute_command_hashes, #compute_option_hashes, #dump_idr, #dump_structure, #initialize, #key?, #keys, #names, #parse, #puts_brief, #puts_descr, #puts_help, #puts_usage, #render, #render_structure, #reorder_options

Methods inherited from IdrNode

#dump_doc, #parse, #set_name, #uid

Methods inherited from Node

#analyzer_error, #ancestors, #dump_ast, #dump_attrs, #dump_idr, #initialize, #inspect, #parents, #parse, #parser_error, #puts_help, #puts_usage, #remove_arg_descr_nodes, #remove_arg_spec_nodes, #remove_brief_nodes, #traverse

Constructor Details

This class inherits a constructor from ShellOpts::Grammar::Command

Instance Attribute Details

#infoObject (readonly)

Lifted from .gemspec. TODO



292
293
294
# File 'lib/shellopts/grammar.rb', line 292

def info
  @info
end

Class Method Details

.parse(token) ⇒ Object



123
124
125
# File 'lib/shellopts/parser.rb', line 123

def self.parse(token)
  super(nil, token)
end

Instance Method Details

#inject_option(decl, brief, paragraph = nil, &block) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/shellopts/parser.rb', line 127

def inject_option(decl, brief, paragraph = nil, &block)
  option_token = Token.new(:option, 1, 1, decl)
  brief_token = Token.new(:brief, 1, 1, brief)
  group = OptionGroup.new(self, option_token)
  option = Option.parse(group, option_token)
  brief = Brief.parse(group, brief_token)
  paragraph ||= yield(option) if block_given?
  if paragraph
    paragraph_token = Token.new(:text, 1, 1, paragraph)
    paragraph = Paragraph.parse(group, paragraph_token)
  end
  option
end