# File lib/hammer_cli/apipie/options.rb, line 40 def apipie_options(options={}) setup_identifier_options if resource_defined? filter = options[:without] || [] filter = Array(filter) filter += declared_identifiers.keys options_for_params(resource.action(action).params, filter) end end
# File lib/hammer_cli/apipie/options.rb, line 64 def create_option(param) option( option_switches(param), option_type(param), option_desc(param), option_opts(param) ) end
# File lib/hammer_cli/apipie/options.rb, line 81 def option_desc(param) param.description || " " end
# File lib/hammer_cli/apipie/options.rb, line 85 def option_opts(param) opts = {} opts[:required] = true if param.required? # FIXME: There is a bug in apipie, it does not produce correct expected type for Arrays # When it's fixed, we should test param["expected_type"] == "array" opts[:format] = HammerCLI::Options::Normalizers::List.new if param.validator.include? "Array" return opts end
# File lib/hammer_cli/apipie/options.rb, line 73 def option_switches(param) '--' + param.name.gsub('_', '-') end
# File lib/hammer_cli/apipie/options.rb, line 77 def option_type(param) param.name.upcase.gsub('-', '_') end
# File lib/hammer_cli/apipie/options.rb, line 53 def options_for_params(params, filter) params.each do |p| next if filter.include?(p.name) || filter.include?(p.name.to_sym) if p.expected_type == :hash options_for_params(p.params, filter) else create_option p end end end
Generated with the Darkfish Rdoc Generator 2.