# Support libraries require 'rbconfig' require 'facets' require 'calibre/consoleapp' # Reap support require 'reap/projectinfo' # Reap tasks require 'reap/task/fileperm' require 'reap/task/test' require 'reap/task/testext' require 'reap/task/rdoc' require 'reap/task/announce' require 'reap/task/package' require 'reap/task/publish' require 'reap/task/info' require 'reap/task/install' require 'reap/task/noop' #require 'reap/task/webpublish' Reap.register module Reap Version = "1.2.0" end class ReapCommand < Console::Application # to do first for exvery task #def application_setup # $PROJECT_INFO = ProjectInfo.new( $PROJECT_FILE ) #end # 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 build version (only for package task) def _b ; $BUILD_VERSION = true ; end #def _f( pif ) ; $PROJECT_FILE = pif ; end #alias_method :_f, :__file # 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_class| puts " #{name}".ljust(20) + "#{task_class.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.tasks.each do |sym,taskclass| define_method(sym) do |*args| taskclass.new(*args) end end end HELP = <<-HERE reap v#{::Reap::Version} USAGE: reap [options...] [arguments...] COMMANDS: template Copies a ProjectInfo template into the current directory, if it doesn't already exist. scaffold Builds a project directory based on settings of project information file. 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. -f --file Specify alternate project file. -h --help Display this help information. HERE