aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-04-05 19:04:13 +0200
committerGitHub <noreply@github.com>2019-04-05 19:04:13 +0200
commit30efc99f4493f3a09e94bf322cbf8ef844beea13 (patch)
treed7f5eb05530ac5664fab840f9c56e497fac43233
parent16d2b92f0558184dde4151e96addaa621f51ac13 (diff)
parent14ce66f0dde4345e6b08f528aa435196d132e2b8 (diff)
downloadgit-bug-30efc99f4493f3a09e94bf322cbf8ef844beea13.tar.gz
Merge pull request #122 from A-Hilaly/command-ls-show
integrate actors and participant filters into ls and show commands
-rw-r--r--commands/ls.go30
-rw-r--r--commands/show.go41
2 files changed, 57 insertions, 14 deletions
diff --git a/commands/ls.go b/commands/ls.go
index 75819f1a..ca74cc46 100644
--- a/commands/ls.go
+++ b/commands/ls.go
@@ -11,13 +11,15 @@ import (
)
var (
- lsStatusQuery []string
- lsAuthorQuery []string
- lsTitleQuery []string
- lsLabelQuery []string
- lsNoQuery []string
- lsSortBy string
- lsSortDirection string
+ lsStatusQuery []string
+ lsAuthorQuery []string
+ lsParticipantQuery []string
+ lsLabelQuery []string
+ lsTitleQuery []string
+ lsActorQuery []string
+ lsNoQuery []string
+ lsSortBy string
+ lsSortDirection string
)
func runLsBug(cmd *cobra.Command, args []string) error {
@@ -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,
diff --git a/commands/show.go b/commands/show.go
index f7f8ecd5..41dc5851 100644
--- a/commands/show.go
+++ b/commands/show.go
@@ -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]")
}