The plans verb: what the last merges produced and where each stands (hq ADR 0162)
The mesh's seat answers plans — the recent plans with their tier, what each waits for and since when, or one plan whole given its id — so the console reads a merge's progress where it reads everything else, instead of a person reading the daemon's log.
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -524,3 +525,63 @@ func openPlans(plans []inventory.Plan) ([]inventory.Plan, int) {
|
||||
}
|
||||
return open, late
|
||||
}
|
||||
|
||||
|
||||
// plansCommand says what the last merges produced and where each stands; given an id, one plan
|
||||
// tier by tier with every module's state.
|
||||
func plansCommand(ctx context.Context, args []string) error {
|
||||
set := flag.NewFlagSet("plans", flag.ContinueOnError)
|
||||
limit := set.Int("n", 10, "how many to show")
|
||||
positionals, err := parseAround(set, args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
open, err := openStores(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer open.Close()
|
||||
inv := open.inventory
|
||||
now := time.Now()
|
||||
if len(positionals) == 1 {
|
||||
p, err := inv.PlanByID(ctx, positionals[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("%s — %s\n", p.ID, planLine(p, now))
|
||||
for i, tier := range p.Tiers {
|
||||
marker := " "
|
||||
if i == p.Tier && p.Open() {
|
||||
marker = ">"
|
||||
}
|
||||
fmt.Printf("%s tier %d\n", marker, i)
|
||||
for _, m := range tier {
|
||||
s := p.Modules[m]
|
||||
state := "not yet asked"
|
||||
if s != nil && s.State != "" {
|
||||
state = s.State
|
||||
if s.Commit != "" {
|
||||
state += " from " + short(s.Commit)
|
||||
}
|
||||
if s.Why != "" {
|
||||
state += ": " + s.Why
|
||||
}
|
||||
}
|
||||
fmt.Printf(" %-22s %s\n", m, state)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
plans, err := inv.RecentPlans(ctx, *limit)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(plans) == 0 {
|
||||
fmt.Println("no merge has produced a plan yet")
|
||||
return nil
|
||||
}
|
||||
for _, p := range plans {
|
||||
fmt.Printf("%-28s %s\n", p.ID, planLine(p, now))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user