Skip to content

Add Sentence field to lib list output #845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions cli/lib/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (ir installedResult) String() string {
}

t := table.New()
t.SetHeader("Name", "Installed", "Available", "Location")
t.SetHeader("Name", "Installed", "Available", "Location", "Sentence")

lastName := ""
for _, libMeta := range ir.installedLibs {
Expand All @@ -109,11 +109,14 @@ 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 = "-"
}
t.AddRow(name, lib.Version, available, location, sentence)
}
}

Expand Down
6 changes: 5 additions & 1 deletion test/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 for Arduino." == toks[4]

# Look at the JSON output
result = run_command("lib list --format json")
Expand Down