Sha256: 279452c9ceb35a15d726f54881af860b55a66383a30160ce1a92ffd156ff1738

Contents?: true

Size: 984 Bytes

Versions: 4

Compression:

Stored size: 984 Bytes

Contents

module Brightbox
  command [:groups] do |cmd|

    cmd.desc "Update a server group"
    cmd.arg_name "grp-id"
    cmd.command [:update] do |c|

      c.desc "Friendly name of server group"
      c.flag [:n, :name]

      c.desc "Server group description"
      c.flag [:d, :description]

      c.action do |global_options, options, args|
        grp_id = args.shift
        raise "You must specify the server group to update as the first argument" unless grp_id =~ /^grp-/

          params = NilableHash.new

        # unless args.empty?
        #   params[:servers] = args.collect { |a| { :server => a } }
        # end

        if options[:n]
          params[:name] = options[:n]
        end

        if options[:d]
          params[:description] = options[:d]
        end

        params.nilify_blanks

        sg = ServerGroup.find grp_id
        info "Updating server group #{sg}"
        sg = sg.update(params)
        render_table([sg], global_options)
    end
  end
end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
brightbox-cli-1.1.0 lib/brightbox-cli/commands/groups-update.rb
brightbox-cli-1.0.0 lib/brightbox-cli/commands/groups-update.rb
brightbox-cli-1.0.0.rc2 lib/brightbox-cli/commands/groups-update.rb
brightbox-cli-1.0.0.rc1 lib/brightbox-cli/commands/groups-update.rb