Sha256: 9032959b1ffb2cec44e0bd97299b52b476d3f5b490e01e726961f18b087e822f
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 KB
Contents
#require 'facets/ansicode' module Reap require 'reap/project' # = Application # # Application is the commandline interface to Project. 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reap-9.4.0 | lib/reap/application.rb |