lib/cmds/util/defaults.rb in cmds-0.2.10 vs lib/cmds/util/defaults.rb in cmds-0.2.11
- old
+ new
@@ -1,7 +1,10 @@
+# encoding: UTF-8
# frozen_string_literal: true
+require 'active_support/core_ext/object/deep_dup'
+
class Cmds
# hash of common default values used in method options.
#
# don't use them directly -- use {Cmds.defaults}.
#
@@ -30,10 +33,15 @@
assert: false,
# Don't change directories
chdir: nil,
+ # Commands often use dash-separated option names, but it's a lot more
+ # convenient in Ruby to use underscored when using {Symbol}. This option
+ # will convert the underscores to dashes.
+ dash_opt_names: false,
+
# No additional environment
env: {},
# Stick ENV var defs inline at beginning of command
env_mode: :inline,
@@ -95,10 +103,10 @@
# @return [Hash<Symbol, Object>]
# defaults to use in the method call.
#
def self.defaults opts, keys = '*', extras = {}
if keys == '*'
- DEFAULTS.dup
+ DEFAULTS.deep_dup
else
keys.
map {|key|
[key, DEFAULTS.fetch(key)]
}.