bin/poohbear
#!/usr/bin/env ruby
require 'command-dispatcher'
$scriptPath = File.expand_path(File.dirname(__FILE__))
$scriptName = File.basename(__FILE__)
$command = ARGV.shift
dispatcher = CommandDispatcher::Dispatcher.new( $scriptPath, $scriptName )
begin
dispatcher.dispatchCommand($command, *ARGV)
rescue ArgumentError => ex
$stderr.puts 'Error: ' + ex.to_s + '. Please specify a valid command.'
dispatcher.usage
exit -1
ensure
end
require 'highline/import'
require 'base64'
require 'polarbear'
#-----------------------------------------------------------------------------
# ................ A R G U M E N T S .. P R O C E S S I N G .................
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# This hash will hold all of the options parsed from the command-line by
# OptionParser.
# login/logout
# creating a new review (reviewer/observers, title)
# adding diff to an existing review
# cancelling review
# finishing a review
# deleting a review
# open a review in the browser
# get review info such as state by id or by title
#-----------------------------------------------------------------------------
options = {}
loglevels = [:debug, :info, :warn, :error, :fatal]
optparse = OptionParser.new do |opts|
# Set a banner, displayed at the top of the help screen.
opts.banner = 'Usage: poohbear [options] oldbranch newbranch ...'
# Define the options, and what they do
options[:list] = []
opts.on('--login', 'login to the code collaborator server') do |l|
options[:list] = l
end
options[:quick] = false
opts.on( '-q', '--quick', 'Perform the task quickly' ) do
options[:quick] = true
end
options[:logfile] = nil
opts.on( '-l', '--logfile FILE', 'Write log to FILE' ) do |file|
options[:logfile] = file
end
options[:usage] = nil
opts.on( '-u', '--usage', 'Print one liner about this script' ) do
options[:usage] = true
end
options[:list] = []
opts.on( '-a', '--list a,b,c', Array, 'List of parameters') do |l|
options[:list] = l
end
options[:loglevel] = nil
opts.on( '-i', '--loglevel OPT', loglevels, 'Log level') do |s|
options[:loglevel] = s
end
opts.on( '-v', '--verbose', 'Verbose ') do
options[:loglevel] = :info
end
# This displays the help screen, all programs are assumed to have this
# option.
opts.on( '-h', '--help', 'Display this screen' ) do
puts opts
exit
end
end
#-----------------------------------------------------------------------------
# Parse the command-line. Remember there are two forms of the parse method.
# The 'parse' method simply parses ARGV, while the 'parse!' method parses
# ARGV and removes any options found there, as well as any parameters for the
# the options. What's left is the list of files to resize.
#-----------------------------------------------------------------------------
begin
optparse.parse!
rescue => ex
puts ex.to_s
exit 1
end
_codecollab = PolarBear::CodeCollab.new
#_codecollab.login('https://development-us:8443', 'plaplante', "\"p0utgr0s'\"")
#p _codecollab.active_reviews
new_review = PolarBear::Review.new(
:title => 'my nice review',
:author => _codecollab.configuration.username,
:reviewers => %w(jearl),
:observers => %w(aburr),
:gitdiffs_args => 'develop master'
)
new_review.create_it!
new_review.add_git_diff('develop', 'master')
p new_review
#_codecollab.get_review_with_title 'my review'
#review = _codecollab.create_review(
# :title => 'my review',
# :observers => %w(aburr),
# :reviewers => %w(jearl),
# :diff => 'diff stuff'
#)
#puts review.review_id
#reviews_in_planning = _codecollab.reviews_in_planning('Pat Laplante')
#_codecollab.delete_reviews(reviews_in_planning)
#puts _codecollab.admin.create_review('pat is awesome')