Last active
March 18, 2016 03:22
-
-
Save mechamogera/1b6b9be40b3686bc94fd to your computer and use it in GitHub Desktop.
Github Organizationのメンバー一覧を取得するRubyスクリプト
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
# A sample Gemfile | |
source "https://rubygems.org" | |
gem 'github_api' | |
gem 'highline' | |
gem 'trollop' |
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
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