diff --git a/internal/ui/app.go b/internal/ui/app.go index 77e1b92..8af26e5 100644 --- a/internal/ui/app.go +++ b/internal/ui/app.go @@ -38,10 +38,17 @@ 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(), @@ -49,6 +56,10 @@ func NewApp(version, emulatorName, endpoint string, cancel func()) App { lines: make([]styledLine, 0, maxLines), cancel: cancel, } + for _, opt := range opts { + opt(&app) + } + return app } func (a App) Init() tea.Cmd { @@ -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 diff --git a/internal/ui/run_logout.go b/internal/ui/run_logout.go index 30f7d5e..3dac9be 100644 --- a/internal/ui/run_logout.go +++ b/internal/ui/run_logout.go @@ -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)