Adds simple integration with github library and test with publish github

This commit is contained in:
Miguel de la Cruz 2020-03-07 13:08:03 +01:00
parent d5815e4e6a
commit fdaf72aac4
206 changed files with 63806 additions and 2 deletions

View file

@ -2,10 +2,12 @@ package cmd
import (
"fmt"
"context"
"git.ctrlz.es/mgdelacroix/campaigner/campaign"
"git.ctrlz.es/mgdelacroix/campaigner/config"
"git.ctrlz.es/mgdelacroix/campaigner/jira"
"git.ctrlz.es/mgdelacroix/campaigner/github"
"github.com/spf13/cobra"
)
@ -13,7 +15,7 @@ import (
func JiraPublishCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "jira",
Short: "Publishes the campaign tickets in JIRA",
Short: "Publishes the campaign tickets in jira",
Args: cobra.NoArgs,
RunE: jiraPublishCmdF,
}
@ -25,6 +27,21 @@ func JiraPublishCmd() *cobra.Command {
return cmd
}
func GithubPublishCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "github",
Short: "Publishes the campaign tickets in github",
Args: cobra.NoArgs,
Run: githubPublishCmdF,
}
cmd.Flags().BoolP("all", "a", false, "Publish all the tickets of the campaign")
cmd.Flags().IntP("batch", "b", 0, "Number of tickets to publish")
cmd.Flags().Bool("dry-run", false, "Print the tickets information instead of publishing them")
return cmd
}
func PublishCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "publish",
@ -32,6 +49,7 @@ func PublishCmd() *cobra.Command {
}
cmd.AddCommand(
GithubPublishCmd(),
JiraPublishCmd(),
)
@ -77,3 +95,26 @@ func jiraPublishCmdF(cmd *cobra.Command, _ []string) error {
return nil
}
func githubPublishCmdF(cmd *cobra.Command, _ []string) {
cfg, err := config.ReadConfig()
if err != nil {
ErrorAndExit(cmd, err)
}
// cmp, err := campaign.Read()
// if err != nil {
// ErrorAndExit(cmd, err)
// }
githubClient := github.NewClient("my/repo", cfg.GithubToken)
repos, _, err := githubClient.Repositories.List(context.Background(), "", nil)
if err != nil {
ErrorAndExit(cmd, err)
}
for _, repo := range repos {
cmd.Println(*repo.Name)
}
}