lib/configliere/commandline.rb
# Returns a flag in dashed form, suitable for recycling into the commandline
# of an external program.
# Can specify a specific flag name, otherwise the given setting key is used
#
# @example
#   Settings.dashed_flag_for(:flux_capacitance)
#   #=> --flux-capacitance=0.7
#   Settings.dashed_flag_for(:screw_you, :hello_friend)
#   #=> --hello-friend=true
#
Returns a flag in dashed form, suitable for recycling into the commandline
of an external program.
Can specify a specific flag name, otherwise the given setting key is used
Returns a flag in dashed form suitable for recycling into the commandline of an external program . Can specify a specific flag name otherwise the given setting key is used
def dashed_flag_for setting_name, flag_name=nil
      return unless self[setting_name]
      flag_name ||= setting_name
      (self[setting_name] == true ? "--#{flag_name.to_s.gsub(/_/,"-")}" : "--#{flag_name.to_s.gsub(/_/,"-")}=#{self[setting_name]}" )
    end
def dashed_flag_for setting_name , flag_name = nil return unless self [ setting_name ] flag_name ||= setting_name ( self [ setting_name ] == true ? "--#{flag_name.to_s.gsub(/_/,"-")}" : "--#{flag_name.to_s.gsub(/_/,"-")}=#{self[setting_name]}" ) end
Returns a flag in dashed form, suitable for recycling into the commandline
of an external program.
Returns a flag in dashed form suitable for recycling into the commandline of an external program .
setting_name
flag_name
example
Settings.dashed_flag_for(:flux_capacitance) #=> --flux-capacitance=0.7 Settings.dashed_flag_for(:screw_you, :hello_friend) #=> --hello-friend=true
Settings . dashed_flag_for ( : flux_capacitance ) # = > -- flux - capacitance = 0 . 7 Settings . dashed_flag_for ( : screw_you : hello_friend ) # = > -- hello - friend = true