Skip to content

Instantly share code, notes, and snippets.

@mechamogera
Last active March 18, 2016 03:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mechamogera/1b6b9be40b3686bc94fd to your computer and use it in GitHub Desktop.
Save mechamogera/1b6b9be40b3686bc94fd to your computer and use it in GitHub Desktop.
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