# File lib/rhc/commands/cartridge.rb, line 224
    def storage(cartridge)
      cartridges = Array(cartridge)
      rest_app = rest_client(:min_api => 1.3).find_application(options.namespace, options.app, :include => :cartridges)

      # Pull the desired action
      #
      actions = options.__hash__.keys & [:show, :add, :remove, :set]

      # Ensure that only zero or one action was selected
      raise RHC::AdditionalStorageArgumentsException if actions.length > 1

      operation = actions.first || :show
      amount = options.__hash__[operation]

      # Perform a storage change action if requested
      if operation == :show
        results do
          if cartridges.length == 0
            display_cart_storage_list rest_app.cartridges
          else
            check_cartridges(cartridge, :from => rest_app.cartridges).each do |cart|
              display_cart_storage_info cart, cart.display_name
            end
          end
        end
      else
        raise RHC::MultipleCartridgesException,
          'Exactly one cartridge must be specified for this operation' if cartridges.length != 1

        rest_cartridge = check_cartridges(cartridge, :from => rest_app.cartridges).first
        amount = amount.match(/^(\d+)(GB)?$/i)
        raise RHC::AdditionalStorageValueException if amount.nil?

        # If the amount is specified, find the regex match and convert to a number
        amount = amount[1].to_i
        total_amount = rest_cartridge.additional_gear_storage

        if operation == :add
          total_amount += amount
        elsif operation == :remove
          if amount > total_amount && !options.force
            raise RHC::AdditionalStorageRemoveException
          else
            total_amount = [total_amount - amount, 0].max
          end
        else
          total_amount = amount
        end

        cart = rest_cartridge.set_storage(:additional_gear_storage => total_amount)
        results do
          say "Success: additional storage space set to #{total_amount}GB\n"
          display_cart_storage_info cart
        end
      end

      0
    end