#!/usr/bin/env ruby $:.unshift(File.dirname(__FILE__) + '/../lib') require 'dnsimple' require 'dnsimple/cli' cli = DNSimple::CLI.new require 'optparse' def usage $stderr.puts < OptionParser.new do |opts| opts.on("--template [ARG]") do |opt| options[:template] = opt end end, 'register' => OptionParser.new do |opts| opts.on("--template [ARG]") do |opt| options[:template] = opt end end, 'record:create' => OptionParser.new do |opts| opts.on("--prio [ARG]") do |prio| options[:prio] = prio end end, 'template:add_record' => OptionParser.new do |opts| opts.on("--prio [ARG]") do |prio| options[:prio] = prio end end, } global.order! command = ARGV.shift if command.nil? || command == 'help' usage else options_parser = subcommands[command] options_parser.order! if options_parser begin cli.execute(command, ARGV, options) rescue DNSimple::CommandNotFound => e puts e.message end end