Sha256: 6f9d75d808363d23c30bf6314fb0b8e55d14117f1f968a39c606cf7dccc4ce4d

Contents?: true

Size: 697 Bytes

Versions: 6

Compression:

Stored size: 697 Bytes

Contents

module Brightbox
  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
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
brightbox-cli-0.16.0 lib/brightbox-cli/commands/images-list.rb
brightbox-cli-0.15.0 lib/brightbox-cli/commands/images-list.rb
brightbox-cli-0.14.1 lib/brightbox-cli/commands/images-list.rb
brightbox-cli-0.14.0 lib/brightbox-cli/commands/images-list.rb
brightbox-cli-0.13.1 lib/brightbox-cli/commands/images-list.rb
brightbox-cli-0.13.0 lib/brightbox-cli/commands/images-list.rb