Sha256: be74a1ae5a6561102647b9c964e4a3f684a21ce8f4bc84eb829db8059e7f6179

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require 'peak_log_simulator'
require 'resolve'
require 'socket_connetion'

options={:filepath => nil ,:timescale => 1.0}

opts = OptionParser.new do |opts|
  opts.banner = "Usage: simulate [logfile path] [options]"

  opts.on('-t time',Float,'timescale. Default is 1.0') do |time|
    options[:timescale] = time
  end

  opts.on_tail('-h', '--help', 'Show this message') { puts opts; exit }
end

opts.parse!(ARGV)

# empty option set
# if STDIN.tty?
#   puts opts.help
#   exit 1
# end

unless ARGV.empty?
  options[:filepath] = ARGV.pop(ARGV.count)[0]
end

LogSimulator::Resolver.select_target(2.0) do |target|
  socket_connection = LogSimulator::SocketConnetion.new(target.target_name,target.port)

  unless options[:filepath].nil?
    LogSimulator::PeakLogSimulator.start(socket_connection.socket,options[:filepath],options[:timescale]) do |success|
      while true #TODO: make it DRY
        print '>'
        message = gets.chomp
        socket_connection.socket.puts message
      end
    end
  else
    while true
      print '>'
      message = gets.chomp
      socket_connection.socket.puts message
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
log_simulator-0.1.0 bin/simulate