Class: Terraspace::CLI::New::Hook

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.optionsObject



7
8
9
10
11
12
13
14
# File 'lib/terraspace/cli/new/hook.rb', line 7

def self.options
  [
    [:force, aliases: %w[y], type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
    [:kind, default: "terraform", desc: "terraform or terraspace"],
    [:name, desc: "Command name. Defaults to apply for terraform kind and build for terraspace kind"],
    [:type, default: "project", desc: "project, stack or module"],
  ]
end

.source_rootObject



17
18
19
# File 'lib/terraspace/cli/new/hook.rb', line 17

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

Instance Method Details

#check_stack_argObject



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/terraspace/cli/new/hook.rb', line 54

def check_stack_arg
  return if type == "project"
  return unless stack.nil?
  # Else check for STACK argument for type module or stack
  puts <<~EOL
    Required STACK argument, either the module or stack name. Usage:

        terraspace new hook STACK --type #{type}
  EOL
  exit 1
end

#createObject



66
67
68
# File 'lib/terraspace/cli/new/hook.rb', line 66

def create
  directory ".", dest
end