-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
69 additions
and
193 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package formatter | ||
|
||
// PrintTableHeaders prints table headers with padding based on their length. | ||
func (f *Formatter) PrintTableHeaders(headers []string) { | ||
switch len(headers) { | ||
case 4: | ||
f.cmd.Printf("%-20s %-15s %-15s %-20s\n", | ||
headers[0], | ||
headers[1], | ||
headers[2], | ||
headers[3], | ||
) | ||
case 5: | ||
f.cmd.Printf("%-15s %-10s %-20s %-15s %-10s\n", | ||
headers[0], | ||
headers[1], | ||
headers[2], | ||
headers[3], | ||
headers[4], | ||
) | ||
default: | ||
f.cmd.Println("Error: Unsupported number of headers.") | ||
} | ||
} | ||
|
||
// PrintTableRow prints a single row with padding matching the header format. | ||
func (f *Formatter) PrintTableRow(row []string) { | ||
switch len(row) { | ||
case 4: | ||
f.cmd.Printf("%-20s %-15s %-15s %-20s\n", | ||
row[0], | ||
row[1], | ||
row[2], | ||
row[3], | ||
) | ||
case 5: | ||
f.cmd.Printf("%-15s %-10s %-20s %-15s %-10s\n", | ||
row[0], | ||
row[1], | ||
row[2], | ||
row[3], | ||
row[4], | ||
) | ||
default: | ||
f.cmd.Println("Error: Unsupported number of columns in row.") | ||
} | ||
} |