package forgepb import ( "fmt" "go.wit.com/log" ) // mostly just functions related to making STDOUT // more readable by us humans // also function shortcuts the do fixed limited formatting (it's like COBOL) // so reporting tables of the status of what droplets and hypervisors // are in text columns and rows that can be easily read in a terminal func standardHeader() string { return fmt.Sprintf("%-4s %-40s %s", "", "Path", "flags") } func (f *Forge) standardHeader(r *ForgeConfig) string { var flags string var readonly string if f.IsPrivate(r.GoPath) { flags += "(private) " } if f.IsFavorite(r.GoPath) { flags += "(favorite) " } if f.IsReadOnly(r.GoPath) { readonly = "" } else { readonly = "r/w" } return fmt.Sprintf("%-4s %-40s %s", readonly, r.GoPath, flags) } // print a human readable table to STDOUT func (f *Forge) ConfigPrintTable() { if f == nil { log.Info("WTF forge == nil") panic("WTF forge == nil") } log.Info(standardHeader()) loop := f.Config.SortByPath() for loop.Scan() { r := loop.Next() log.Info(f.standardHeader(r)) } }