Sha256: 5b775aa69ff90893e959c9108bfa4a0ea7d2b7e073aff48f068abd39c7469658
Contents?: true
Size: 1.8 KB
Versions: 7
Compression:
Stored size: 1.8 KB
Contents
#require 'facets/ansicode' module Reap require 'reap/project' # Application is the commandline interface. class Application attr_reader :manager def initialize #vector = ArgVector.new #arguments = vector.arguments #options = vector.options opts = {} opts['dryrun'] = options.delete('dryrun') opts['trace'] = options.delete('trace') opts['force'] = options.delete('force') opts['verbose'] = options.delete('verbose') opts['debug'] = options.delete('debug') opts @manager = Project.new(opts) #@arguments = arguments #@options = options end def argv @argv ||= ARGV.dup end def arguments @arguments ||= argv.select{ |e| e !~ /^-/ && e !~ /=/ } end def options @options ||= ( pms = {} argv.select{ |e| /[=]/ =~ e }.each do |e| k,v = e.split('=') k = k.sub(/^[-]{1,2}/,'') pms.store(k,v) end argv.select{ |e| e =~ /^-/ && e !~ /=/ }.each do |k| k = k.sub(/^[-]{1,2}/,'') pms.store(k,true) end pms ) end # def method_missing(cmd, *args) opts = options.dup opts['arguments'] = arguments unless arguments.empty? args << opts manager.invoke(cmd, *args) end # # TODO: Collect reap bin commands and give short descriptions. # # def display_commands # cmds = Application.commands # #cmds.sort!{ |a,b| a[0] <=> b[0] } # size = cmds.collect{ |(k,m,v)| k.to_s.size }.max + 2 # cmds.each do |(k,m,v)| # next unless v # next if k.index(':') or k.index('-') unless task? # puts " %-#{size}s # %s" % [k, v] # end # end # end end end
Version data entries
7 entries across 7 versions & 1 rubygems