mirror of
https://github.com/db9979/sshtermy.git
synced 2026-12-05 12:24:08 +01:00
- internal/cmdset: ein YAML-Satz pro Hersteller (48 eingebaut) mit Varianten, Erkennung, Befehlen, Lesemustern, Logs, Syslog, Gefahrenregeln, Beispielen - Neue Hersteller: Switches, Firewalls, WLAN-Controller, Appliances; Comware und Huawei vervollständigt - Eigene Sätze (basiert auf), Formular, Test am Gerät, KI-Entwurf, Korrekturen übernehmen, Export/Import, Team-Sätze mit Freigabe - Sicherheit: nur Lesebefehle, Gefahrenregeln nur ergänzbar, eingebaute Kennungen und Erkennung haben Vorrang, Syslog-Schritte geprüft, Grenzen, Selbsttest - Doku: README, Webseite, Kurzreferenz Claude-Session: https://claude.ai/code/session_018i4GUhVDoXMfSDNsb58H5M Co-authored-by: Claude <noreply@anthropic.com>
56 lines
1.8 KiB
Go
56 lines
1.8 KiB
Go
package ui
|
|
|
|
import (
|
|
"strings"
|
|
|
|
tea "charm.land/bubbletea/v2"
|
|
|
|
"github.com/db9979/sshtermy/internal/i18n"
|
|
)
|
|
|
|
// Wenn sshTermy selbst in eine Switch-Shell tippt (F6, Log-Blick, Syslog
|
|
// einrichten), nimmt der Tab keine Tasten und kein Einfügen an. Esc bricht
|
|
// die Folge ab. Sonst landete ein „no “ von dir vor „logging …“ im
|
|
// Konfigurationsmodus.
|
|
|
|
// shellBusyKey: Taste für einen Tab, in den sshTermy gerade tippt. true =
|
|
// verbraucht.
|
|
func (a *App) shellBusyKey(s *session, k tea.KeyPressMsg) bool {
|
|
if s == nil || !s.cap.active() {
|
|
return false
|
|
}
|
|
if k.String() == "esc" {
|
|
s.cap.abort()
|
|
a.flash(i18n.T("Abgebrochen. sshTermy tippt nichts mehr in diese Shell."))
|
|
return true
|
|
}
|
|
a.flash(i18n.T("sshTermy tippt gerade in diese Shell, deine Eingabe wartet nicht · Esc bricht ab"))
|
|
return true
|
|
}
|
|
|
|
// configPrompt: Prompt im Konfigurationsmodus (switch(config)#, [edit])?
|
|
// Abfragen und Einrichtung starten dort nicht: Befehle hätten eine andere
|
|
// Bedeutung oder änderten etwas.
|
|
func configPrompt(p string) bool {
|
|
l := strings.ToLower(strings.TrimSpace(p))
|
|
if strings.Contains(l, "(config") || strings.Contains(l, "[edit") {
|
|
return true
|
|
}
|
|
// Comware/Huawei: <Name> normal, [Name] bzw. [~Name] in der system-view
|
|
return strings.HasPrefix(l, "[") && strings.HasSuffix(l, "]") && !strings.ContainsAny(l, "@ ")
|
|
}
|
|
|
|
// cliError: meldet das Gerät einen Fehler in der Ausgabe?
|
|
func cliError(lines []string) string {
|
|
for _, l := range lines {
|
|
x := strings.ToLower(strings.TrimSpace(l))
|
|
for _, m := range []string{"invalid input", "unknown command", "invalid command", "incomplete command", "ambiguous",
|
|
"syntax error", "command fail", "error:", "bad command", "command parse error", "unrecognized command", "not found"} {
|
|
if strings.Contains(x, m) {
|
|
return strings.TrimSpace(l)
|
|
}
|
|
}
|
|
}
|
|
return ""
|
|
}
|