feat(indicator): Make initialIndicator() take a job description
This commit is contained in:
		@ -10,6 +10,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Indicator struct {
 | 
					type Indicator struct {
 | 
				
			||||||
 | 
						text     string
 | 
				
			||||||
	spinner  spinner.Model
 | 
						spinner  spinner.Model
 | 
				
			||||||
	quitting bool
 | 
						quitting bool
 | 
				
			||||||
	err      error
 | 
						err      error
 | 
				
			||||||
@ -29,11 +30,11 @@ func (i IndicatorInfo) String() string {
 | 
				
			|||||||
	return fmt.Sprintf("%s %s", textStyle.Render(i.duration.String()), i.info)
 | 
						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.New()
 | 
				
			||||||
	s.Spinner = spinner.Dot
 | 
						s.Spinner = spinner.Dot
 | 
				
			||||||
	s.Style = lipgloss.NewStyle().Foreground(colors.green)
 | 
						s.Style = lipgloss.NewStyle().Foreground(colors.green)
 | 
				
			||||||
	return Indicator{spinner: s}
 | 
						return Indicator{spinner: s, text: text}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
func (m Indicator) Init() tea.Cmd {
 | 
					func (m Indicator) Init() tea.Cmd {
 | 
				
			||||||
	return m.spinner.Tick
 | 
						return m.spinner.Tick
 | 
				
			||||||
@ -59,7 +60,7 @@ func (m Indicator) View() string {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	str := ""
 | 
						str := ""
 | 
				
			||||||
	if !m.quitting {
 | 
						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
 | 
						return str
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								times.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								times.go
									
									
									
									
									
								
							@ -98,7 +98,7 @@ func (m timesviewer) View() string {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func times() {
 | 
					func times() {
 | 
				
			||||||
	p := tea.NewProgram(initialIndicator())
 | 
						p := tea.NewProgram(initialIndicator("Fetching time logs..."))
 | 
				
			||||||
	go func() {
 | 
						go func() {
 | 
				
			||||||
		if _, err := p.Run(); err != nil {
 | 
							if _, err := p.Run(); err != nil {
 | 
				
			||||||
			fmt.Println(err)
 | 
								fmt.Println(err)
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user