Repositories

This change also adds a "-a" flag to the list command, for keeping the closed reviews in the output.

Modified commands/list.go

@@ -17,16 +17,30 @@ limitations under the License.
package commands
import (
"flag"
"fmt"
"github.com/google/git-appraise/repository"
"github.com/google/git-appraise/review"
)
var listFlagSet = flag.NewFlagSet("list", flag.ExitOnError)
var (
listAll = listFlagSet.Bool("a", false, "List all reviews (not just the open ones).")
)
// listReviews lists all extant reviews.
// TODO(ojarjur): Add flags for filtering the output (e.g. to just open reviews).
// TODO(ojarjur): Add more flags for filtering the output (e.g. filtering by reviewer or status).
func listReviews(repo repository.Repo, args []string) {
reviews := review.ListAll(repo)
fmt.Printf("Loaded %d reviews:\n", len(reviews))
listFlagSet.Parse(args)
var reviews []review.Review
if *listAll {
reviews = review.ListAll(repo)
fmt.Printf("Loaded %d reviews:\n", len(reviews))
} else {
reviews = review.ListOpen(repo)
fmt.Printf("Loaded %d open reviews:\n", len(reviews))
}
for _, r := range reviews {
r.PrintSummary()
}