fix: pass config file flag to add/edit commands

This commit is contained in:
Gu1llaum-3 2025-09-03 08:33:07 +02:00
parent adde6eb666
commit 959c084466
5 changed files with 7 additions and 7 deletions

View File

@ -18,7 +18,7 @@ var addCmd = &cobra.Command{
hostname = args[0]
}
err := ui.RunAddForm(hostname)
err := ui.RunAddForm(hostname, configFile)
if err != nil {
fmt.Printf("Error adding host: %v\n", err)
}

View File

@ -15,7 +15,7 @@ var editCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
hostname := args[0]
err := ui.RunEditForm(hostname)
err := ui.RunEditForm(hostname, configFile)
if err != nil {
fmt.Printf("Error editing host: %v\n", err)
}

View File

@ -59,7 +59,7 @@ func runInteractiveMode() {
var response string
_, err := fmt.Scanln(&response)
if err == nil && (response == "y" || response == "Y") {
err := ui.RunAddForm("")
err := ui.RunAddForm("", configFile)
if err != nil {
fmt.Printf("Error adding host: %v\n", err)
}

View File

@ -270,9 +270,9 @@ func (m standaloneAddForm) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
// RunAddForm provides backward compatibility for standalone add form
func RunAddForm(hostname string) error {
func RunAddForm(hostname string, configFile string) error {
styles := NewStyles(80)
addForm := NewAddForm(hostname, styles, 80, 24, "")
addForm := NewAddForm(hostname, styles, 80, 24, configFile)
m := standaloneAddForm{addForm}
p := tea.NewProgram(m, tea.WithAltScreen())

View File

@ -258,9 +258,9 @@ func (m standaloneEditForm) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
// RunEditForm provides backward compatibility for standalone edit form
func RunEditForm(hostName string) error {
func RunEditForm(hostName string, configFile string) error {
styles := NewStyles(80)
editForm, err := NewEditForm(hostName, styles, 80, 24, "")
editForm, err := NewEditForm(hostName, styles, 80, 24, configFile)
if err != nil {
return err
}