Unverified Commit 046d2e06 authored by Silvano Cerza's avatar Silvano Cerza Committed by GitHub

Add Description field to lib list output (#845)

* Add Description field to lib list output

* [skip changelog] Fix lib list output

Output columns are now smaller, sentence is cut if too long and renamed
Sentence column to Description.

* [skip changelog] Fixed lib list output on Windows
parent e2af8d57
......@@ -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)
}
}
......
......@@ -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")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment