feat: add pre_connect hook and optional shortcut alias display
- ssh.pre_connect: local shell command run before every connection, layered like proxy_jump (global, instance/static host, rules; "none" disables). Host details are passed as NETSSH_* env vars, a non-zero exit aborts the connection, --dry-run only prints it. - shortcuts.show: show shortcut aliases in the TUI host list, an ALIAS column in `cache list` / `hosts list` (also via --aliases) and in Tab completion. - Both editable in `netssh configure`; README and CHANGELOG updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAuVpPncumMViLLc8N4
This commit is contained in:
1 parent
3804c33669
commit
419c682a71
15 files changed
+507
-23
No files matched your search
@@ -166,3 +166,30 @@ func TestHiddenPrefixDuplicateLabels(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAliasesShownNextToHostName(t *testing.T) {
|
||||
m := New(nil, cache.New("", 3600), "")
|
||||
m.SetAliases(func(target string) string {
|
||||
return map[string]string{"fsn1-bx1.hoster.de": "fsnbx1", "web01": "web01"}[target]
|
||||
})
|
||||
m.updateListItems([]netbox.HostEntry{{Name: "fsn1-bx1.hoster.de", PrimaryIP4: "10.0.0.1"}, {Name: "web01", PrimaryIP4: "10.0.0.2"}})
|
||||
items := m.list.Items()
|
||||
if got := items[0].(hostItem).alias; got != "fsnbx1" {
|
||||
t.Fatalf("alias = %q", got)
|
||||
}
|
||||
// An alias equal to the shown name is not repeated.
|
||||
if got := items[1].(hostItem).alias; got != "" {
|
||||
t.Fatalf("redundant alias %q", got)
|
||||
}
|
||||
var b strings.Builder
|
||||
compactDelegate{marked: map[string]bool{}}.Render(&b, m.list, 1, items[0])
|
||||
if !strings.Contains(b.String(), "fsn1-bx1.hoster.de") || !strings.Contains(b.String(), "→ fsnbx1") {
|
||||
t.Fatalf("row %q", b.String())
|
||||
}
|
||||
// Without SetAliases nothing changes.
|
||||
plain := New(nil, cache.New("", 3600), "")
|
||||
plain.updateListItems([]netbox.HostEntry{{Name: "fsn1-bx1.hoster.de"}})
|
||||
if got := plain.list.Items()[0].(hostItem).alias; got != "" {
|
||||
t.Fatalf("alias without SetAliases: %q", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user