mirror of
https://github.com/Valkyrie00/bold-brew.git
synced 2026-03-14 22:35:53 +01:00
update homebrew integration
This commit is contained in:
parent
0c4d572e0b
commit
cc482e388b
2 changed files with 25 additions and 1 deletions
|
|
@ -231,7 +231,7 @@ func (s *AppService) BuildApp() {
|
|||
SetTextAlign(tview.AlignCenter)
|
||||
|
||||
legend := tview.NewTextView().
|
||||
SetText(tview.Escape("[Up/Down] Navigate | [/] Search | [f] Filter Installed Only | [i] Install | [u] Update | [r] Remove | [Esc] Back to Table | [q] Quit")).
|
||||
SetText(tview.Escape("[/] Search | [f] Filter Installed | [i] Install | [u] Update | [r] Remove | [Esc] Back to Table | [ctrl+u] Update Homebrew | [q] Quit")).
|
||||
SetDynamicColors(true).
|
||||
SetTextAlign(tview.AlignCenter)
|
||||
|
||||
|
|
@ -406,6 +406,24 @@ func (s *AppService) handleKeyEventInput(event *tcell.EventKey) *tcell.EventKey
|
|||
s.table.ScrollToBeginning()
|
||||
return nil
|
||||
}
|
||||
case tcell.KeyCtrlU:
|
||||
// Update homebrew
|
||||
modal := s.createModal("Are you sure you want to update Homebrew?", func() {
|
||||
s.outputView.Clear()
|
||||
go func() {
|
||||
err := s.CommandService.UpdateHomebrew(s.app, s.outputView)
|
||||
if err != nil {
|
||||
s.app.QueueUpdateDraw(func() {
|
||||
errorModal := s.createModal(fmt.Sprintf("Failed to update Homebrew\nError: %v", err), nil)
|
||||
s.app.SetRoot(errorModal, true).SetFocus(errorModal)
|
||||
})
|
||||
} else {
|
||||
s.updateTableView()
|
||||
}
|
||||
}()
|
||||
})
|
||||
s.app.SetRoot(modal, true).SetFocus(modal)
|
||||
return nil
|
||||
case tcell.KeyEsc:
|
||||
// Remove the modal if it is currently displayed
|
||||
if s.currentModal != nil {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ type CommandServiceInterface interface {
|
|||
UpdatePackage(info models.Formula, app *tview.Application, outputView *tview.TextView) error
|
||||
RemovePackage(info models.Formula, app *tview.Application, outputView *tview.TextView) error
|
||||
InstallPackage(info models.Formula, app *tview.Application, outputView *tview.TextView) error
|
||||
UpdateHomebrew(app *tview.Application, outputView *tview.TextView) error
|
||||
}
|
||||
|
||||
type CommandService struct{}
|
||||
|
|
@ -34,6 +35,11 @@ func (s *CommandService) InstallPackage(info models.Formula, app *tview.Applicat
|
|||
return s.executeCommand(app, cmd, outputView)
|
||||
}
|
||||
|
||||
func (s *CommandService) UpdateHomebrew(app *tview.Application, outputView *tview.TextView) error {
|
||||
cmd := exec.Command("brew", "update")
|
||||
return s.executeCommand(app, cmd, outputView)
|
||||
}
|
||||
|
||||
func (s *CommandService) executeCommand(
|
||||
app *tview.Application,
|
||||
cmd *exec.Cmd,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue