Add campaigner list command
This commit is contained in:
parent
27965460d4
commit
0cff217a8b
4 changed files with 44 additions and 0 deletions
|
@ -8,6 +8,7 @@ Command line tool to create and manage community campaigns. `campaigner` takes c
|
||||||
- `campaigner publish` builds the tickets information and publishes it both to jira and github.
|
- `campaigner publish` builds the tickets information and publishes it both to jira and github.
|
||||||
- `campaigner sync` downloads updated information of the campaign progress.
|
- `campaigner sync` downloads updated information of the campaign progress.
|
||||||
- `campaigner status` shows the current campaign data and progression.
|
- `campaigner status` shows the current campaign data and progression.
|
||||||
|
- `campaigner list` shows the current campaign tickets and their status.
|
||||||
- `campaigner report` generates reports from the campaign data.
|
- `campaigner report` generates reports from the campaign data.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
21
cmd/list.go
Normal file
21
cmd/list.go
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"git.ctrlz.es/mgdelacroix/campaigner/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ListCmd() *cobra.Command {
|
||||||
|
return &cobra.Command{
|
||||||
|
Use: "list",
|
||||||
|
Short: "Prints a list of the campaign's tickets",
|
||||||
|
Long: "Prints a list of the campaign's tickets with their statuses and external ids",
|
||||||
|
Args: cobra.NoArgs,
|
||||||
|
Run: withApp(listCmdF),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func listCmdF(a *app.App, cmd *cobra.Command, _ []string) {
|
||||||
|
a.Campaign.PrintList()
|
||||||
|
}
|
|
@ -50,6 +50,7 @@ func RootCmd() *cobra.Command {
|
||||||
// FilterCmd(),
|
// FilterCmd(),
|
||||||
InitCmd(),
|
InitCmd(),
|
||||||
LabelCmd(),
|
LabelCmd(),
|
||||||
|
ListCmd(),
|
||||||
StatusCmd(),
|
StatusCmd(),
|
||||||
PublishCmd(),
|
PublishCmd(),
|
||||||
PullCmd(),
|
PullCmd(),
|
||||||
|
|
|
@ -2,6 +2,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -87,6 +88,26 @@ func (c *Campaign) PrintStatus() {
|
||||||
w.Flush()
|
w.Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Campaign) PrintList() {
|
||||||
|
for _, t := range c.Tickets {
|
||||||
|
if t.IsPublishedJira() {
|
||||||
|
var str string
|
||||||
|
if t.IsPublishedGithub() {
|
||||||
|
str = fmt.Sprintf("[%s / #%d] %s", t.JiraLink, t.GithubLink, t.Summary)
|
||||||
|
} else {
|
||||||
|
str = fmt.Sprintf("[%s] %s", t.JiraLink, t.Summary)
|
||||||
|
}
|
||||||
|
if t.GithubStatus != "" {
|
||||||
|
str += fmt.Sprintf(" (%s)", t.GithubStatus)
|
||||||
|
}
|
||||||
|
fmt.Println(str)
|
||||||
|
} else {
|
||||||
|
b, _ := json.Marshal(t)
|
||||||
|
fmt.Printf("unpublished: %s\n", string(b))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Campaign) AddTickets(tickets []*Ticket, fileOnly bool) {
|
func (c *Campaign) AddTickets(tickets []*Ticket, fileOnly bool) {
|
||||||
c.Tickets = append(c.Tickets, tickets...)
|
c.Tickets = append(c.Tickets, tickets...)
|
||||||
c.RemoveDuplicateTickets(fileOnly)
|
c.RemoveDuplicateTickets(fileOnly)
|
||||||
|
|
Loading…
Reference in a new issue