Class: Terraspace::CLI::New::Shim

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/terraspace/cli/new/shim.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cli_optionsObject



5
6
7
8
9
# 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_rootObject



12
13
14
# File 'lib/terraspace/cli/new/shim.rb', line 12

def self.source_root
  File.expand_path("../../../templates/base/shim", __dir__)
end

Instance Method Details

#createObject



20
21
22
23
24
25
# 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

#messageObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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_varsObject



16
17
18
# File 'lib/terraspace/cli/new/shim.rb', line 16

def set_vars
  @path = @options[:path]
end