Sha256: 3e148e02961a27bf41fe36fa94eccbc32051afda1fa7a7654e0511167c4ac782

Contents?: true

Size: 1.8 KB

Versions: 40

Compression:

Stored size: 1.8 KB

Contents

module Brightbox
  command [:images] do |cmd|

    cmd.desc I18n.t("images.register.desc")
    cmd.command [:register] do |c|

      c.desc I18n.t("options.name.desc")
      c.flag [:n, :name]

      c.desc I18n.t("options.description.desc")
      c.flag [:d, :description]

      c.desc "Image Username"
      c.flag [:u, "username"]

      c.desc "Archtecture of the image (i686 or x86_64)"
      c.flag [:a, "arch"]

      c.desc "Source filename of the image you uploaded to the image library"
      c.flag [:s, "source"]

      c.desc "Set image mode to be either 'virtio' or 'compatibility'"
      c.default_value "virtio"
      c.flag [:m, "mode"]

      c.desc "Set image to be publically visible (true or false)"
      c.default_value "false"
      c.flag [:p, "public"]

      c.action do |global_options, options, _args|

        raise "You must specify the architecture" unless options[:a]
        raise "You must specify the source filename" unless options[:s]
        raise "Mode must be 'virtio' or 'compatibility'" unless options[:m] == "virtio" || options[:m] == "compatibility"
        raise "Public must be true or false" unless options[:p] == "true" || options[:p] == "false"

        if options[:m] == "compatibility"
          compatibility_flag = true
        else
          compatibility_flag = false
        end

        if options[:p] == "true"
          public_flag = true
        else
          public_flag = false
        end

        image_options = {
          :name => options[:n], :arch => options[:a],
          :username => options[:u], :source => options[:s],
          :compatibility_mode => compatibility_flag,
          :description => options[:d], :public => public_flag
        }

        image = Image.register(image_options)

        render_table([image], global_options)

      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
brightbox-cli-3.3.0 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-3.2.0 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-3.1.0 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-3.0.1 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-3.0.0 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.12.0 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.11.2 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.11.1 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.11.0 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.10.0 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.9.3 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.9.2 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.9.1 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.9.0 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.8.2 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.8.1 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.8.0 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.7.1 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.7.0 lib/brightbox-cli/commands/images/register.rb
brightbox-cli-2.6.0 lib/brightbox-cli/commands/images/register.rb