mirror of
https://github.com/Gu1llaum-3/sshm.git
synced 2026-01-27 03:04:21 +01:00
fix: enable editing and management of hosts from included SSH config files
• Add SourceFile field to SSHHost struct to track config file origins • Implement FindHostInAllConfigs() to locate hosts across all config files • Fix "host not found" errors when editing/deleting hosts from included files • Add GetAllConfigFiles() and GetAllConfigFilesFromBase() for config discovery • Create UpdateSSHHostV2() and DeleteSSHHostV2() for cross-file operations • Display config file source in edit and info forms for better visibility • Add intelligent file selector for host addition when multiple configs exist • Support -c parameter context with proper file resolution • Exclude .backup files from Include directive processing • Maintain backward compatibility with existing SSH config workflows Resolves limitation where hosts from included config files could be viewed but not edited, deleted, or properly managed through the interface.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/charmbracelet/bubbles/textinput"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
|
||||
type editFormModel struct {
|
||||
@@ -16,6 +17,7 @@ type editFormModel struct {
|
||||
success bool
|
||||
styles Styles
|
||||
originalName string
|
||||
host *config.SSHHost // Store the original host with SourceFile
|
||||
width int
|
||||
height int
|
||||
configFile string
|
||||
@@ -102,6 +104,7 @@ func NewEditForm(hostName string, styles Styles, width, height int, configFile s
|
||||
inputs: inputs,
|
||||
focused: nameInput,
|
||||
originalName: hostName,
|
||||
host: host,
|
||||
configFile: configFile,
|
||||
styles: styles,
|
||||
width: width,
|
||||
@@ -201,6 +204,24 @@ func (m *editFormModel) View() string {
|
||||
var b strings.Builder
|
||||
|
||||
b.WriteString(m.styles.FormTitle.Render("Edit SSH Host Configuration"))
|
||||
b.WriteString("\n")
|
||||
|
||||
// Show source file information
|
||||
if m.host != nil && m.host.SourceFile != "" {
|
||||
b.WriteString("\n") // Ligne d'espace avant Config file
|
||||
|
||||
// Style for "Config file:" label in primary color
|
||||
labelStyle := lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("#00ADD8")). // Primary color
|
||||
Bold(true)
|
||||
|
||||
// Style for the file path in white
|
||||
pathStyle := lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("#FFFFFF"))
|
||||
|
||||
configInfo := labelStyle.Render("Config file: ") + pathStyle.Render(formatConfigFile(m.host.SourceFile))
|
||||
b.WriteString(configInfo)
|
||||
}
|
||||
b.WriteString("\n\n")
|
||||
|
||||
fields := []string{
|
||||
|
||||
Reference in New Issue
Block a user