Merge pull request #26 from pwaller/fix-len

Fix LongestProcessName
This commit is contained in:
David Dollar
2014-06-02 11:14:43 -07:00
2 changed files with 12 additions and 4 deletions
+11 -3
View File
@@ -5,6 +5,7 @@ import (
"fmt"
_ "github.com/kr/pretty"
"io"
"math"
"os"
"regexp"
)
@@ -38,11 +39,18 @@ func (pf *Procfile) HasProcess(name string) (exists bool) {
return false
}
func (pf *Procfile) LongestProcessName() (longest int) {
func (pf *Procfile) LongestProcessName(concurrency map[string]int) (longest int) {
longest = 6 // length of forego
for _, entry := range pf.Entries {
if len(entry.Name) > longest {
longest = len(entry.Name)
thisLen := len(entry.Name)
// The "."
thisLen += 1
if c, ok := concurrency[entry.Name]; ok {
// Add the number of digits
thisLen += int(math.Log10(float64(c))) + 1
}
if thisLen > longest {
longest = thisLen
}
}
return
+1 -1
View File
@@ -191,7 +191,7 @@ func runStart(cmd *Command, args []string) {
handleError(err)
of := NewOutletFactory()
of.Padding = pf.LongestProcessName()
of.Padding = pf.LongestProcessName(concurrency)
f := &Forego{
outletFactory: of,