class Terraspace::CLI::New::Shim

Public Class Methods

cli_options() click to toggle source
# File lib/terraspace/cli/new/shim.rb, line 5
def self.cli_options
  [
    [:path, aliases: %w[p], default: "/usr/local/bin/terraspace", desc: "path to save the shim script"],
  ]
end
source_root() click to toggle source
# File lib/terraspace/cli/new/shim.rb, line 12
def self.source_root
  File.expand_path("../../../templates/base/shim", __dir__)
end

Public Instance Methods

create() click to toggle source
# File lib/terraspace/cli/new/shim.rb, line 20
def create
  return unless File.exist?(".git")
  dest = @path
  template "terraspace", dest
  chmod dest, 0755
end
message() click to toggle source
# File lib/terraspace/cli/new/shim.rb, line 27
    def message
      dir = File.dirname(@path)
      puts <<~EOL
        A terraspace shim as been generated at #{@path}
        Please make sure that it is found in the $PATH.

        You can double check with:

            which terraspace

        You should see

            $ which terraspace
            #{@path}

        If you do not, please add #{dir} to your PATH.
        You can usually do so by adding this line to ~/.bash_profile and opening a new terminal to check.

            export PATH=#{dir}:/$PATH

      EOL
    end
set_vars() click to toggle source
# File lib/terraspace/cli/new/shim.rb, line 16
def set_vars
  @path = @options[:path]
end

Private Instance Methods

switch_ruby_version_line() click to toggle source
# File lib/terraspace/cli/new/shim.rb, line 51
def switch_ruby_version_line
  rbenv_installed = system("type rbenv 2>&1 > /dev/null")
  if rbenv_installed
    'eval "$(rbenv init -)"'
  end
end