Class: Fvm::CLI::Driver

Inherits:
Object
  • Object
show all
Defined in:
lib/fvm/cli/driver.rb

Instance Method Summary collapse

Instance Method Details

#home(options) ⇒ Object

Prints the active Flex SDK home directory

OPTIONS

-c, --chomp `print` instead of `puts`


138
139
140
141
142
143
144
145
# File 'lib/fvm/cli/driver.rb', line 138

def home( options )
  installations = installer.installations.select( &:active? )
  if installations.any?
    options.chomp? ? print( installations.first.dir ) : puts( installations.first.dir )
  else
    print ''
  end
end

#install(options) ⇒ Object

Installs a version of the Flex SDK and creates symlinks to the included binaries.

If no options are provided, FVM will fetch all available builds and present them to
the user as an interactive menu.

Because we're trying to stay honest, the user will be prompted to agree to the MPL
license no matter what.

OPTIONS

  -v, --version Specify a version of the Flex SDK to install

  -s, --sdk Only present a menu containing builds from the given SDK name


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fvm/cli/driver.rb', line 20

def install( options )

  if options.version?
    
    begin
      builds = Fvm::CLI::Build.version( options.version )
    rescue
      shell.exit 'There was a problem connecting to the FVM API. Please try again.'
    end
    
    shell.exit "No Flex SDK build found with version #{options.version}" if builds.empty?
    build = builds.first
    
  elsif options.sdk?
    
    begin
      builds = Fvm::CLI::Build.sdk( options.sdk )
    rescue
      shell.exit 'There was a problem connecting to the FVM API. Please try again.'
    end
    
    shell.exit "No Flex SDK build found in SDK #{options.sdk}" if builds.empty?
    build = shell.choose builds
    
  else
    
    begin
      builds = Fvm::CLI::Build.all
    rescue
      shell.exit 'There was a problem connecting to the FVM API. Please try again.'
    end
    
    build = shell.choose builds
    
  end
  
  shell.exit "You must agree to the MPL terms before installing the Flex SDK." unless shell.mpl?
    
  installed = installer.install build.zip_url, build.version

  linker.link File.join( installed, 'bin' )

  shell.props "Flex SDK version #{build.version} successfully installed to #{installed}"
  
  shell.warn_restart!
  
end

#list(options) ⇒ Object

List Flex SDK builds installed locally. Will also show which build is currently linked.

OPTIONS

-r, --remote List available remote builds.


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/fvm/cli/driver.rb', line 93

def list( options )
  if options.remote?
    begin
      builds = Build.all
    rescue
      shell.exit 'There was a problem connecting to the FVM API. Please try again.'
    end
    
    shell.list builds
  else
    installations = installer.installations
    
    shell.exit "No Flex SDK versions installed. Run 'fvm install' to install some!" if installations.empty?
    
    shell.list installations
  end
end

#restart(options) ⇒ Object

Prints the location of the fvm-restart script

OPTIONS

-c, --chomp `print` instead of `puts`


153
154
155
# File 'lib/fvm/cli/driver.rb', line 153

def restart( options )
  options.chomp? ? print( restart_script_path ) : puts( restart_script_path )
end

Removes all symlinks created by FVM.



113
114
115
116
# File 'lib/fvm/cli/driver.rb', line 113

def unlink
  linker.unlink!
  shell.props "All Flex SDK symlinks successfully removed."
end

#useObject

Select an installed version of the Flex SDK to link to.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fvm/cli/driver.rb', line 70

def use
  
  installations = installer.installations
  
  shell.exit "No Flex SDK versions installed. Run 'fvm install' to install some!" if installations.empty?
  
  installation = shell.choose installations
  
  linker.link File.join( installation.dir, 'bin' )
  
  shell.props "Now using Flex SDK version #{installation.version}"
  
  shell.warn_restart!
  
end

#which(options) ⇒ Object

Prints the active Flex SDK version number

OPTIONS

-c, --chomp `print` instead of `puts`


124
125
126
127
128
129
130
# File 'lib/fvm/cli/driver.rb', line 124

def which( options )
  if Fvm::System.active_version?
    options.chomp? ? print( Fvm::System.active_version.version ) : puts( Fvm::System.active_version.version )
  else
    print ''
  end
end