Sha256: ee9dbd61e0c8b1bf98b784d23c3088d6c016daae4436e3807d7992a9eb31e40d

Contents?: true

Size: 785 Bytes

Versions: 2

Compression:

Stored size: 785 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(options[:config])
    
    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

2 entries across 2 versions & 1 rubygems

Version Path
cloudstack-cli-0.0.3 lib/cloudstack-cli/commands/template.rb
cloudstack-cli-0.0.2 lib/cloudstack-cli/commands/template.rb