Method: Cf::CLI#generate

Defined in:
lib/cf/cli.rb

#generate(project_name) ⇒ Object



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/cf/cli.rb', line 165

def generate(project_name)
  source = Dir.pwd

  parent_dir = "#{source}/#{project_name}"
  lines_dir = "#{parent_dir}/lines"
  badges_dir = "#{parent_dir}/badges"

  if options.force?
    FileUtils.rm_rf( parent_dir, :verbose => true)
  end

  if File.exist?(parent_dir)
    say "Skipping #{project_name} because it already exists.", :red
    exit(1)
  end

  say "Generating #{project_name} project hierarchy"
  FileUtils.mkdir(parent_dir)
  say_status "create", "#{project_name}"
  FileUtils.mkdir(badges_dir)
  say_status "create", "#{project_name}/badges"
  FileUtils.mkdir(lines_dir)
  say_status "create", "#{project_name}/lines"

  say "#{project_name.humanize} project hierarchy generated successfully.", :green
  say "Go to the directory #{lines_dir} and run command 'cf line generate <line_name>' to create line.", :yellow
  say "Go to the directory #{badges_dir} and run command 'cf badge generate <badge_name>' to create badge.", :yellow
end