diff --git a/cli/lib/list.go b/cli/lib/list.go index 80eeb566ffb..01426734827 100644 --- a/cli/lib/list.go +++ b/cli/lib/list.go @@ -90,7 +90,10 @@ func (ir installedResult) String() string { } t := table.New() - t.SetHeader("Name", "Installed", "Available", "Location") + t.SetHeader("Name", "Installed", "Available", "Location", "Description") + t.SetColumnWidthMode(1, table.Average) + t.SetColumnWidthMode(2, table.Average) + t.SetColumnWidthMode(4, table.Average) lastName := "" for _, libMeta := range ir.installedLibs { @@ -109,11 +112,17 @@ func (ir installedResult) String() string { if libMeta.GetRelease() != nil { available := libMeta.GetRelease().GetVersion() - if available != "" { - t.AddRow(name, lib.Version, available, location) - } else { - t.AddRow(name, lib.Version, "-", location) + if available == "" { + available = "-" } + sentence := lib.Sentence + if sentence == "" { + sentence = "-" + } else if len(sentence) > 40 { + sentence = sentence[:37] + "..." + } + + t.AddRow(name, lib.Version, available, location, sentence) } } diff --git a/test/test_lib.py b/test/test_lib.py index 457b2eb883f..e088076ddd1 100644 --- a/test/test_lib.py +++ b/test/test_lib.py @@ -39,10 +39,14 @@ def test_list(run_command): assert "" == result.stderr lines = result.stdout.strip().splitlines() assert 2 == len(lines) - toks = [t.strip() for t in lines[1].split()] + toks = [t.strip() for t in lines[1].split(maxsplit=4)] + # Verifies the expected number of field + assert 5 == len(toks) # be sure line contain the current version AND the available version assert "" != toks[1] assert "" != toks[2] + # Verifies library sentence + assert "An efficient and elegant JSON library..." == toks[4] # Look at the JSON output result = run_command("lib list --format json")