Adds published-only flag to the list command
This commit is contained in:
parent
ce96e712e4
commit
8494b273dd
2 changed files with 10 additions and 4 deletions
10
cmd/list.go
10
cmd/list.go
|
@ -7,15 +7,21 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func ListCmd() *cobra.Command {
|
func ListCmd() *cobra.Command {
|
||||||
return &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "list",
|
Use: "list",
|
||||||
Short: "Prints a list of the campaign's tickets",
|
Short: "Prints a list of the campaign's tickets",
|
||||||
Long: "Prints a list of the campaign's tickets with their statuses and external ids",
|
Long: "Prints a list of the campaign's tickets with their statuses and external ids",
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
Run: withApp(listCmdF),
|
Run: withApp(listCmdF),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd.Flags().BoolP("published-only", "p", false, "list only published tickets")
|
||||||
|
|
||||||
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func listCmdF(a *app.App, cmd *cobra.Command, _ []string) {
|
func listCmdF(a *app.App, cmd *cobra.Command, _ []string) {
|
||||||
a.Campaign.PrintList()
|
publishedOnly, _ := cmd.Flags().GetBool("published-only")
|
||||||
|
|
||||||
|
a.Campaign.PrintList(publishedOnly)
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ func (c *Campaign) PrintStatus() {
|
||||||
w.Flush()
|
w.Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Campaign) PrintList() {
|
func (c *Campaign) PrintList(publishedOnly bool) {
|
||||||
for _, t := range c.Tickets {
|
for _, t := range c.Tickets {
|
||||||
if t.IsPublishedJira() {
|
if t.IsPublishedJira() {
|
||||||
var str string
|
var str string
|
||||||
|
@ -101,7 +101,7 @@ func (c *Campaign) PrintList() {
|
||||||
str += fmt.Sprintf(" (%s)", color.MagentaString(t.GithubStatus))
|
str += fmt.Sprintf(" (%s)", color.MagentaString(t.GithubStatus))
|
||||||
}
|
}
|
||||||
fmt.Println(str)
|
fmt.Println(str)
|
||||||
} else {
|
} else if !publishedOnly {
|
||||||
b, _ := json.Marshal(t)
|
b, _ := json.Marshal(t)
|
||||||
fmt.Printf("unpublished: %s\n", color.YellowString(string(b)))
|
fmt.Printf("unpublished: %s\n", color.YellowString(string(b)))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue