refactor: Make table.New generic
Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
This commit is contained in:
parent
9449cba68d
commit
ffe81b005d
4 changed files with 5 additions and 6 deletions
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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{}
|
||||
|
||||
|
|
Loading…
Reference in a new issue