Sha256: f7aa0f6ef04df1892d68897fe67c9c700294d63beea938ebbd70107a3186ce13

Contents?: true

Size: 869 Bytes

Versions: 3

Compression:

Stored size: 869 Bytes

Contents

#!/usr/bin/env ruby

require 'optionparser'

APP = File.basename(__FILE__)

commands = {
    "explain" => "Generate a report from logged SQL queries",
    "check"   => "Check staged files for query problems",
}

global = OptionParser.new do |opts|
  opts.banner = "usage: #{APP} [--help] <command> [<args>]"
  opts.separator ""
  opts.separator "These are the commands available:"
  commands.each do |name,info|
    opts.separator "  #{name}     #{info}"
  end
  opts.separator ""
  opts.separator "See #{APP} --help <command> to read about a specific command."
  opts.separator ""
end

global.order!

command = ARGV.shift

if command.nil?
  puts global.to_s
  exit
end

if !commands.key?(command)
    puts "#{APP}: '#{command}' is not a '#{APP}' command. See '#{APP} --help'."
    exit 1
end

path = File.join(File.dirname(__FILE__), command)

Kernel.exec(path, *ARGV)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shiba-0.2.3 bin/shiba
shiba-0.2.2 bin/shiba
shiba-0.2.0 bin/shiba