bin/reap in reap-03.01 vs bin/reap in reap-4.0
- old
+ new
@@ -1,161 +1,5 @@
#!/usr/bin/env ruby
-require 'getoptlong'
-require 'rbconfig'
-require 'reap/tasks'
+require 'reap/bin/reap'
-HELP1 = <<-HERE
-
- reap v#{::Reap::VERSION}
-
- USAGE: reap [options...] <command> [arguments...]
-
- COMMANDS:
-
- help
- Displays this help information.
-
- template
- Copies the ProjectInfo template into the current
- directory, if it doesn't already exist.
-
-HERE
-
-HELP2 = <<-HERE
- OPTIONS:
-
- -v --verbose
- Provides extra verbose processing information.
-
- -u --use <file>
- Use the specified configuration file rather than
- the default 'ProjectInfo'.
-
- -p --pretend (NOT YET IMPLEMENTED)
- Pretend, just to see what would happen, but don't
- actually do anything.
-
- --version
- Display the current version.
-
- --help
- Display this help information.
-HERE
-
-
-module Commands
- extend self
-
- DATA_DIR = 'site_ruby/reap'
- FILE_NAME = 'ProjectInfo'
-
- def version
- d = Reap::VERSION.to_i
- f = Reap::VERSION - d
- puts "%02d.%02d" % [ d, f ]
- end
-
- def help
- puts HELP1
-
- #Reap::Task.registry.each do |t|
- # puts " #{t.task_name}"
- # puts " #{t.task_desc}\n\n"
- #end
-
- puts HELP2
- end
-
- def tasks
- puts
- #Reap::Task.registry.each do |t|
- # puts " #{t.task_name}".ljust(20) + "#{t.task_desc}"
- #end
- puts
- end
-
- def template( file_name = ProjectInfo )
- #dir = File.dirname(File.dirname(__FILE__))
- dir = File.join( ::Config::CONFIG['datadir'], DATA_DIR )
-
- tmpf = File.join( dir, 'template.yaml' )
- unless File.file?( tmpf )
- puts tmpf
- raise "Tempfile is missing."
- end
-
- if File.directory?(filename)
- puts "#{filename} a directory. Cannot comply."
- return
- elsif File.file?(filename)
- puts "#{filename} already exists."
- return
- end
- # copy tmpf to Reapfile
- FileUtils.cp( tmpf, filename )
- puts "#{filename} created. You'll need to fill it out."
- end
-
-end
-
-
-# main
-
-cmd = nil
-
-opts = GetoptLong.new(
- [ "-v", "--verbose", GetoptLong::NO_ARGUMENT ],
- [ "-p", "--pretend", GetoptLong::NO_ARGUMENT ],
- [ "-d", "--debug", GetoptLong::NO_ARGUMENT ],
- [ "-u", "--use", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--version", GetoptLong::NO_ARGUMENT ],
- [ "--help", GetoptLong::NO_ARGUMENT ]
-)
-
-opts.each do |o, a|
- case o
- when '-v'
- $VERBOSE = true
- when '-p'
- $PRETEND = true
- when '-u'
- config = a
- when '-d'
- $DEBUG = true
- when '--help'
- cmd = 'help'
- when '--version'
- cmd = 'version'
- end
-end
-
-cmd = cmd || ARGV[0]
-args = ARGV[1..-1]
-config = nil
-
-cmd = cmd.downcase if cmd
-
-case cmd
-when nil,'help'
- Commands.help
- exit 0
-when 'tasks'
- Commands.tasks
- exit 0
-when 'version'
- Commands.version
- exit 0
-when 'template'
- Commands.template
-end
-
-# Quick-build and run a task.
-
-c = cmd.downcase.to_s
-if ReapTask.respond_to?( "#{c}_task" )
- rt = ReapTask.send("#{c}_task") { ARGV.slice(1..-1).join(' ') }
- rt.run
-else
- puts "Unknown command. Try 'reap help' for assitance."
- exit 0
-end
+ReapCommand.new.go