module Temp::Runner
The Runner
module contains methods for Temp's command line interface.
Public Class Methods
help()
click to toggle source
# File lib/temp/runner.rb, line 8 def self.help puts 'Usage: temp [options] [project] [template]' end
start!(args)
click to toggle source
Runs Temp
as a command line program
# File lib/temp/runner.rb, line 13 def self.start!(args) conf = Temp::Config.new(Temp::Config::DEFAULT_CONF_FILE) options = Temp::Options.parse(args) conf.template_options = options if options[:h] || options[:help] help exit elsif options[:v] || options[:version] puts "Temp #{Temp::VERSION}" exit end if options[:args].size == 0 puts 'No template specified.' elsif options[:args].size == 1 template = Temp::Template.new(ARGV[0], conf) Temp::Project.new(Dir.pwd, template).create else template = Temp::Template.new(ARGV[1], conf) Temp::Project.new(ARGV[0], template).create end rescue => e case e.exception when Temp::Exceptions::ProjectExistsError puts 'Cannot create project because file exists there.' when Temp::Exceptions::TemplateNonExistentError puts 'The specified template does not exist.' else raise e end end