Class: XcodeInstall::Command::Select
- Inherits:
-
XcodeInstall::Command
- Object
- CLAide::Command
- XcodeInstall::Command
- XcodeInstall::Command::Select
- Defined in:
- lib/xcode/install/select.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Select
constructor
A new instance of Select.
- #run ⇒ Object
- #validate! ⇒ Object
Methods inherited from XcodeInstall::Command
Constructor Details
#initialize(argv) ⇒ Select
Returns a new instance of Select.
15 16 17 18 19 20 |
# File 'lib/xcode/install/select.rb', line 15 def initialize(argv) @installer = Installer.new @version = argv.shift_argument @should_symlink = argv.flag?('symlink', false) super end |
Class Method Details
.options ⇒ Object
11 12 13 |
# File 'lib/xcode/install/select.rb', line 11 def self. [['--symlink', 'Update symlink in /Applications with selected Xcode']].concat(super) end |
Instance Method Details
#run ⇒ Object
29 30 31 32 33 |
# File 'lib/xcode/install/select.rb', line 29 def run xcode = @installer.installed_versions.detect { |v| v.version == @version } `sudo xcode-select --switch "#{xcode.path}"` @installer.symlink xcode.version if @should_symlink end |
#validate! ⇒ Object
22 23 24 25 26 27 |
# File 'lib/xcode/install/select.rb', line 22 def validate! super fail Informative, 'Please specify a version to select.' if @version.nil? fail Informative, "Version #{@version} not installed." unless @installer.installed?(@version) end |