class Terraspace::CLI::New::Arg
Public Class Methods
options()
click to toggle source
# File lib/terraspace/cli/new/arg.rb, line 7 def self.options [ [:force, aliases: %w[y], type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"], [:name, default: "apply", desc: "command name"], [:type, default: "project", desc: "project, stack or module"], ] end
source_root()
click to toggle source
# File lib/terraspace/cli/new/arg.rb, line 16 def self.source_root File.expand_path("../../../templates/base/arg", __dir__) end
Public Instance Methods
check_stack_arg()
click to toggle source
# File lib/terraspace/cli/new/arg.rb, line 46 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 arg STACK --type #{type} EOL exit 1 end
create()
click to toggle source
# File lib/terraspace/cli/new/arg.rb, line 58 def create directory ".", dest end
Private Instance Methods
arg_path()
click to toggle source
# File lib/terraspace/cli/new/arg.rb, line 40 def arg_path "#{dest}/#{kind}.rb" end
dest()
click to toggle source
# File lib/terraspace/cli/new/arg.rb, line 31 def dest map = { project: "config/args", stack: "app/stacks/#{stack}/config/args", module: "app/modules/#{stack}/config/args", } map[type.to_sym] end
name()
click to toggle source
# File lib/terraspace/cli/new/arg.rb, line 27 def name options[:name] ? options[:name] : "apply" end
type()
click to toggle source
# File lib/terraspace/cli/new/arg.rb, line 21 def type valid_types = %w[project stack module] type = @options[:type] valid_types.include?(type) ? type : "project" # fallback to project if user provides invalid type end