Add --help, use os.Executable() for panel path, improve usage text

This commit is contained in:
2026-08-09 20:29:55 +02:00
parent 697017e496
commit e36ac3568f
3 changed files with 38 additions and 1 deletions
+1
View File
@@ -203,6 +203,7 @@ ln -s /mnt/c/Users/<your-windows-username>/.kube/config ~/.kube/config
```bash ```bash
kctl-tui # start the TUI (full navigation mode) kctl-tui # start the TUI (full navigation mode)
kctl-tui --help # show all commands and flags
kctl-tui --version # print version kctl-tui --version # print version
kctl-tui --verbose # enable debug logging to stderr kctl-tui --verbose # enable debug logging to stderr
kctl-tui doctor # check if all tools, config and connections are OK kctl-tui doctor # check if all tools, config and connections are OK
+5 -1
View File
@@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"os"
"os/exec" "os/exec"
"sort" "sort"
@@ -265,7 +266,10 @@ func (m *fullModel) loadNamespacesFor(teamValue string) tea.Cmd {
// configured envs, resolved via the context template, so both are // configured envs, resolved via the context template, so both are
// visible side by side. // visible side by side.
func (m *fullModel) startTmuxSession() tea.Cmd { func (m *fullModel) startTmuxSession() tea.Cmd {
selfPath := "kctl-tui" selfPath, err := os.Executable()
if err != nil {
selfPath = "kctl-tui" // fallback to PATH lookup
}
panelCmd := fmt.Sprintf("%s panel --context=%s --ns=%s --team=%s", panelCmd := fmt.Sprintf("%s panel --context=%s --ns=%s --team=%s",
selfPath, m.selectedContext, m.selectedNamespace, m.selectedTeam) selfPath, m.selectedContext, m.selectedNamespace, m.selectedTeam)
+32
View File
@@ -18,6 +18,7 @@ func main() {
// Extract global flags before delegating to sub-commands. // Extract global flags before delegating to sub-commands.
verbose := false verbose := false
showHelp := false
filtered := make([]string, 0, len(args)) filtered := make([]string, 0, len(args))
for _, a := range args { for _, a := range args {
switch a { switch a {
@@ -26,6 +27,8 @@ func main() {
case "--version", "-v": case "--version", "-v":
fmt.Printf("kctl-tui %s\n", version) fmt.Printf("kctl-tui %s\n", version)
return return
case "--help", "-h":
showHelp = true
default: default:
filtered = append(filtered, a) filtered = append(filtered, a)
} }
@@ -34,6 +37,13 @@ func main() {
kubeexec.SetVerbose(true, os.Stderr) kubeexec.SetVerbose(true, os.Stderr)
} }
if showHelp || len(filtered) == 0 {
printUsage()
if showHelp && len(filtered) == 0 {
return
}
}
if len(filtered) > 0 { if len(filtered) > 0 {
switch filtered[0] { switch filtered[0] {
case "panel": case "panel":
@@ -65,6 +75,28 @@ func main() {
} }
} }
func printUsage() {
fmt.Print(`kctl-tui — Kubernetes entry-point TUI
Usage:
kctl-tui [flags] start the TUI (full navigation mode)
kctl-tui doctor check tools, config and connections
kctl-tui config check validate ~/.kctl-tui/config.yaml
kctl-tui panel [options] control pane (called internally by tmux)
Flags:
--verbose log all kubectl/aws commands to stderr
--version print version
--help show this help
Examples:
kctl-tui # start the TUI
kctl-tui doctor # verify everything is installed
kctl-tui --verbose 2>debug.log # log commands to a file
kctl-tui config check # validate config
`)
}
func runConfig(args []string) error { func runConfig(args []string) error {
if len(args) == 0 || args[0] != "check" { if len(args) == 0 || args[0] != "check" {
return fmt.Errorf("usage: kctl-tui config check") return fmt.Errorf("usage: kctl-tui config check")