refactor: Make table.New generic

Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
This commit is contained in:
Tim Hårek Andreassen 2024-11-25 19:30:34 +01:00
parent 9449cba68d
commit ffe81b005d
No known key found for this signature in database
GPG key ID: E59C7734F0E10EB5
4 changed files with 5 additions and 6 deletions

View file

@ -39,7 +39,7 @@ func forecast(cmd *cobra.Command, args []string) {
outputJson(f.Forecast)
}
t := table.New()
t := table.New("time", "temp.", "rain", "wind")
for _, item := range f.Forecast {
if !isUTC {

View file

@ -7,8 +7,7 @@ import (
"github.com/charmbracelet/lipgloss/table"
)
// TODO: Make more generic
func New() *table.Table {
func New(headers ...string) *table.Table {
re := lipgloss.NewRenderer(os.Stdout)
const (
@ -51,6 +50,6 @@ func New() *table.Table {
return style
}).
Headers("time", "temp.", "rain", "wind")
Headers(headers...)
return t
}

View file

@ -30,7 +30,7 @@ func today(cmd *cobra.Command, args []string) {
outputJson(f.Forecast)
}
t := table.New()
t := table.New("time", "temp.", "rain", "wind")
today := time.Now()
for _, item := range f.Forecast {

View file

@ -36,7 +36,7 @@ func tomorrow(cmd *cobra.Command, args []string) {
os.Exit(0)
}
t := table.New()
t := table.New("time", "temp.", "rain", "wind")
tomorrows := []yr.Forecast{}