Skip to content

Commit

Permalink
support deleting tarballs
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Apr 13, 2020
1 parent 4eb5532 commit acfded2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/gui/keybindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,12 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.wrappedDependencyHandler(gui.handleEditDepConstraint),
Description: "edit dependency constraint",
},
{
ViewName: "tarballs",
Key: gui.getKey("universal.remove"),
Handler: gui.wrappedTarballHandler(gui.handleDeleteTarball),
Description: "delete tarball",
},
}

for _, viewName := range []string{"status", "packages", "deps", "scripts", "tarballs", "menu"} {
Expand Down
14 changes: 14 additions & 0 deletions pkg/gui/tarballs_panel.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gui

import (
"fmt"

"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazynpm/pkg/commands"
"github.com/jesseduffield/lazynpm/pkg/gui/presentation"
Expand Down Expand Up @@ -45,3 +47,15 @@ func (gui *Gui) wrappedTarballHandler(f func(*commands.Tarball) error) func(*goc
return gui.finalStep(f(tarball))
})
}

func (gui *Gui) handleDeleteTarball(tarball *commands.Tarball) error {
return gui.createConfirmationPanel(createConfirmationPanelOpts{
returnToView: gui.getTarballsView(),
returnFocusOnClose: true,
title: "Remove tarball",
prompt: fmt.Sprintf("are you sure you want to delete `%s`?", tarball.Name),
handleConfirm: func() error {
return gui.finalStep(gui.OSCommand.Remove(tarball.Path))
},
})
}

0 comments on commit acfded2

Please # to comment.