Created
August 19, 2015 15:11
-
-
Save karstengresch/0a990e658bbe5e19304f to your computer and use it in GitHub Desktop.
Primitive Ruby script for checking if a GitHub user login is avalable (you need to have octokit installed). Usage: ruby ghakound.rb <login>, e.g. ruby ghakound.rb defunkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#encoding: utf-8 | |
# Checks if GitHub login is taken. Argument -u => login name | |
# noinspection RubyResolve | |
require 'optparse' | |
require 'octokit' | |
require 'pp' | |
options = {} | |
option_parser = OptionParser.new do |opts| | |
# Create a flag | |
opts.on('-u USER') do |user| | |
options[:user] = user | |
end | |
end | |
begin | |
option_parser.parse! | |
# puts options.inspect | |
rescue OptionParser::InvalidArgument => ex | |
STDERR.puts ex.message | |
STDERR.puts option_parser | |
end | |
begin | |
command = -1 | |
user = Octokit.user options[:user] | |
puts user.login | |
command = 0 | |
rescue | |
puts "Not found" | |
command = 1 | |
end | |
exit command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment