36 lines
838 B
Ruby
36 lines
838 B
Ruby
require "devops-client/handler/handler"
|
|
require "devops-client/options/network_options"
|
|
require "json"
|
|
require "devops-client/output/network"
|
|
|
|
class Network < Handler
|
|
|
|
output_with Output::Network
|
|
|
|
def initialize(host, def_options={})
|
|
@host, @options = host, def_options
|
|
@options_parser = NetworkOptions.new(ARGV, def_options)
|
|
end
|
|
|
|
def handle
|
|
current_command = ARGV[1].to_sym
|
|
@options, @args = @options_parser.parse_options_for!(current_command)
|
|
case current_command
|
|
when :list
|
|
list_handler(@args[2])
|
|
output
|
|
end
|
|
end
|
|
|
|
def list_handler(provider=nil)
|
|
r = inspect_parameters @options_parser.list_params, provider
|
|
unless r.nil?
|
|
@options_parser.invalid_list_command
|
|
abort(r)
|
|
end
|
|
@list = get("/networks/#{provider}").sort!{|x,y| x["name"] <=> y["name"]}
|
|
end
|
|
|
|
end
|
|
|