lib/slop/option.rb in slop-4.4.3 vs lib/slop/option.rb in slop-4.5.0

- old
+ new

@@ -1,10 +1,11 @@ module Slop class Option DEFAULT_CONFIG = { help: true, tail: false, + underscore_flags: true, } # An Array of flags this option matches. attr_reader :flags @@ -105,10 +106,17 @@ flags.join(", ") end # Returns the last key as a symbol. Used in Options.to_hash. def key - (config[:key] || flags.last.sub(/\A--?/, '')).tr("-", "_").to_sym + key = config[:key] || flags.last.sub(/\A--?/, '') + key = key.tr '-', '_' if underscore_flags? + key.to_sym + end + + # Returns true if this option should be displayed with dashes transformed into underscores. + def underscore_flags? + config[:underscore_flags] end # Returns true if this option should be displayed in help text. def help? config[:help]