Class: VpsCli::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/vps_cli/cli.rb

Overview

The CLI component of this library Integrates Thor

Instance Method Summary collapse

Instance Method Details

#copyObject



56
57
58
59
# File 'lib/vps_cli/cli.rb', line 56

def copy
  VpsCli.load_configuration(options[:config])
  Copy.all
end

#fresh_installObject



21
22
23
24
25
26
27
28
29
# File 'lib/vps_cli/cli.rb', line 21

def fresh_install
  VpsCli.load_configuration(options[:config])
  Copy.all
  Install.all_install

  Access.provide_credentials

  VpsCli.print_errors
end

#git_pullObject



91
92
93
# File 'lib/vps_cli/cli.rb', line 91

def git_pull
  swap_dir { Rake.sh('git pull') }
end

#git_push(message = nil) ⇒ Object



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

def git_push(message = nil)
  message ||= 'auto push files'

  swap_dir do
    begin
      Rake.sh('git add -A')
      Rake.sh("git commit -m \"#{message}\"")
      Rake.sh('git push')
    rescue


    end
  end
end

#git_statusObject



112
113
114
# File 'lib/vps_cli/cli.rb', line 112

def git_status
  swap_dir { Rake.sh('git status') }
end

#init(file = options[:config]) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vps_cli/cli.rb', line 32

def init(file = options[:config])
  if File.exist?(file)
    loop do
      puts "#{file} already exists. Would you like to overwrite it? (Y/N)"
      input = $stdin.gets.chomp

      # breaks and creates the config
      break if input.to_sym == :y
      return if input.to_sym == :n

      # continue the loop otherwise
    end
  end
  VpsCli.create_configuration(file)
end

#install_allObject



76
77
78
79
80
81
82
# File 'lib/vps_cli/cli.rb', line 76

def install_all
  Install.all_install

  return if VpsCli.errors.empty?

  VpsCli.print_errors
end

#install_gemsObject



49
50
51
52
53
# File 'lib/vps_cli/cli.rb', line 49

def install_gems
  Packages::GEMS.each do |g|
    Rake.sh("gem install #{g}")
  end
end

#loginObject



85
86
87
88
# File 'lib/vps_cli/cli.rb', line 85

def 
  VpsCli.load_configuration(options[:config])
  VpsCli.provide_credentials
end

#pullObject



63
64
65
66
# File 'lib/vps_cli/cli.rb', line 63

def pull
  VpsCli.load_configuration(options[:config])
  Pull.all
end

#update_allObject



69
70
71
72
73
# File 'lib/vps_cli/cli.rb', line 69

def update_all
  VpsCli.load_configuration(options[:config])
  Install.prep
  Install.install_non_apt_packages
end

#versionObject



15
16
17
# File 'lib/vps_cli/cli.rb', line 15

def version
  puts "vps-cli version #{VpsCli::VERSION}"
end