Skip to content

Commit

Permalink
fix: tui initial repo
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Apr 7, 2022
1 parent bd4b435 commit edbcf6f
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions internal/tui/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,27 @@ package tui

import (
"fmt"
"net/url"
"strings"

tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/soft-serve/internal/config"
"github.com/gliderlabs/ssh"
)

// SessionHandler handles the bubble tea session.
func SessionHandler(cfg *config.Config) func(ssh.Session) (tea.Model, []tea.ProgramOption) {
return func(s ssh.Session) (tea.Model, []tea.ProgramOption) {
pty, _, active := s.Pty()
if !active {
fmt.Println("not active")
return nil, nil
}
cmd := s.Command()
scfg := &SessionConfig{Session: s}
switch len(cmd) {
case 0:
scfg.InitialRepo = ""
case 1:
p, err := url.Parse(cmd[0])
if err != nil || strings.Contains(p.Path, "/") {
return nil, nil
}
scfg.InitialRepo = cmd[0]
default:
return nil, nil
}
pty, _, active := s.Pty()
if !active {
fmt.Println("not active")
return nil, nil
}
scfg.Width = pty.Window.Width
scfg.Height = pty.Window.Height
Expand Down

0 comments on commit edbcf6f

Please sign in to comment.