Class: Gem::OptionParser::AC
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::Gem::OptionParser
|
|
Instance Chain:
self,
::Gem::OptionParser
|
|
Inherits: |
Gem::OptionParser
|
Defined in: | lib/rubygems/vendor/optparse/lib/optparse/ac.rb |
Overview
autoconf-like options.
Constant Summary
-
ARG_CONV =
private
Internal use only
# File 'lib/rubygems/vendor/optparse/lib/optparse/ac.rb', line 20proc {|val| val.nil? ? true : val}
::Gem::OptionParser
- Inherited
ArgumentStyle, COMPSYS_HEADER, DecimalInteger, DecimalNumeric, DefaultList, NoArgument, OctalInteger, Officious, OptionalArgument, RequiredArgument, SPLAT_PROC, Version
Class Method Summary
::Gem::OptionParser
- Inherited
.accept | See #accept. |
.getopts | See #getopts. |
.inc | Returns an incremented value of |
.new | Initializes the instance and yields itself if called with a block. |
.reject | See #reject. |
.show_version | Shows version string in packages if Version is defined. |
.terminate | See #terminate. |
.top | Returns the global top option list. |
.with | Initializes a new instance and evaluates the optional block in context of the instance. |
.each_const, .search_const |
Instance Attribute Summary
::Gem::OptionParser
- Inherited
#banner | Heading banner preceding summary. |
#banner= | Heading banner preceding summary. |
#default_argv | Strings to be parsed in default. |
#program_name | Program name to be emitted in error message and default banner, defaults to $0. |
#program_name= | Program name to be emitted in error message and default banner, defaults to $0. |
#raise_unknown | Whether to raise at unknown option. |
#release | Release code. |
#release= | Release code. |
#require_exact | Whether to require that options match exactly (disallows providing abbreviated long option as short option). |
#summary_indent | Indentation for summary. |
#summary_width | Width for option list portion of summary. |
#version | |
#version= |
Instance Method Summary
-
#ac_arg_disable(name, help_string, &block)
Define
--enable
/--disable
style option. -
#ac_arg_enable(name, help_string, &block)
Define
--enable
/--disable
style option. -
#ac_arg_with(name, help_string, &block)
Define
--with
/--without
style option. - #_ac_arg_enable(prefix, name, help_string, block) private Internal use only
- #_check_ac_args(name, block) private Internal use only
::Gem::OptionParser
- Inherited
#abort | Shows message with the program name then aborts. |
#accept | Directs to accept specified class |
#additional_message | Returns additional info. |
#base | Subject of #on_tail. |
#candidate | Return candidates for |
#def_head_option | Alias for #define_head. |
#def_option | Alias for #define. |
#def_tail_option | Alias for #define_tail. |
#define | |
#define_by_keywords | |
#define_head | |
#define_tail | |
#environment | Parses environment variable |
#getopts | Wrapper method for getopts.rb. |
#help | Returns option summary string. |
#inc | See self.inc. |
#load | Loads options from file names as |
#make_switch | |
#new | Pushes a new |
#on | |
#on_head | |
#on_tail | |
#order | Parses command line arguments |
#order! | Same as #order, but removes switches destructively. |
#parse | Parses command line arguments |
#parse! | Same as #parse, but removes switches destructively. |
#permute | Parses command line arguments |
#permute! | Same as #permute, but removes switches destructively. |
#reject | Directs to reject specified class argument. |
#remove | Removes the last |
#separator | Add separator in summary. |
#summarize | Puts option summary into |
#terminate | Terminates option parsing. |
#to_a | Returns option summary list. |
#to_s | Alias for #help. |
#top | |
#ver | Returns version string from program_name, version and release. |
#warn | Shows warning message with the program name. |
#add_officious, #compsys, #help_exit, #inspect, #pretty_print, | |
#callback! | Calls callback with val. |
#complete | Completes shortened long style option switch and returns pair of canonical switch and switch descriptor |
#notwice | Checks if an argument is given twice, in which case an ArgumentError is raised. |
#parse_in_order, | |
#search | Searches |
#visit | Traverses @stack, sending each element method |
Constructor Details
This class inherits a constructor from Gem::OptionParser
Instance Method Details
#_ac_arg_enable(prefix, name, help_string, block) (private)
# File 'lib/rubygems/vendor/optparse/lib/optparse/ac.rb', line 23
def _ac_arg_enable(prefix, name, help_string, block) _check_ac_args(name, block) sdesc = [] ldesc = ["--#{prefix}-#{name}"] desc = [help_string] q = name.downcase ac_block = proc {|val| block.call(ARG_CONV.call(val))} enable = Switch::PlacedArgument.new(nil, ARG_CONV, sdesc, ldesc, nil, desc, ac_block) disable = Switch::NoArgument.new(nil, proc {false}, sdesc, ldesc, nil, desc, ac_block) top.append(enable, [], ["enable-" + q], disable, ['disable-' + q]) enable end
#_check_ac_args(name, block) (private)
# File 'lib/rubygems/vendor/optparse/lib/optparse/ac.rb', line 11
def _check_ac_args(name, block) unless /\A\w[-\w]*\z/ =~ name raise ArgumentError, name end unless block raise ArgumentError, "no block given", ParseError.filter_backtrace(caller) end end
#ac_arg_disable(name, help_string, &block)
Define --enable
/ --disable
style option
Appears as --disable-name
in help message.
# File 'lib/rubygems/vendor/optparse/lib/optparse/ac.rb', line 51
def ac_arg_disable(name, help_string, &block) _ac_arg_enable("disable", name, help_string, block) end
#ac_arg_enable(name, help_string, &block)
Define --enable
/ --disable
style option
Appears as --enable-name
in help message.
# File 'lib/rubygems/vendor/optparse/lib/optparse/ac.rb', line 44
def ac_arg_enable(name, help_string, &block) _ac_arg_enable("enable", name, help_string, block) end
#ac_arg_with(name, help_string, &block)
Define --with
/ --without
style option
Appears as --with-name
in help message.
# File 'lib/rubygems/vendor/optparse/lib/optparse/ac.rb', line 58
def ac_arg_with(name, help_string, &block) _check_ac_args(name, block) sdesc = [] ldesc = ["--with-#{name}"] desc = [help_string] q = name.downcase with = Switch::PlacedArgument.new(*search(:atype, String), sdesc, ldesc, nil, desc, block) without = Switch::NoArgument.new(nil, proc {}, sdesc, ldesc, nil, desc, block) top.append(with, [], ["with-" + q], without, ['without-' + q]) with end