setActive writes the new active profile to disk, then asks the app to reload.
(name string)
| 159 | |
| 160 | // setActive writes the new active profile to disk, then asks the app to reload. |
| 161 | func (m profilesModel) setActive(name string) tea.Cmd { |
| 162 | cfg := m.app.cfg |
| 163 | if cfg == nil { |
| 164 | return setStatus("no config loaded") |
| 165 | } |
| 166 | cfg.Active = name |
| 167 | return func() tea.Msg { |
| 168 | if err := writeYAML(m.app.opts.ConfigPath, cfg); err != nil { |
| 169 | return statusMsg(fmt.Sprintf("write failed: %v", err)) |
| 170 | } |
| 171 | return tea.Sequence( |
| 172 | setStatus("active profile set to %q", name), |
| 173 | func() tea.Msg { return configReloadMsg{} }, |
| 174 | )() |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | // editExternal opens the config file in $EDITOR and returns control to the |
| 179 | // TUI after the editor exits. On Windows we fall back to notepad. |