From 42679ee63b35dcdaa9e77e796fe6e081f05b7887 Mon Sep 17 00:00:00 2001 From: Noah Date: Sun, 17 Mar 2024 23:03:45 -0500 Subject: [PATCH] feat(indicator): Make initialIndicator() take a job description --- indicator.go | 7 ++++--- times.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/indicator.go b/indicator.go index e719d44..74d34c6 100644 --- a/indicator.go +++ b/indicator.go @@ -10,6 +10,7 @@ import ( ) type Indicator struct { + text string spinner spinner.Model quitting bool err error @@ -29,11 +30,11 @@ func (i IndicatorInfo) String() string { return fmt.Sprintf("%s %s", textStyle.Render(i.duration.String()), i.info) } -func initialIndicator() Indicator { +func initialIndicator(text string) Indicator { s := spinner.New() s.Spinner = spinner.Dot s.Style = lipgloss.NewStyle().Foreground(colors.green) - return Indicator{spinner: s} + return Indicator{spinner: s, text: text} } func (m Indicator) Init() tea.Cmd { return m.spinner.Tick @@ -59,7 +60,7 @@ func (m Indicator) View() string { } str := "" if !m.quitting { - str += fmt.Sprintf("\n %s Loading time logs...\n %s\n", m.spinner.View(), m.info.String()) + str += fmt.Sprintf("\n %s %s\n %s\n", m.spinner.View(), m.text, m.info.String()) } return str } diff --git a/times.go b/times.go index 01f8f39..4d19d33 100644 --- a/times.go +++ b/times.go @@ -98,7 +98,7 @@ func (m timesviewer) View() string { } func times() { - p := tea.NewProgram(initialIndicator()) + p := tea.NewProgram(initialIndicator("Fetching time logs...")) go func() { if _, err := p.Run(); err != nil { fmt.Println(err)