Skip to content

Commit

Permalink
exec shell handler for services panel
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed May 19, 2022
1 parent 3abff08 commit 14af9f4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/gui/containers_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,11 @@ func (gui *Gui) handleContainersExecShell(g *gocui.Gui, v *gocui.View) error {
if err != nil {
return nil
}

return gui.containerExecShell(container)
}

func (gui *Gui) containerExecShell(container *commands.Container) error {
commandObject := gui.DockerCommand.NewCommandObject(commands.CommandObject{
Container: container,
})
Expand Down
7 changes: 7 additions & 0 deletions pkg/gui/keybindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.handleServicesBulkCommand,
Description: gui.Tr.ViewBulkCommands,
},
{
ViewName: "services",
Key: 'E',
Modifier: gocui.ModNone,
Handler: gui.handleServicesExecShell,
Description: gui.Tr.ExecShell,
},
{
ViewName: "services",
Key: 'w',
Expand Down
14 changes: 14 additions & 0 deletions pkg/gui/services_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,20 @@ func (gui *Gui) handleServicesBulkCommand(g *gocui.Gui, v *gocui.View) error {
return gui.createBulkCommandMenu(bulkCommands, commandObject)
}

func (gui *Gui) handleServicesExecShell(g *gocui.Gui, v *gocui.View) error {
service, err := gui.getSelectedService()
if err != nil {
return nil
}

container := service.Container
if container == nil {
return gui.createErrorPanel(gui.g, gui.Tr.NoContainers)
}

return gui.containerExecShell(container)
}

func (gui *Gui) handleServicesOpenInBrowserCommand(g *gocui.Gui, v *gocui.View) error {
service, err := gui.getSelectedService()
if err != nil {
Expand Down

0 comments on commit 14af9f4

Please sign in to comment.