@@ -1054,7 +1054,7 @@ def compsys(to, name = File.basename($0)) # :nodoc:
1054
1054
# Shows option summary.
1055
1055
#
1056
1056
Officious [ 'help' ] = proc do |parser |
1057
- Switch ::NoArgument . new ( nil , nil , [ "-h" ] , [ "--help" ] ) do |arg |
1057
+ Switch ::NoArgument . new do |arg |
1058
1058
puts parser . help
1059
1059
exit
1060
1060
end
@@ -1479,7 +1479,7 @@ def make_switch(opts, block = nil)
1479
1479
default_style = default_style . guess ( arg = a )
1480
1480
default_pattern , conv = search ( :atype , o ) unless default_pattern
1481
1481
end
1482
- ldesc << "--#{ q } " << "-- no-#{ q } "
1482
+ ldesc << "--[ no-] #{ q } "
1483
1483
( o = q . downcase ) . tr! ( '_' , '-' )
1484
1484
long << o
1485
1485
not_pattern , not_conv = search ( :atype , FalseClass ) unless not_style
@@ -1654,14 +1654,19 @@ def parse_in_order(argv = default_argv, setter = nil, &nonopt) # :nodoc:
1654
1654
opt , rest = $1, $2
1655
1655
opt . tr! ( '_' , '-' )
1656
1656
begin
1657
- sw , = complete ( :long , opt , true )
1658
- if require_exact && ! sw . long . include? ( "-- #{ opt } " )
1659
- throw :terminate , arg unless raise_unknown
1660
- raise InvalidOption , arg
1657
+ if require_exact
1658
+ sw , = search ( :long , opt )
1659
+ else
1660
+ sw , = complete ( :long , opt , true )
1661
1661
end
1662
1662
rescue ParseError
1663
1663
throw :terminate , arg unless raise_unknown
1664
1664
raise $!. set_option ( arg , true )
1665
+ else
1666
+ unless sw
1667
+ throw :terminate , arg unless raise_unknown
1668
+ raise InvalidOption , arg
1669
+ end
1665
1670
end
1666
1671
begin
1667
1672
opt , cb , *val = sw . parse ( rest , argv ) { |*exc | raise ( *exc ) }
0 commit comments