Class: Chid::Commands::Installs::Vim

Inherits:
Chid::Command show all
Defined in:
lib/chid/commands/installs/vim.rb

Constant Summary

Constants inherited from Chid::Command

Chid::Command::COMMANDS

Instance Attribute Summary

Attributes inherited from Chid::Command

#options

Instance Method Summary collapse

Methods inherited from Chid::Command

command, help, #initialize, map_options_with_values, run

Constructor Details

This class inherits a constructor from Chid::Command

Instance Method Details

#do_gvim?Boolean

Returns:

  • (Boolean)


60
61
62
63
64
# File 'lib/chid/commands/installs/vim.rb', line 60

def do_gvim?
  answers = ['Yes','No']
  should_install_gvim = prompt.select('Install gvim too?', answers)
  should_install_gvim == 'Yes'
end

#do_vim?Boolean

Returns:

  • (Boolean)


54
55
56
57
58
# File 'lib/chid/commands/installs/vim.rb', line 54

def do_vim?
  answers = ['Yes','No']
  should_install_vim = prompt.select('Install vim ?', answers)
  should_install_vim == 'Yes'
end

#promptObject



50
51
52
# File 'lib/chid/commands/installs/vim.rb', line 50

def prompt
  @prompt ||= TTY::Prompt.new
end

#runObject



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
# File 'lib/chid/commands/installs/vim.rb', line 21

def run
  puts "\nInstalling vim..."

  is_vim = do_vim?
  is_gvim = do_gvim?

  ::ChidConfig.on_linux do
    system('sudo apt update')

    if is_vim
      system('sudo add-apt-repository ppa:jonathonf/vim')
      system('sudo apt update')
      system('sudo apt install vim')
    end

    system('sudo apt-get install vim-gnome') if is_gvim
  end

  ::ChidConfig.on_osx do
    system('brew update')
    system('brew install vim')
  end

  puts "\nVim installed successfully" if is_vim
  puts "\nGvim installed successfully" if is_gvim

  puts "\nNothing installed =(" unless is_vim || is_gvim
end