Sha256: 840f64fd1cafce96d2735960558353213bb900ca083f92694e08911ad6986953

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

#!/usr/bin/env ruby

# This is a front-end for tools provided by Ruby-VPI.
#
# Usage:
#   ruby-vpi                      Show this help message
#   ruby-vpi -v                   Show version information
#   ruby-vpi TOOL --help          Show help message for TOOL
#   ruby-vpi TOOL arguments...    Run TOOL with some arguments

#--
# Copyright 2006 Suraj N. Kurapati
# See the file named LICENSE for details.

TOOL_DIR = File.dirname(__FILE__)
TOOL_EXT = '.rb'

$: << File.join(TOOL_DIR, '..', 'lib')
require 'ruby-vpi'


def show_help_info
  # show program description located at the top of this file
  puts File.read(__FILE__).split(/^$\n/)[1].gsub(/^# ?/, '')

  # show a list of available tools
  puts '', 'Tools:'

  Dir[File.join(TOOL_DIR, '*' + TOOL_EXT)].each do |file|
    tool = File.basename file, TOOL_EXT
    printf "  %-10s %s", tool, File.new(file).readline.sub(/^#\s*/, '')
  end

  # show a list of available simulators
  require 'ruby-vpi'
  puts '', 'Simulators:'

  RubyVPI::SIMULATORS.each do |sim|
    printf "  %-10s %s\n", sim.id, sim.name
  end
end


if tool = ARGV.shift
  case tool
  when /-v|--version/i
    puts "%s %s (%s) %s %s" % [
      :name, :version, :release, :website, :home
    ].map {|m| RubyVPI::Project[m] }

  when /-h|--help/i
    show_help_info

  else
    glob = File.join(TOOL_DIR, tool + '*' + TOOL_EXT)
    file = Dir[glob].first

    begin
      load file
    rescue
      raise ArgumentError, "The #{tool.inspect} tool does not exist."
    end
  end

else
  show_help_info
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-vpi-20.0.0 bin/ruby-vpi
ruby-vpi-21.0.0 bin/ruby-vpi
ruby-vpi-21.1.0 bin/ruby-vpi