Class: Terraspace::CLI::New::Ci

Inherits:
Sequence
  • Object
show all
Defined in:
lib/terraspace/cli/new/ci.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Sequence

base_options, component_options

Methods included from Util::Logging

#logger

Class Method Details

.optionsObject



5
6
7
8
9
# File 'lib/terraspace/cli/new/ci.rb', line 5

def self.options
  [
    [:force, aliases: %w[y], type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
  ]
end

Instance Method Details

#generateObject



12
13
14
15
16
17
18
19
20
# File 'lib/terraspace/cli/new/ci.rb', line 12

def generate
  unless template_root_exist? # template not provided in the CI plugin
    puts "This CI plugin did not include template. CI plugin: #{meta[:name]}"
    puts "Searched path: #{template_root}"
    exit 1
  end
  set_source_paths(template_root)
  directory ".", exclude_pattern: "partials"
end

#make_executableObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/terraspace/cli/new/ci.rb', line 22

def make_executable
  exe = meta[:exe]
  return unless exe
  if File.directory?(exe)
    Dir.glob("#{exe}/*").each do |path|
      chmod path, 0755
    end
  else
    chmod exe, 0755
  end
end

#messageObject



34
35
36
37
38
39
# File 'lib/terraspace/cli/new/ci.rb', line 34

def message
  puts <<~EOL
    A CI structure has been generated for #{meta[:name]}.
    It's a starter example and should be adjusted for your needs.
  EOL
end