Create::Crystal::App
Constants
ProjectNameValidator = Proc(Term::Prompt::Question, String | ::Nil, Bool).new do |question, value|
if value.nil? || value.blank?
question.errors << "Project Name must not be empty."
next false
end
if value.size > 50
question.errors << "Project Name must not be longer than 50 characters."
end
if !value[0].ascii_letter?
question.errors << "Project Name must start with a letter."
end
if !value.each_char.all? do |c| ((c.alphanumeric? || (c == '-')) || (c == '_')) || (c == ' ') end
question.errors << "Project Name must only contain alphanumerical characters, spaces, _ or -"
end
if question.errors.size > 0
next false
end
true
end
Match the crystal init validation requirements
Instance methods
clean_project_name(unclean_name : String) : String
Makes string module-and-others-name-compatible
create_file(content : String, path : String, project_dir : Path, type : String | Nil = "")
Creates the template
print_console(msg : String, type : String | Nil = "simple", stop : Bool | Nil = false)
Prints to console using colors and STDOUT/STDERR for better handling It also exits if requested to
run_cmd(cmd, args)
Runs a command in shell Used for fetching the git aurhor and email from git