Unverified Commit 210dda42 authored by MatteoPologruto's avatar MatteoPologruto Committed by GitHub

[skip-changelog] Eliminate empty lines produced by `board details -b` (#1997)

* Eliminate blank line between required tools row entries

* Fix Programmers ID typo and modify tests accordingly

* Reduce spacing between "Required tool" columns

Splitting the table produced by `board details` after `Platform checksum` resets both the average length and the variance of the following cells, thus reducing the space between entries.
parent 76ddec81
...@@ -109,6 +109,7 @@ func (dr detailsResult) String() string { ...@@ -109,6 +109,7 @@ func (dr detailsResult) String() string {
// ATmega328P (Old Bootloader) cpu=atmega328old // ATmega328P (Old Bootloader) cpu=atmega328old
// ATmega168 cpu=atmega168 // ATmega168 cpu=atmega168
t := table.New() t := table.New()
tab := table.New()
addIfNotEmpty := func(label, content string) { addIfNotEmpty := func(label, content string) {
if content != "" { if content != "" {
t.AddRow(label, content) t.AddRow(label, content)
...@@ -157,32 +158,34 @@ func (dr detailsResult) String() string { ...@@ -157,32 +158,34 @@ func (dr detailsResult) String() string {
addIfNotEmpty(tr("Platform checksum:"), details.Platform.Checksum) addIfNotEmpty(tr("Platform checksum:"), details.Platform.Checksum)
t.AddRow() // get some space from above t.AddRow() // get some space from above
tab.SetColumnWidthMode(1, table.Average)
for _, tool := range details.ToolsDependencies { for _, tool := range details.ToolsDependencies {
t.AddRow(tr("Required tool:"), tool.Packager+":"+tool.Name, tool.Version) tab.AddRow(tr("Required tool:"), tool.Packager+":"+tool.Name, tool.Version)
if showFullDetails { if showFullDetails {
for _, sys := range tool.Systems { for _, sys := range tool.Systems {
t.AddRow("", tr("OS:"), sys.Host) tab.AddRow("", tr("OS:"), sys.Host)
t.AddRow("", tr("File:"), sys.ArchiveFilename) tab.AddRow("", tr("File:"), sys.ArchiveFilename)
t.AddRow("", tr("Size (bytes):"), fmt.Sprint(sys.Size)) tab.AddRow("", tr("Size (bytes):"), fmt.Sprint(sys.Size))
t.AddRow("", tr("Checksum:"), sys.Checksum) tab.AddRow("", tr("Checksum:"), sys.Checksum)
t.AddRow("", tr("URL:"), sys.Url) tab.AddRow("", tr("URL:"), sys.Url)
t.AddRow() // get some space from above tab.AddRow() // get some space from above
} }
} }
t.AddRow() // get some space from above
} }
tab.AddRow() // get some space from above
for _, option := range details.ConfigOptions { for _, option := range details.ConfigOptions {
t.AddRow(tr("Option:"), option.OptionLabel, "", option.Option) tab.AddRow(tr("Option:"), option.OptionLabel, "", option.Option)
for _, value := range option.Values { for _, value := range option.Values {
green := color.New(color.FgGreen) green := color.New(color.FgGreen)
if value.Selected { if value.Selected {
t.AddRow("", tab.AddRow("",
table.NewCell(value.ValueLabel, green), table.NewCell(value.ValueLabel, green),
table.NewCell("✔", green), table.NewCell("✔", green),
table.NewCell(option.Option+"="+value.Value, green)) table.NewCell(option.Option+"="+value.Value, green))
} else { } else {
t.AddRow("", tab.AddRow("",
value.ValueLabel, value.ValueLabel,
"", "",
option.Option+"="+value.Value) option.Option+"="+value.Value)
...@@ -190,10 +193,10 @@ func (dr detailsResult) String() string { ...@@ -190,10 +193,10 @@ func (dr detailsResult) String() string {
} }
} }
t.AddRow(tr("Programmers:"), tr("Id"), tr("Name")) tab.AddRow(tr("Programmers:"), tr("ID"), tr("Name"))
for _, programmer := range details.Programmers { for _, programmer := range details.Programmers {
t.AddRow("", programmer.GetId(), programmer.GetName()) tab.AddRow("", programmer.GetId(), programmer.GetName())
} }
return t.Render() return t.Render() + tab.Render()
} }
...@@ -326,7 +326,7 @@ func TestBoardDetailsListProgrammersWithoutFlag(t *testing.T) { ...@@ -326,7 +326,7 @@ func TestBoardDetailsListProgrammersWithoutFlag(t *testing.T) {
for i, l := range split { for i, l := range split {
lines[i] = strings.Fields(l) lines[i] = strings.Fields(l)
} }
require.Contains(t, lines, []string{"Programmers:", "Id", "Name"}) require.Contains(t, lines, []string{"Programmers:", "ID", "Name"})
require.Contains(t, lines, []string{"edbg", "Atmel", "EDBG"}) require.Contains(t, lines, []string{"edbg", "Atmel", "EDBG"})
require.Contains(t, lines, []string{"atmel_ice", "Atmel-ICE"}) require.Contains(t, lines, []string{"atmel_ice", "Atmel-ICE"})
require.Contains(t, lines, []string{"sam_ice", "Atmel", "SAM-ICE"}) require.Contains(t, lines, []string{"sam_ice", "Atmel", "SAM-ICE"})
......
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