func GenerateConfig(token string) { if _, err := os.Stat(fullFileLocation()); err == nil { logger.Debug("Config file already exists") } else { logger.Debug("Generating new config file at " + fullFileLocation() + "...") content := []byte("[authentication]\ntoken = \"" + token + "\"\n") err := ioutil.WriteFile(fullFileLocation(), content, 0644) if err != nil { logger.Info("There was a problem writing your config file") } } }
func (query *Query) Execute() { client := client() options := github.IssueListByRepoOptions{State: query.State, Labels: query.Labels} issues, _, err := client.Issues.ListByRepo(query.Owner, query.Repo, &options) if err != nil { logger.Error(err.Error()) } else if len(issues) == 0 { logger.Info("no pulls") } else { var wg sync.WaitGroup for _, issue := range issues { if issue.PullRequestLinks != nil { wg.Add(1) go func() { defer wg.Done() fmt.Printf("%s\n", fetchByIssueNumber(*client, query.Owner, query.Repo, *issue.Number)) }() wg.Wait() } } } }
// Uncomment the following line if your bare application has an action associated with it PersistentPreRun: func(cmd *cobra.Command, args []string) { if debugFlag { logger.CurrentLevel = logger.DebugLevel } config.ConfigInit() }, Run: func(cmd *cobra.Command, args []string) { if len(ownerArg) == 0 { ownerArg = projects.Current().GithubOwner() } if len(repoArg) == 0 { repoArg = projects.Current().GithubRepo() } if len(repoArg) == 0 || len(ownerArg) == 0 { logger.Info("Couldn't find Owner or Repo to query") return } labels := strings.Split(strings.Trim(labelArg, " "), ",") issueQuery := issues.Query{ Labels: labels, State: stateArg, Owner: ownerArg, Repo: repoArg, } issueQuery.Execute() }, } //Execute adds all child commands to the root command sets flags appropriately.