35 lines
793 B
Ruby
35 lines
793 B
Ruby
require "devops-client/handler/handler"
|
|
require "devops-client/options/flavor_options"
|
|
require "json"
|
|
require "devops-client/output/flavors"
|
|
|
|
class Flavor < Handler
|
|
|
|
output_with Output::Flavors
|
|
|
|
def initialize(host, def_options={})
|
|
@host, @options = host, def_options
|
|
@options_parser = FlavorOptions.new(ARGV, def_options)
|
|
end
|
|
|
|
def handle
|
|
case ARGV[1]
|
|
when "list"
|
|
@options, @args = @options_parser.parse_options_for!(:list)
|
|
list_handler
|
|
output
|
|
end
|
|
end
|
|
|
|
def list_handler(provider=nil)
|
|
provider ||= @args[2]
|
|
r = inspect_parameters @options_parser.list_params, provider
|
|
unless r.nil?
|
|
@options_parser.invalid_list_command
|
|
abort(r)
|
|
end
|
|
@list = get("/flavors/#{provider}").sort!{|x,y| x["id"] <=> y["id"]}
|
|
end
|
|
|
|
end
|