Skip to content

Instantly share code, notes, and snippets.

@mechamogera
Last active Mar 18, 2016
Embed
What would you like to do?
Github Organizationのメンバー一覧を取得するRubyスクリプト
# A sample Gemfile
source "https://rubygems.org"
gem 'github_api'
gem 'highline'
gem 'trollop'
require 'github_api'
require 'highline/import'
require 'trollop'
class GithubOrgMembers
def self.members(org_name, options = {})
$terminal = HighLine.new($stdin, $stderr)
options[:user] = ask("Enter Github user: ") { |q| q.echo = true } unless options[:user]
options[:password] = ask("Enter Github password: ") { |q| q.echo = false } unless options[:password]
github = Github.new(login: options[:user], password: options[:password])
members = github.orgs.members.list(org_name: org_name)
members.each_page do |page|
page.each do |repo|
puts repo.login
end
end
end
end
opts = Trollop::options do
opt :org_name, 'github organization name', :required => true, :type => :string
opt :user, 'github account user name', :type => :string
opt :password, 'github account password', :type => :string
end
GithubOrgMembers.members(opts[:org_name], opts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment