Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8347: cli.rb_add_outputfile.3.patch

File cli.rb_add_outputfile.3.patch, 1.2 kB (added by lhartley, 2 years ago)

patch to add "output to file" option

  • cli.rb

    old new  
    9595    # the CLI class is recommended. 
    9696    def initialize(args = ARGV) 
    9797      @args = args 
    98       @options = { :recipes => [], :actions => [], :vars => {}, 
     98      @options = { :recipes => [], :actions => [], :vars => {}, :output => [], 
    9999        :pre_vars => {}, :sysconf => default_sysconf, :dotfile => default_dotfile } 
    100100 
    101101      OptionParser.new do |opts| 
     
    189189          "May be given multiple times. (Default: silent)" 
    190190        ) { @options[:verbose] ||= 0; @options[:verbose] += 1 } 
    191191 
     192        opts.on("-o", "--output FILE", 
     193          "Specify a file for output.", 
     194          "(Default: STDERR)" 
     195        ) {|value| @options[:output] = value } 
     196 
    192197        opts.on("-V", "--version", 
    193198          "Display the version info for this utility" 
    194199        ) do 
     
    247252      def execute_recipes! 
    248253        config = Capistrano::Configuration.new 
    249254        config.logger.level = options[:verbose] 
     255        config.logger.setDevice({:device =>options[:output]})  
    250256        config.set :password, options[:password] 
    251257        config.set :pretend, options[:pretend] 
    252258