bin/poohbear-logout
#!/usr/bin/env ruby
require 'highline/import'
require 'base64'
require 'polarbear'
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
def usage
puts 'Commands for login out from your code collaborator server.'
exit 0
end
#-----------------------------------------------------------------------------
# ................ A R G U M E N T S .. P R O C E S S I N G .................
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
options = {}
optparse = OptionParser.new do |opts|
# Set a banner, displayed at the top of the help screen.
opts.banner = 'Usage: poohbear logout'
options[:usage] = nil
opts.on( '-u', '--usage', 'Print one liner about this script' ) do
options[:usage] = true
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
usage if options[:usage]
_codecollab = PolarBear::CodeCollab.new
options[:url] = _codecollab.configuration.url if options[:url].nil?
options[:username] = _codecollab.configuration.username if options[:username].nil?
options[:url] = ask('URL: ') if options[:url].nil? || options[:url].empty?
options[:username] = ask('Username: ') if options[:username].nil? || options[:username].empty?
options[:password] = ask('Password: ') { |q| q.echo = '*' } if options[:password].nil?
_codecollab.login("#{options[:url]}", "#{options[:username]}", "\"#{options[:password]}\"")