summaryrefslogtreecommitdiff
path: root/lib/slop/option.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/slop/option.rb')
-rw-r--r--lib/slop/option.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/slop/option.rb b/lib/slop/option.rb
index 3e414f9..b8533ae 100644
--- a/lib/slop/option.rb
+++ b/lib/slop/option.rb
@@ -3,6 +3,7 @@ module Slop
DEFAULT_CONFIG = {
help: true,
tail: false,
+ underscore_flags: true,
}
# An Array of flags this option matches.
@@ -107,7 +108,14 @@ module Slop
# 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.