Skip to content

Instantly share code, notes, and snippets.

@jonico
Created November 4, 2016 10:00
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 jonico/dcccbc4f49a11e6eb4dcdb4e3cb4b8c4 to your computer and use it in GitHub Desktop.
Save jonico/dcccbc4f49a11e6eb4dcdb4e3cb4b8c4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env groovy
package org.kohsuke.github
@Grab(group='org.kohsuke', module='github-api', version='1.75')
import org.kohsuke.github.GitHub
class ListUsersInOrg extends GitHub {
static void main(args) {
def cli = new CliBuilder(usage: 'groovy -t <personal access token> ListUsersInOrg.groovy <organization>')
cli.t(longOpt: 'token', 'personal access token', required: false , args: 1 )
OptionAccessor opt = cli.parse(args)
if(opt.arguments().size() != 1) {
cli.usage()
return
}
def org = opt.arguments()[0];
def githubCom
if (opt.t) {
githubCom = GitHub.connectUsingOAuth(opt.t);
} else {
githubCom = GitHub.connect();
}
githubCom.getOrganization(org).listMembers().each {
println it.getLogin();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment