Module: Temp::Runner
- Defined in:
- lib/temp/runner.rb
Overview
The Runner module contains methods for Temp’s command line interface.
Class Method Summary collapse
- .help ⇒ Object
-
.start!(args) ⇒ Object
Runs Temp as a command line program.
Class Method Details
.help ⇒ Object
8 9 10 |
# File 'lib/temp/runner.rb', line 8 def self.help puts 'Usage: temp [options] [project] [template]' end |
.start!(args) ⇒ Object
Runs Temp as a command line program
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/temp/runner.rb', line 13 def self.start!(args) conf = Temp::Config.new(Temp::Config::DEFAULT_CONF_FILE) = Temp::Options.parse(args) conf. = if [:h] || [:help] help exit elsif [:v] || [:version] puts "Temp #{Temp::VERSION}" exit end if [:args].size == 0 puts 'No template specified.' elsif [: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 |