I'm not sure if this is an issue but the Quiet Printer uses output.print(message) instead of output << message as referenced in the readme.md file.
Running
#! /usr/bin/env ruby
require 'tty-command'
# Class prints and logs output of cmd
class Tee
def initialize(file)
@file = file
end
def <<(message)
@file << message
puts message
end
end
# Command System
tee = Tee.new( File.open('foo.log', 'w') )
cmd = TTY::Command.new( output: tee, printer: :quiet )
cmd.run 'ping google.com -c 3'
results in an error of :
/Users/james/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/tty-command-0.4.0/lib/tty/command/printers/quiet.rb:20:in `write': private method `print' called for #<Tee:0x007f82db191558 @file=#<File:foo.log>> (NoMethodError)
from /Users/james/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/tty-command-0.4.0/lib/tty/command/printers/abstract.rb:33:in `print_command_out_data'
from /Users/james/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/tty-command-0.4.0/lib/tty/command/process_runner.rb:66:in `block in read_streams'
Put using the pretty printer instead works without issue. Changing << -> write or aliasing works as well.
Hey everyone,
I'm not sure if this is an issue but the Quiet Printer uses
output.print(message)
instead ofoutput << message
as referenced in the readme.md file.Running
results in an error of :
Put using the pretty printer instead works without issue. Changing
<<
->write
or aliasing works as well.