#!/usr/bin/env ruby Signal.trap('INT'){ exit 255 } require 'rubygems' require 'vagabond' require 'vagabond/errors' if(ARGV.include?('--version') || ARGV.include?('-v')) require 'vagabond/vagabond' Vagabond::Vagabond.new.send(:version) elsif(%w(help --help -h).include?(ARGV.first) && ARGV.size == 1) puts "-- Vagabond --\n" require 'vagabond/vagabond' Object.send(:remove_const, :ARGV) ARGV = %w(help) Vagabond::Vagabond.start %w(server knife kitchen spec).each do |key| puts "-- #{key.capitalize} --\n" require "vagabond/#{key}" Object.send(:remove_const, :ARGV) ARGV = %w(help) Vagabond.const_get(key.capitalize).start end else begin case arg = ARGV.shift when 'server' require 'vagabond/server' Vagabond::Server when 'knife' require 'vagabond/knife' ARGV.unshift(arg) unless ARGV.empty? Vagabond::Knife when 'test', 'kitchen' require 'vagabond/kitchen' Vagabond::Kitchen when 'spec' require 'vagabond/spec' Vagabond::Spec else require 'vagabond/vagabond' ARGV.unshift(arg) Vagabond::Vagabond end.start rescue Vagabond::VagabondError => e exit e.exit_code rescue Exception => e $stderr.puts "Vagabond exiting. Reason: #{e}" if(ENV['VAGABOND_EXIT_DEBUG']) puts "#{e.class}: #{e}\n#{e.backtrace.join("\n")}" end exit -1 end end