mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-21 23:01:03 +00:00
Initial working demo
Signed-off-by: Dowideit, Sven (O&A, St. Lucia) <Sven.Dowideit@csiro.au>
This commit is contained in:
parent
cca69e64f3
commit
cdf075b00d
5 changed files with 56 additions and 0 deletions
|
|
@ -51,6 +51,8 @@ type CommandObject struct {
|
|||
DockerCompose string
|
||||
Service *Service
|
||||
Container *Container
|
||||
Image *Image
|
||||
Volume *Volume
|
||||
}
|
||||
|
||||
// NewCommandObject takes a command object and returns a default command object with the passed command object merged in
|
||||
|
|
|
|||
|
|
@ -258,6 +258,12 @@ type CustomCommands struct {
|
|||
|
||||
// Services contains the custom commands for services
|
||||
Services []CustomCommand `yaml:"services,omitempty"`
|
||||
|
||||
// Services contains the custom commands for services
|
||||
Images []CustomCommand `yaml:"images,omitempty"`
|
||||
|
||||
// Services contains the custom commands for services
|
||||
Volumes []CustomCommand `yaml:"volumes,omitempty"`
|
||||
}
|
||||
|
||||
// CustomCommand is a template for a command we want to run against a service or
|
||||
|
|
@ -335,6 +341,8 @@ func GetDefaultConfig() UserConfig {
|
|||
},
|
||||
},
|
||||
Services: []CustomCommand{},
|
||||
Images: []CustomCommand{},
|
||||
Volumes: []CustomCommand{},
|
||||
},
|
||||
OS: GetPlatformDefaultConfig(),
|
||||
Update: UpdateConfig{
|
||||
|
|
|
|||
|
|
@ -259,3 +259,19 @@ func (gui *Gui) handlePruneImages(g *gocui.Gui, v *gocui.View) error {
|
|||
})
|
||||
}, nil)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleImagesCustomCommand(g *gocui.Gui, v *gocui.View) error {
|
||||
image, err := gui.getSelectedImage(g)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
commandObject := gui.DockerCommand.NewCommandObject(
|
||||
commands.CommandObject{
|
||||
Image: image,
|
||||
})
|
||||
|
||||
customCommands := gui.Config.UserConfig.CustomCommands.Images
|
||||
|
||||
return gui.createCustomCommandMenu(customCommands, commandObject)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -337,6 +337,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||
Handler: gui.handleImagesNextContext,
|
||||
Description: gui.Tr.NextContext,
|
||||
},
|
||||
{
|
||||
ViewName: "images",
|
||||
Key: 'c',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleImagesCustomCommand,
|
||||
Description: gui.Tr.RunCustomCommand,
|
||||
},
|
||||
{
|
||||
ViewName: "images",
|
||||
Key: 'd',
|
||||
|
|
@ -365,6 +372,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||
Handler: gui.handleVolumesNextContext,
|
||||
Description: gui.Tr.NextContext,
|
||||
},
|
||||
{
|
||||
ViewName: "volumes",
|
||||
Key: 'c',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleVolumesCustomCommand,
|
||||
Description: gui.Tr.RunCustomCommand,
|
||||
},
|
||||
{
|
||||
ViewName: "volumes",
|
||||
Key: 'd',
|
||||
|
|
|
|||
|
|
@ -250,3 +250,19 @@ func (gui *Gui) handlePruneVolumes(g *gocui.Gui, v *gocui.View) error {
|
|||
})
|
||||
}, nil)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleVolumesCustomCommand(g *gocui.Gui, v *gocui.View) error {
|
||||
volume, err := gui.getSelectedVolume()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
commandObject := gui.DockerCommand.NewCommandObject(
|
||||
commands.CommandObject{
|
||||
Volume: volume,
|
||||
})
|
||||
|
||||
customCommands := gui.Config.UserConfig.CustomCommands.Volumes
|
||||
|
||||
return gui.createCustomCommandMenu(customCommands, commandObject)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue