diff options
author | Michael Muré <batolettre@gmail.com> | 2019-03-03 15:27:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-03 15:27:29 +0100 |
commit | fe8b0659c9bc1cb074a5acfbafcabd603e533f9f (patch) | |
tree | b3d8db1596b7347fdcf39cfdc9614a3c09464b36 /commands | |
parent | 7260ca05bc3588c0572887a7d8f1b897c7fc13da (diff) | |
parent | 408654514ea813933f45d383d949611d138084e1 (diff) | |
download | git-bug-fe8b0659c9bc1cb074a5acfbafcabd603e533f9f.tar.gz |
Merge pull request #100 from sladyn98/faster_ls
`git bug ls` should be faster
Diffstat (limited to 'commands')
-rw-r--r-- | commands/ls.go | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/commands/ls.go b/commands/ls.go index 75b7ceaf..75819f1a 100644 --- a/commands/ls.go +++ b/commands/ls.go @@ -5,7 +5,6 @@ import ( "strings" "github.com/MichaelMure/git-bug/cache" - "github.com/MichaelMure/git-bug/identity" "github.com/MichaelMure/git-bug/util/colors" "github.com/MichaelMure/git-bug/util/interrupt" "github.com/spf13/cobra" @@ -14,6 +13,7 @@ import ( var ( lsStatusQuery []string lsAuthorQuery []string + lsTitleQuery []string lsLabelQuery []string lsNoQuery []string lsSortBy string @@ -45,30 +45,22 @@ func runLsBug(cmd *cobra.Command, args []string) error { allIds := backend.QueryBugs(query) for _, id := range allIds { - b, err := backend.ResolveBug(id) + b, err := backend.ResolveBugExcerpt(id) if err != nil { return err } - snapshot := b.Snapshot() - - var author identity.Interface - - if len(snapshot.Comments) > 0 { - create := snapshot.Comments[0] - author = create.Author - } - // truncate + pad if needed - titleFmt := fmt.Sprintf("%-50.50s", snapshot.Title) - authorFmt := fmt.Sprintf("%-15.15s", author.DisplayName()) + titleFmt := fmt.Sprintf("%-50.50s", b.Title) + authorFmt := fmt.Sprintf("%-15.15s", b.LegacyAuthor.Name) - fmt.Printf("%s %s\t%s\t%s\t%s\n", + fmt.Printf("%s %s\t%s\t%s\tC:%d L:%d\n", colors.Cyan(b.HumanId()), - colors.Yellow(snapshot.Status), + colors.Yellow(b.Status), titleFmt, colors.Magenta(authorFmt), - snapshot.Summary(), + b.LenComments, + len(b.Labels), ) } @@ -87,6 +79,11 @@ func lsQueryFromFlags() (*cache.Query, error) { query.Status = append(query.Status, f) } + for _, title := range lsTitleQuery { + f := cache.TitleFilter(title) + query.Title = append(query.Title, f) + } + for _, author := range lsAuthorQuery { f := cache.AuthorFilter(author) query.Author = append(query.Author, f) @@ -156,6 +153,8 @@ func init() { "Filter by author") lsCmd.Flags().StringSliceVarP(&lsLabelQuery, "label", "l", nil, "Filter by label") + lsCmd.Flags().StringSliceVarP(&lsTitleQuery, "title", "t", nil, + "Filter by title") lsCmd.Flags().StringSliceVarP(&lsNoQuery, "no", "n", nil, "Filter by absence of something. Valid values are [label]") lsCmd.Flags().StringVarP(&lsSortBy, "by", "b", "creation", |