Skip to content

Instantly share code, notes, and snippets.

@rxbynerd
Created September 8, 2011 21:17
Show Gist options
  • Save rxbynerd/1204759 to your computer and use it in GitHub Desktop.
Save rxbynerd/1204759 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/ruby
# Creates a new repo called ARGV[0]
@args = ARGV
@args.each_with_index{|o,i| puts "#{i} : #{o}"}
if not @args[1] =~ /(private|public)/
puts "invalid arguments: #{@args.inspect}"
exit(1)
end
puts "Creating repo called #{@args[0]} and it's going to be #{@args[1]}"
print "Please enter password: "
system "stty -echo"
pass = STDIN.gets.chomp
system "stty echo"
puts ""
print "Please enter a description: "
desc = STDIN.gets.chomp
print "Please enter a website: "
url = STDIN.gets.chomp
if @args[1] == "public"
state = 1
else
state = 0
end
require "httparty"
class Github
include HTTParty
base_uri "github.com"
def initialize(user, pass)
@auth = {:username => user, :password => pass}
end
# name = new repo name
# state is 0 or 1 depending on private/public
def new_repo(query)
options = {:basic_auth => @auth, :query => query}
self.class.post("/api/v2/json/repos/create", options)
end
end
@github = Github.new("poptart", pass)
opts = {:name => @args[0], :description => desc, :public => state, :homepage => url}
resp = @github.new_repo opts
puts resp.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment