Last active
February 3, 2021 10:25
-
-
Save palnabarun/2adc485d3f267ddc882310470751def4 to your computer and use it in GitHub Desktop.
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
package main | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"os" | |
"github.com/google/go-github/github" | |
flag "github.com/spf13/pflag" | |
) | |
func main() { | |
var org string | |
var repoType string | |
var entriesPerPage int | |
flag.StringVarP(&org, "org", "o", "pythonindia", "org to get repos from") | |
flag.StringVarP(&repoType, "type", "t", "sources", "type of repo") | |
flag.IntVarP(&entriesPerPage, "n", "n", 100, "org to get repos from") | |
flag.Parse() | |
client := github.NewClient(nil) | |
opt := &github.RepositoryListByOrgOptions{Type: repoType, ListOptions: github.ListOptions{PerPage: entriesPerPage}} | |
repos, _, err := client.Repositories.ListByOrg(context.Background(), org, opt) | |
if err != nil { | |
panic(err) | |
} | |
repos_json, err := json.Marshal(repos) | |
if err != nil { | |
fmt.Printf("err: %s\n", err) | |
os.Exit(1) | |
} | |
fmt.Println(string(repos_json)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment