require 'facets' require 'rbconfig' require 'carat/shellcommand' require 'reap/tasks' INFO_FILES = [ 'ProjectInfo', 'Reapfile', 'projectinfo', 'reapfile' ] Reap.register module Reap Version = "2005-10-06" end class ReapCommand < ShellCommand # Options # verbose mode def __verbose ; $VERBOSE = true ; end alias_method :_V, :__verbose # debug mode (under construction) def __debug; $DEBUG = true ; end alias_method :_D, :__debug # pretend mode (under construction) def __pretend; $PRETEND = true ; end alias_method :_P, :__pretend # option to display version def __version ; version ; end alias_method :_v, :__version # option to display help def __help ; help ; end alias_method :_h, :__help # option to display tasks def __tasks; tasks ; end alias_method :_t, :__tasks # option for require #def __require(r); @require = r ; end #alias_method :_r, :__require # Commands # default action def default tasks end # display version def version puts "Reap v.#{Reap::Version}" exit 0 end # display help def help puts HELP exit 0 end # list available tasks def tasks Reap.initialize #_all puts Reap.tasks.each do |name,task| puts " #{name}".ljust(20) + "#{task.task_desc}" end puts exit 0 end alias_method :ls, :tasks # copy the file from lib/data to the current dir. def template if INFO_FILES.any?{ |f| File.exists?(f) } puts "Project file already exists." exit 0 end filename = 'ProjectInfo' dir = File.join( ::Config::CONFIG['datadir'], 'reap', 'scaffold' ) f = File.join( dir, filename ) raise "ProjectInfo template file #{f} is missing." unless File.file?( f ) # copy FileUtils.cp( f, filename ) puts "#{filename} created. You'll need to fill it out." exit 0 end Reap.registry.each do |sym,taskclass| define_method(sym) do |*args| taskclass.new.run(*args) end end end HELP = <<-HERE reap v#{::Reap::Version} USAGE: reap [options...] [arguments...] COMMANDS: scaffold Copies a ProjectInfo template into the current directory, if it doesn't already exist. If it does exist will build the project directory based on it. This will not destroy any structure already in place! help Displays this help information. OPTIONS: -v --version Display the current version. -V --verbose Provides extra verbose processing information. -D --debug Provides extra verbose processing information. -h --help Display this help information. HERE