Class: Vvm::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions, Validator
Defined in:
lib/vvm/cli.rb

Constant Summary

Constants included from Validator

Validator::METHOD_MAP

Instance Method Summary collapse

Methods included from Validator

hg?, installed_version?, new_version?, validate_before_invoke, version?

Instance Method Details

#install(version, *conf) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/vvm/cli.rb', line 10

def install(version, *conf)
  i = Installer.new(Version.format(version), conf)
  i.checkout
  i.configure
  i.make_install
  Installer.cp_etc
  invoke :use, [version], {} if options[:use]
  i.message
end

#listObject



54
55
56
57
# File 'lib/vvm/cli.rb', line 54

def list
  Installer.pull
  puts Version.list.join("\n")
end

#rebuild(version, *conf) ⇒ Object



41
42
43
44
45
46
# File 'lib/vvm/cli.rb', line 41

def rebuild(version, *conf)
  r = Installer.new(Version.format(version), conf)
  r.make_clean
  r.configure
  r.make_install
end

#reinstall(version, *conf) ⇒ Object



35
36
37
38
# File 'lib/vvm/cli.rb', line 35

def reinstall(version, *conf)
  invoke :uninstall, [version]
  invoke :install, [version, *conf]
end

#uninstall(version) ⇒ Object



65
66
67
# File 'lib/vvm/cli.rb', line 65

def uninstall(version)
  Uninstaller.new(Version.format(version)).uninstall
end

#updateObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vvm/cli.rb', line 21

def update
  Installer.pull
  if (current = Version.current) == 'system'
    run 'vvm install --use latest'
    run 'vvm use system' unless $?.success?
  else
    run 'vvm use system'
    run 'vvm install --use latest'
    action = $?.success? ? 'uninstall' : 'use'
    run "vvm #{action} #{current}"
  end
end

#use(version) ⇒ Object



49
50
51
# File 'lib/vvm/cli.rb', line 49

def use(version)
  Switcher.new(Version.format(version)).use
end

#versionsObject



60
61
62
# File 'lib/vvm/cli.rb', line 60

def versions
  puts Version.versions.join("\n")
end