34 lines
		
	
	
		
			778 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			778 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| require "devops-client/handler/handler"
 | |
| require "devops-client/options/provider_options"
 | |
| require "devops-client/output/provider"
 | |
| 
 | |
| class Provider < Handler
 | |
| 
 | |
|   output_with Output::Provider
 | |
| 
 | |
|   def initialize(host, def_options={})
 | |
|     @host, @options = host, def_options
 | |
|     @options_parser = ProviderOptions.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
 | |
|       output
 | |
|     end
 | |
|   end
 | |
| 
 | |
|   def list_handler
 | |
|     r = inspect_parameters @options_parser.list_params
 | |
|     unless r.nil?
 | |
|       @options_parser.invalid_list_command
 | |
|       abort(r)
 | |
|     end
 | |
|     @list = get("/providers").sort!{|x,y| x["id"] <=> y["id"]}
 | |
|   end
 | |
| 
 | |
| end
 | 
