Skip to content

Commit

Permalink
Return errMsg when config is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Sep 22, 2021
1 parent 6f287f0 commit 745ed4c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tui/bubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ type Bubble struct {
}

func NewBubble(cfg *Config, sCfg *SessionConfig) *Bubble {
var repoSource *git.RepoSource = nil
if cfg != nil {
repoSource = cfg.RepoSource
}
b := &Bubble{
config: cfg,
styles: style.DefaultStyles(),
width: sCfg.Width,
height: sCfg.Height,
repoSource: cfg.RepoSource,
repoSource: repoSource,
repoMenu: make([]MenuEntry, 0),
boxes: make([]tea.Model, 2),
initialRepo: sCfg.InitialRepo,
Expand Down Expand Up @@ -156,7 +160,11 @@ func (b *Bubble) viewForBox(i int) string {

func (b Bubble) headerView() string {
w := b.width - b.styles.App.GetHorizontalFrameSize()
return b.styles.Header.Copy().Width(w).Render(b.config.Name)
name := ""
if b.config != nil {
name = b.config.Name
}
return b.styles.Header.Copy().Width(w).Render(name)
}

func (b Bubble) footerView() string {
Expand Down
3 changes: 3 additions & 0 deletions tui/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ func (e errMsg) Error() string {
}

func (b *Bubble) setupCmd() tea.Msg {
if b.config == nil || b.config.RepoSource == nil {
return errMsg{err: fmt.Errorf("config not set")}
}
ct := time.Now()
lipgloss.SetColorProfile(termenv.ANSI256)
b.repos = b.repoSource.AllRepos()
Expand Down

0 comments on commit 745ed4c

Please sign in to comment.