Sha256: 4a931f2c8f2455bd5dc92fe2c6a7b75a51b7add35191d59ea17c1972524d281b

Contents?: true

Size: 640 Bytes

Versions: 7

Compression:

Stored size: 640 Bytes

Contents

desc 'List available images'
arg_name '[image-id...]'
command [:list] do |c|
  c.action do |global_options, options, args|

    if args.empty?
      images = Image.find(:all)
    else
      images = Image.find_or_call(args) do |id|
        warn "Couldn't find image #{id}"
      end
    end

    snapshots = images.select { |i| i.source_type == 'snapshot' }

    images = images - snapshots

    images.sort! do |a,b|
      [a.official ? 0 : 1, a.name, a.arch] <=> [b.official ? 0 : 1, b.name, b.arch]
    end

    snapshots.sort! { |a, b| a.created_at <=> b.created_at }
    
    render_table(images + snapshots, global_options)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bbcloud-0.11.2 lib/bbcloud/commands/images-list.rb
bbcloud-0.11.1 lib/bbcloud/commands/images-list.rb
bbcloud-0.11.0 lib/bbcloud/commands/images-list.rb
bbcloud-0.10.1 lib/bbcloud/commands/images-list.rb
bbcloud-0.9.2 lib/bbcloud/commands/images-list.rb
bbcloud-0.9.1 lib/bbcloud/commands/images-list.rb
bbcloud-0.9 lib/bbcloud/commands/images-list.rb