Sha256: 1ba5aa1cef4aa3c0a97e5847f5f5d9ee02594aab0923d76106f57ab42c7998bc

Contents?: true

Size: 767 Bytes

Versions: 1

Compression:

Stored size: 767 Bytes

Contents

class Template < Thor

  desc 'list', 'list templates by type [featured|self|self-executable|executable|community]' 
  option :project
  def list(type='featured')
    cs_cli = CloudstackCli::Helper.new
    
    if options[:project]
      project = cs_cli.projects.select { |p| p['name'] == options[:project] }.first
      exit_now! "Project '#{options[:project]}' not found" unless project
    end
    
    exit_now! "unsupported template type '#{type}'" unless
      %w(featured self self-executable executable community).include? type
    templates = cs_cli.templates(type, project ? project['id'] : nil)
    if templates.size < 1
      puts "No templates found"
    else
      templates.each do |template|
        puts template['name']
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cloudstack-cli-0.0.1 lib/cloudstack-cli/commands/template.rb