#!/usr/bin/env ruby $LOAD_PATH << File.expand_path("../../lib", __FILE__) require 'hieracles' require 'hieracles/options/hieracles' require 'hieracles/commands' opt = Hieracles::Options::Hieracles.new(ARGV) if opt.options.has_key? :version puts Hieracles.version exit(0) end command = opt.payload.shift arg = opt.payload.shift extra = opt.payload if !command || command == 'help' puts Hieracles::Options::Hieracles.usage exit(1) end config = Hieracles::Config.new opt.options commands = Hieracles::Commands.new config if commands.available.include? command commands.run command, arg, extra elsif commands.respond_to? command commands.send command, arg, extra else puts 'Command not found.' end