Sha256: d37ba8ecbd208f8c2a5e281075def6c90d323b952383dd057228e5ac0760fd32

Contents?: true

Size: 967 Bytes

Versions: 8

Compression:

Stored size: 967 Bytes

Contents

require 'optparse'
require 'json'

module PerfMonger
module Command

class PlayCommand < BaseCommand
  register_command 'play', "Play a perfmonger log file in JSON"

  def initialize
    @parser = OptionParser.new
    @parser.banner = <<EOS
Usage: perfmonger play [options] LOG_FILE

Options:
EOS

  end

  def parse_args(argv)
    @parser.parse!(argv)

    if argv.size == 0
      puts("ERROR: PerfMonger log file is required")
      puts(@parser.help)
      exit(false)
    end

    @logfile = argv.shift
    if ! File.exists?(@logfile)
      puts("ERROR: No such file: #{@logfile}")
      puts(@parser.help)
      exit(false)
    end
  end

  def run(argv)
    parse_args(argv)

    @player_bin = ::PerfMonger::Command::CoreFinder.player()

    if ! @player_bin
      puts("[ERROR] no executable binary found.")
      exit(false)
    end

    cmd = [@player_bin]
    cmd << @logfile

    Process.exec(*cmd)
  end
end

end # module Command
end # module PerfMonger

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
perfmonger-0.10.2 lib/perfmonger/command/play.rb
perfmonger-0.10.1 lib/perfmonger/command/play.rb
perfmonger-0.9.0 lib/perfmonger/command/play.rb
perfmonger-0.8.2 lib/perfmonger/command/play.rb
perfmonger-0.8.1 lib/perfmonger/command/play.rb
perfmonger-0.8.0 lib/perfmonger/command/play.rb
perfmonger-0.7.1 lib/perfmonger/command/play.rb
perfmonger-0.7.0 lib/perfmonger/command/play.rb