Method: Cf::Form#generate

Defined in:
lib/cf/cli/form.rb

#generateObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cf/cli/form.rb', line 47

def generate
  line_destination = Dir.pwd
  unless File.exist?("#{line_destination}/line.yml")
    say("The current directory is not a valid line directory.", :red) and return
  end

  FileUtils.rm_rf("#{line_destination}/station#{options[:station]}.html", :verbose => true) if options.force? && File.exist?("#{line_destination}/station#{options[:station]}.html")
  if File.exist?("#{line_destination}/station#{options[:station]}.html")
    say "Skipping the form generation because the station#{options[:station]}.html already exists with its custom form.\nUse the -f flag to force it to overwrite or check and delete the station#{options[:station]}.html file manually.", :red
  else
    say "Generating form for station #{options[:station]}", :green
    Cf::Newform.start([options[:station], options[:labels], options[:fields]])
    say "A new custom task form has been created named station#{options[:station]}.html !!!", :green
  end
end