#!/usr/bin/env ruby $:.unshift(File.dirname(__FILE__) + '/../lib') require 'toolshed' require 'toolshed/cli' cli = Toolshed::CLI.new require 'optparse' def usage $stderr.puts < OptionParser.new do |opts| opts.on("--tool [ARG]") do |opt| Toolshed::Client.git_tool = opt.downcase end opts.on("--ticket-system [ARG]") do |opt| Toolshed::Client.ticket_tracking_tool = opt.downcase end opts.on("--use-defaults [ARG]") do |opt| Toolshed::Client.use_defaults = opt end opts.on("--title [ARG]") do |opt| options[:title] = opt end opts.on("--body [ARG]") do |opt| options[:body] = opt end end, 'create_branch' => OptionParser.new do |opts| opts.on("--branch-name [ARG]") do |opt| options[:branch_name] = opt end opts.on("--branch-from [ARG]") do |opt| options[:branch_from] = opt end end, 'push_branch' => OptionParser.new do |opts| opts.on("--force [ARG]") do |opt| options[:force_command] = true end opts.on("--branch-name [ARG]") do |opt| options[:branch_name] = opt end end, 'list_branches' => OptionParser.new do |opts| opts.on("--repository-name [ARG]") do |opt| Toolshed::Client.pull_from_repository_name = opt end end, 'checkout_branch' => OptionParser.new do |opts| opts.on("--branch-name [ARG]") do |opt| options[:branch_name] = opt end end, 'delete_branch' => OptionParser.new do |opts| opts.on("--branch-name [ARG]") do |opt| options[:branch_name] = opt 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 Toolshed::CommandNotFound => e puts e.message end end end