mirror of
https://github.com/skoelle/kctl-tui.git
synced 2026-09-17 20:10:24 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb4c1be12b | ||
|
|
9e3fefb71a |
+14
-2
@@ -8,6 +8,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -61,6 +62,11 @@ type panelModel struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isWtMode returns true when running on Windows with multiplexer: "wt".
|
||||||
|
func (m *panelModel) isWtMode() bool {
|
||||||
|
return runtime.GOOS == "windows" && m.cfg.MultiplexerBackend() == "wt"
|
||||||
|
}
|
||||||
|
|
||||||
func runPanel(args []string) error {
|
func runPanel(args []string) error {
|
||||||
fs := flag.NewFlagSet("panel", flag.ContinueOnError)
|
fs := flag.NewFlagSet("panel", flag.ContinueOnError)
|
||||||
context := fs.String("context", "", "context (e.g. internal/external)")
|
context := fs.String("context", "", "context (e.g. internal/external)")
|
||||||
@@ -99,7 +105,9 @@ func newPanelModel(context, ns, team string) *panelModel {
|
|||||||
|
|
||||||
func (m *panelModel) showEnvMenu() {
|
func (m *panelModel) showEnvMenu() {
|
||||||
items := make([]list.Item, 0, len(m.cfg.Envs)+1)
|
items := make([]list.Item, 0, len(m.cfg.Envs)+1)
|
||||||
items = append(items, simpleItem{label: "Quit (closes this tmux session)", value: "quit"})
|
if !m.isWtMode() {
|
||||||
|
items = append(items, simpleItem{label: "Quit (closes this tmux session)", value: "quit"})
|
||||||
|
}
|
||||||
for _, env := range m.cfg.Envs {
|
for _, env := range m.cfg.Envs {
|
||||||
items = append(items, simpleItem{label: env, value: env})
|
items = append(items, simpleItem{label: env, value: env})
|
||||||
}
|
}
|
||||||
@@ -179,10 +187,14 @@ func (m *panelModel) usesTextInput() bool {
|
|||||||
// handleEsc navigates one level up: action menu -> env menu, most
|
// handleEsc navigates one level up: action menu -> env menu, most
|
||||||
// sub-steps -> action menu. From the top-level env menu it closes the
|
// sub-steps -> action menu. From the top-level env menu it closes the
|
||||||
// whole tmux session (all panes, including the two k9s status panes)
|
// whole tmux session (all panes, including the two k9s status panes)
|
||||||
// before quitting this program, per SPEC.md 3.6.
|
// before quitting this program, per SPEC.md 3.6. In wt mode, Esc on
|
||||||
|
// the env menu does nothing — the user closes the wt window manually.
|
||||||
func (m *panelModel) handleEsc() (tea.Model, tea.Cmd) {
|
func (m *panelModel) handleEsc() (tea.Model, tea.Cmd) {
|
||||||
switch m.step {
|
switch m.step {
|
||||||
case stepEnvMenu:
|
case stepEnvMenu:
|
||||||
|
if m.isWtMode() {
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
exec.Command("tmux", "kill-session", "-t", "kctl").Run()
|
exec.Command("tmux", "kill-session", "-t", "kctl").Run()
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
case stepActionMenu:
|
case stepActionMenu:
|
||||||
|
|||||||
Reference in New Issue
Block a user