Skip to content

Instantly share code, notes, and snippets.

@jonico
Created June 16, 2016 14:23
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/b76c571a4e1c30719ff5718e9b01d8d1 to your computer and use it in GitHub Desktop.
Save jonico/b76c571a4e1c30719ff5718e9b01d8d1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env groovy
// run with groovy ListReposInOrg -t <personal access token> <org name>
package org.kohsuke.github
@Grab(group='org.kohsuke', module='github-api', version='1.75')
import org.kohsuke.github.GitHub
class ListReposInOrg extends GitHub {
static void main(args) {
def cli = new CliBuilder(usage: 'groovy -t <personal access token> ListReposInOrg.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).listRepositories().each {
println it.getFullName();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment