Made merb_radiant executable
[merb_radiant.git] / bin / merb_radiant
blobbe6cca0cf1f6a2b943cbfc2fa969dcee23e52fa7
1 #!/usr/bin/env ruby
3 require File.join(File.dirname(__FILE__), '..', 'config', 'init')
5 $LOAD_PATH << File.join(File.dirname(__FILE__), '..')
7 require 'lib/ruby_version_check'
8 Signal.trap("INT") { puts; exit }
10 require 'lib/radiant'
11 if ARGV.any? { |arg| %w(--version -v).any? { |flag| arg == flag } }
12 puts "MerbRadiant #{MerbRadiant::Version}"
13 exit 0
14 end
16 app_path = ARGV.first
19 require 'rubigen/scripts/generate'
21 class Rubigen::Base
23 def self.use_application_sources!
24 reset_sources
25 sources << Rubigen::PathSource.new(:builtin, "#{File.dirname(__FILE__)}/../lib/generators")
26 end
28 def add_general_options!(opt)
29 opt.separator ''
30 opt.separator 'MerbRadiant Info:'
31 opt.on('-v', '--version', 'Show the Radiant version number and quit.')
32 opt.on('-h', '--help', 'Show this help message and quit.') { |v| options[:help] = v }
34 opt.separator ''
35 opt.separator 'General Options:'
37 opt.on('-p', '--pretend', 'Run but do not make any changes.') { |v| options[:pretend] = v }
38 opt.on('-f', '--force', 'Overwrite files that already exist.') { options[:collision] = :force }
39 opt.on('-s', '--skip', 'Skip files that already exist.') { options[:collision] = :skip }
40 opt.on('-q', '--quiet', 'Suppress normal output.') { |v| options[:quiet] = v }
41 opt.on('-t', '--backtrace', 'Debugging: show backtrace on errors.') { |v| options[:backtrace] = v }
42 opt.on('-c', '--svn', 'Modify files with subversion. (Note: svn must be in path)') do
43 options[:svn] = `svn status`.inject({}) do |opt, e|
44 opt[e.chomp[7..-1]] = true
45 opt
46 end
47 end
48 end
50 end
52 Rubigen::Base.use_application_sources!
53 Rubigen::Scripts::Generate.new.run(ARGV, :generator => 'instance')