mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 02:01:43 +03:00
integrate actors and participant filters into ls and show commands
This commit is contained in:
parent
16d2b92f05
commit
14ce66f0dd
@ -13,8 +13,10 @@ import (
|
||||
var (
|
||||
lsStatusQuery []string
|
||||
lsAuthorQuery []string
|
||||
lsTitleQuery []string
|
||||
lsParticipantQuery []string
|
||||
lsLabelQuery []string
|
||||
lsTitleQuery []string
|
||||
lsActorQuery []string
|
||||
lsNoQuery []string
|
||||
lsSortBy string
|
||||
lsSortDirection string
|
||||
@ -89,6 +91,16 @@ func lsQueryFromFlags() (*cache.Query, error) {
|
||||
query.Author = append(query.Author, f)
|
||||
}
|
||||
|
||||
for _, actor := range lsActorQuery {
|
||||
f := cache.ActorFilter(actor)
|
||||
query.Actor = append(query.Actor, f)
|
||||
}
|
||||
|
||||
for _, participant := range lsParticipantQuery {
|
||||
f := cache.ParticipantFilter(participant)
|
||||
query.Participant = append(query.Participant, f)
|
||||
}
|
||||
|
||||
for _, label := range lsLabelQuery {
|
||||
f := cache.LabelFilter(label)
|
||||
query.Label = append(query.Label, f)
|
||||
@ -151,6 +163,10 @@ func init() {
|
||||
"Filter by status. Valid values are [open,closed]")
|
||||
lsCmd.Flags().StringSliceVarP(&lsAuthorQuery, "author", "a", nil,
|
||||
"Filter by author")
|
||||
lsCmd.Flags().StringSliceVarP(&lsParticipantQuery, "participant", "p", nil,
|
||||
"Filter by participant")
|
||||
lsCmd.Flags().StringSliceVarP(&lsActorQuery, "actor", "A", nil,
|
||||
"Filter by actor")
|
||||
lsCmd.Flags().StringSliceVarP(&lsLabelQuery, "label", "l", nil,
|
||||
"Filter by label")
|
||||
lsCmd.Flags().StringSliceVarP(&lsTitleQuery, "title", "t", nil,
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/MichaelMure/git-bug/cache"
|
||||
"github.com/MichaelMure/git-bug/commands/select"
|
||||
_select "github.com/MichaelMure/git-bug/commands/select"
|
||||
"github.com/MichaelMure/git-bug/util/colors"
|
||||
"github.com/MichaelMure/git-bug/util/interrupt"
|
||||
"github.com/spf13/cobra"
|
||||
@ -50,11 +50,17 @@ func runShowBug(cmd *cobra.Command, args []string) error {
|
||||
case "id":
|
||||
fmt.Printf("%s\n", snapshot.Id())
|
||||
case "labels":
|
||||
var labels = make([]string, len(snapshot.Labels))
|
||||
for i, l := range snapshot.Labels {
|
||||
labels[i] = string(l)
|
||||
for _, l := range snapshot.Labels {
|
||||
fmt.Printf("%s\n", l.String())
|
||||
}
|
||||
case "actors":
|
||||
for _, a := range snapshot.Actors {
|
||||
fmt.Printf("%s\n", a.DisplayName())
|
||||
}
|
||||
case "participants":
|
||||
for _, p := range snapshot.Participants {
|
||||
fmt.Printf("%s\n", p.DisplayName())
|
||||
}
|
||||
fmt.Printf("%s\n", strings.Join(labels, "\n"))
|
||||
case "shortId":
|
||||
fmt.Printf("%s\n", snapshot.HumanId())
|
||||
case "status":
|
||||
@ -80,15 +86,36 @@ func runShowBug(cmd *cobra.Command, args []string) error {
|
||||
firstComment.FormatTimeRel(),
|
||||
)
|
||||
|
||||
// Labels
|
||||
var labels = make([]string, len(snapshot.Labels))
|
||||
for i := range snapshot.Labels {
|
||||
labels[i] = string(snapshot.Labels[i])
|
||||
}
|
||||
|
||||
fmt.Printf("labels: %s\n\n",
|
||||
fmt.Printf("labels: %s\n",
|
||||
strings.Join(labels, ", "),
|
||||
)
|
||||
|
||||
// Actors
|
||||
var actors = make([]string, len(snapshot.Actors))
|
||||
for i := range snapshot.Actors {
|
||||
actors[i] = snapshot.Actors[i].DisplayName()
|
||||
}
|
||||
|
||||
fmt.Printf("actors: %s\n",
|
||||
strings.Join(actors, ", "),
|
||||
)
|
||||
|
||||
// Participants
|
||||
var participants = make([]string, len(snapshot.Participants))
|
||||
for i := range snapshot.Participants {
|
||||
participants[i] = snapshot.Participants[i].DisplayName()
|
||||
}
|
||||
|
||||
fmt.Printf("participants: %s\n\n",
|
||||
strings.Join(participants, ", "),
|
||||
)
|
||||
|
||||
// Comments
|
||||
indent := " "
|
||||
|
||||
@ -126,5 +153,5 @@ var showCmd = &cobra.Command{
|
||||
func init() {
|
||||
RootCmd.AddCommand(showCmd)
|
||||
showCmd.Flags().StringVarP(&showFieldsQuery, "field", "f", "",
|
||||
"Select field to display. Valid values are [author,authorEmail,createTime,humanId,id,labels,shortId,status,title]")
|
||||
"Select field to display. Valid values are [author,authorEmail,createTime,humanId,id,labels,shortId,status,title,actors,participants]")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user