feat: fix proxy compatibility and establish TUI foundation
This commit is contained in:
@@ -154,7 +154,7 @@ func runWithEnvironmentAndTargets(args []string, input io.Reader, output io.Writ
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
program := tea.NewProgram(tui.NewModel(application), tea.WithInput(input), tea.WithOutput(output))
|
||||
program := tea.NewProgram(tui.NewModel(application, tui.WithOutput(output)), tea.WithInput(input), tea.WithOutput(output), tea.WithAltScreen())
|
||||
_, err = program.Run()
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -71,6 +71,21 @@ func TestDefaultInvocationStartsTUIWithNoProfileState(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultInvocationUsesAlternateScreenAndRestoresItOnExit(t *testing.T) {
|
||||
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
||||
var output bytes.Buffer
|
||||
if err := runWithSystemTargets(nil, strings.NewReader("q"), &output, []target.Target{}); err != nil {
|
||||
t.Fatalf("run proxyctl: %v", err)
|
||||
}
|
||||
frame := output.String()
|
||||
if !strings.Contains(frame, "\x1b[?1049h") {
|
||||
t.Fatalf("default TUI did not enter the alternate screen: %q", frame)
|
||||
}
|
||||
if !strings.Contains(frame, "\x1b[?1049l") {
|
||||
t.Fatalf("default TUI did not restore the previous screen: %q", frame)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultInvocationLoadsPersistedActiveProfile(t *testing.T) {
|
||||
xdg := t.TempDir()
|
||||
t.Setenv("XDG_CONFIG_HOME", xdg)
|
||||
|
||||
Reference in New Issue
Block a user