Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions internal/ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,28 @@ type App struct {
pendingInput *output.UserInputRequestEvent
err error
quitting bool
hideHeader bool
}

func NewApp(version, emulatorName, endpoint string, cancel func()) App {
return App{
type AppOption func(*App)

var WithoutHeader AppOption = func(a *App) {
a.hideHeader = true
}

func NewApp(version, emulatorName, endpoint string, cancel func(), opts ...AppOption) App {
app := App{
header: components.NewHeader(version, emulatorName, endpoint),
inputPrompt: components.NewInputPrompt(),
spinner: components.NewSpinner(),
errorDisplay: components.NewErrorDisplay(),
lines: make([]styledLine, 0, maxLines),
cancel: cancel,
}
for _, opt := range opts {
opt(&app)
}
return app
}

func (a App) Init() tea.Cmd {
Expand Down Expand Up @@ -269,8 +280,10 @@ func hyperlink(url, displayText string) string {

func (a App) View() string {
var sb strings.Builder
sb.WriteString(a.header.View())
sb.WriteString("\n")
if !a.hideHeader {
sb.WriteString(a.header.View())
sb.WriteString("\n")
}

indent := strings.Repeat(" ", lineIndent)
contentWidth := a.width - lineIndent
Expand Down
3 changes: 2 additions & 1 deletion internal/ui/run_logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ func RunLogout(parentCtx context.Context) error {
_, cancel := context.WithCancel(parentCtx)
defer cancel()

app := NewApp("", "", "", cancel)
app := NewApp("", "", "", cancel, WithoutHeader)

p := tea.NewProgram(app, tea.WithInput(os.Stdin), tea.WithOutput(os.Stdout))
runErrCh := make(chan error, 1)

Expand Down