feat(indicator): Make initialIndicator() take a job description

This commit is contained in:
Noah 2024-03-17 23:03:45 -05:00
parent 174dcb9706
commit 42679ee63b
2 changed files with 5 additions and 4 deletions

View File

@ -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
}

View File

@ -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)