You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2017/03/06 21:16:56 UTC

[22/50] [abbrv] incubator-mynewt-newt git commit: newt: limit output width in size command to 80 columns

newt: limit output width in size command to 80 columns


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/a986f673
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/a986f673
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/a986f673

Branch: refs/heads/master
Commit: a986f673824155e517496138290f256d6e54e5aa
Parents: 8728a73
Author: Micha\u0142 Narajowski <mi...@codecoup.pl>
Authored: Mon Feb 27 12:00:08 2017 +0100
Committer: Micha\u0142 Narajowski <mi...@codecoup.pl>
Committed: Mon Feb 27 12:05:56 2017 +0100

----------------------------------------------------------------------
 newt/builder/symbol_tree.go | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a986f673/newt/builder/symbol_tree.go
----------------------------------------------------------------------
diff --git a/newt/builder/symbol_tree.go b/newt/builder/symbol_tree.go
index ea6202b..2318da1 100644
--- a/newt/builder/symbol_tree.go
+++ b/newt/builder/symbol_tree.go
@@ -127,6 +127,8 @@ func (f *Folder) addSymbol(symbol *Symbol, path string) *Symbol {
 	return sym
 }
 
+var outputFormatting string = "%-59s %9d %8.2f%%\n"
+
 func (f *File) String(indent string, level int, total uint64) string {
 	var str string
 	if f.sumSize() <= 0 {
@@ -134,7 +136,7 @@ func (f *File) String(indent string, level int, total uint64) string {
 	}
 	size := f.sumSize()
 	percent := 100 * float64(size) / float64(total)
-	str += fmt.Sprintf("%-80s %20d %8.2f%%\n", strings.Repeat(indent, level)+
+	str += fmt.Sprintf(outputFormatting, strings.Repeat(indent, level)+
 		f.Name, size, percent)
 
 	var sorted []string
@@ -146,9 +148,8 @@ func (f *File) String(indent string, level int, total uint64) string {
 		size := f.Symbols[sym].Size
 		percent := 100 * float64(size) / float64(total)
 		if f.Symbols[sym].Size > 0 {
-			str += fmt.Sprintf("%-80s %20d %8.2f%%\n",
-				strings.Repeat(indent, level+1)+
-					f.Symbols[sym].Name,
+			str += fmt.Sprintf(outputFormatting,
+				strings.Repeat(indent, level+1)+ f.Symbols[sym].Name,
 				size, percent)
 		}
 	}
@@ -171,7 +172,7 @@ func (f *Folder) StringRec(indent string, level int, total uint64) string {
 		if folder, ok := f.Folders[name]; ok {
 			size := folder.sumSize()
 			percent := 100 * float64(size) / float64(total)
-			str += fmt.Sprintf("%-80s %20d %8.2f%%\n",
+			str += fmt.Sprintf(outputFormatting,
 				strings.Repeat(indent, level)+folder.Name, size, percent)
 			str += folder.StringRec(indent, level+1, total)
 		} else {
@@ -184,11 +185,11 @@ func (f *Folder) StringRec(indent string, level int, total uint64) string {
 func (f *Folder) ToString(total uint64) string {
 	indent := "  "
 	var str string
-	str += fmt.Sprintf("%-90s %10s %9s\n", "Path", "Size", "%")
-	str += strings.Repeat("=", 111) + "\n"
+	str += fmt.Sprintf("%-59s %9s %9s\n", "Path", "Size", "%")
+	str += strings.Repeat("=", 79) + "\n"
 	str += f.StringRec(indent, 0, total)
-	str += strings.Repeat("=", 111) + "\n"
-	str += fmt.Sprintf("%90s %10d\n",
-		"Total symbol size (i.e. excluding padding, etc.)", f.sumSize())
+	str += strings.Repeat("=", 79) + "\n"
+	str += fmt.Sprintf("%-59s %9d %9s\n",
+		"Total symbol size (i.e. excluding padding, etc.)", f.sumSize(), "")
 	return str
 }