Sha256: 14d47e7dceb78a647097a31c66d000bacdac9802a5c257e7c7e3ff8d29d93909

Contents?: true

Size: 1.53 KB

Versions: 3

Compression:

Stored size: 1.53 KB

Contents

require 'uri'

module XcodeInstall
  class Command
    class Install < Command
      self.command = 'install'
      self.summary = 'Install a specific version of Xcode.'

      self.arguments = [
        CLAide::Argument.new('VERSION', :true)
      ]

      def self.options
        [['--url', 'Custom Xcode DMG file path or HTTP URL.'],
         ['--no-switch', 'Don’t switch to this version after installation'],
         ['--no-install', 'Only download DMG, but do not install it.'],
         ['--no-progress', 'Don’t show download progress.'],
         ['--no-clean', 'Don’t delete DMG after installation.']].concat(super)
      end

      def initialize(argv)
        @installer = Installer.new
        @version = argv.shift_argument
        @url = argv.option('url')
        @should_clean = argv.flag?('clean', true)
        @should_install = argv.flag?('install', true)
        @should_switch = argv.flag?('switch', true)
        @progress = argv.flag?('progress', true)
        super
      end

      def validate!
        super

        return if @version.nil?
        fail Informative, "Version #{@version} already installed." if @installer.installed?(@version)
        fail Informative, "Version #{@version} doesn't exist." unless @installer.exist?(@version)

        if @url
          fail Informative, "Invalid URL: `#{@url}`" unless @url =~ /\A#{URI::regexp}\z/
        end
      end

      def run
        @installer.install_version(@version, @should_switch, @should_clean, @should_install,
          @progress, @url)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xcode-install-1.1.0 lib/xcode/install/install.rb
xcode-install-1.0.1 lib/xcode/install/install.rb
xcode-install-1.0.0 lib/xcode/install/install.rb