module ForemanMaintain::Cli::TransformClampOptions::ParamsToOptions
Public Instance Methods
option_switches(param)
click to toggle source
# File lib/foreman_maintain/cli/transform_clamp_options.rb, line 57 def option_switches(param) ['--' + dashize(param.name.to_s)] end
option_type(param)
click to toggle source
# File lib/foreman_maintain/cli/transform_clamp_options.rb, line 61 def option_type(param) param.flag? ? :flag : param.name.to_s.upcase end
param_to_option(param, custom = {})
click to toggle source
# File lib/foreman_maintain/cli/transform_clamp_options.rb, line 45 def param_to_option(param, custom = {}) switches = custom.fetch(:switches, option_switches(param)) opt_type = custom.fetch(:type, option_type(param)) description = custom.fetch(:description, param.description) options = custom.fetch(:options, {}) # clamp doesnt allow required flags options[:required] ||= param.required? unless param.flag? options[:multivalued] ||= param.array? option(switches, opt_type, description, options) end
params_to_options(params)
click to toggle source
# File lib/foreman_maintain/cli/transform_clamp_options.rb, line 39 def params_to_options(params) params.each_value do |param| param_to_option(param) end end