Created
June 16, 2016 14:23
-
-
Save jonico/b76c571a4e1c30719ff5718e9b01d8d1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/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