From 4df785087ad2bd264379f74fd900150dfe98b515 Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Mon, 20 Jul 2020 15:41:03 +0200 Subject: [PATCH 1/3] Add Sentence field to lib list output --- cli/lib/list.go | 13 ++++++++----- test/test_lib.py | 6 +++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cli/lib/list.go b/cli/lib/list.go index 80eeb566ffb..a8e67563056 100644 --- a/cli/lib/list.go +++ b/cli/lib/list.go @@ -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 { @@ -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) } } diff --git a/test/test_lib.py b/test/test_lib.py index 457b2eb883f..5766bc22beb 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 for Arduino." == toks[4] # Look at the JSON output result = run_command("lib list --format json") From 06bcd3fa975d7525033a89d7e3e327a0a15e41d6 Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Tue, 21 Jul 2020 12:13:57 +0200 Subject: [PATCH 2/3] [skip changelog] Fix lib list output Output columns are now smaller, sentence is cut if too long and renamed Sentence column to Description. --- cli/lib/list.go | 8 +++++++- test/test_lib.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cli/lib/list.go b/cli/lib/list.go index a8e67563056..c25c368aa1c 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", "Sentence") + 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 { @@ -115,7 +118,10 @@ func (ir installedResult) String() string { sentence := lib.Sentence if sentence == "" { sentence = "-" + } else if len(sentence) > 40 { + sentence = sentence[:39] + "…" } + t.AddRow(name, lib.Version, available, location, sentence) } } diff --git a/test/test_lib.py b/test/test_lib.py index 5766bc22beb..e7d0c548792 100644 --- a/test/test_lib.py +++ b/test/test_lib.py @@ -46,7 +46,7 @@ def test_list(run_command): assert "" != toks[1] assert "" != toks[2] # Verifies library sentence - assert "An efficient and elegant JSON library for Arduino." == toks[4] + assert "An efficient and elegant JSON library f…" == toks[4] # Look at the JSON output result = run_command("lib list --format json") From 547b107bd1e9e198bfe8f093fa1d9415f1ba1c88 Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Tue, 21 Jul 2020 12:52:57 +0200 Subject: [PATCH 3/3] [skip changelog] Fixed lib list output on Windows --- cli/lib/list.go | 2 +- test/test_lib.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/lib/list.go b/cli/lib/list.go index c25c368aa1c..01426734827 100644 --- a/cli/lib/list.go +++ b/cli/lib/list.go @@ -119,7 +119,7 @@ func (ir installedResult) String() string { if sentence == "" { sentence = "-" } else if len(sentence) > 40 { - sentence = sentence[:39] + "…" + sentence = sentence[:37] + "..." } t.AddRow(name, lib.Version, available, location, sentence) diff --git a/test/test_lib.py b/test/test_lib.py index e7d0c548792..e088076ddd1 100644 --- a/test/test_lib.py +++ b/test/test_lib.py @@ -46,7 +46,7 @@ def test_list(run_command): assert "" != toks[1] assert "" != toks[2] # Verifies library sentence - assert "An efficient and elegant JSON library f…" == toks[4] + assert "An efficient and elegant JSON library..." == toks[4] # Look at the JSON output result = run_command("lib list --format json")