diff --git a/cmd/forecast.go b/cmd/forecast.go index 5aacd29..8327a26 100644 --- a/cmd/forecast.go +++ b/cmd/forecast.go @@ -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 { diff --git a/cmd/internal/ui/table/table.go b/cmd/internal/ui/table/table.go index 31bb454..a519e3b 100644 --- a/cmd/internal/ui/table/table.go +++ b/cmd/internal/ui/table/table.go @@ -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 } diff --git a/cmd/today.go b/cmd/today.go index 7a7c80e..499cbf9 100644 --- a/cmd/today.go +++ b/cmd/today.go @@ -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 { diff --git a/cmd/tomorrow.go b/cmd/tomorrow.go index e3f8f8d..b29d5f4 100644 --- a/cmd/tomorrow.go +++ b/cmd/tomorrow.go @@ -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{}