From 0974e603a77ed418af1bae6f85348d04a7c67b16 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Sauvage?=
+ e: modifier la configuration lazydocker
+ o: ouvrir la configuration lazydocker
+ [: onglet précédent
+ ]: onglet suivant
+ m: voir le journal
+ enter: mise au point sur le paneau principale
+
+
+## Conteneurs
+
+
+ [: onglet précédent
+ ]: onglet suivant
+ d: retirer
+ e: Cacher/Montrer les conteneurs arrêtés
+ s: arrêter
+ r: redémarrer
+ a: attacher
+ m: voir le journal
+ E: shell d'exécution
+ c: lancer une commande pérsonnalisée prédéfinie
+ b: voir les commandes groupés
+ w: ouvrir dans le navigateur (le premier port est http)
+ enter: mise au point sur le paneau principale
+
+
+## Services
+
+
+ d: retirer les conteneurs
+ s: arrêter
+ r: redémarrer
+ a: attacher
+ m: voir le journal
+ [: onglet précédent
+ ]: onglet suivant
+ R: voir les options de redémarrage
+ c: lancer une commande pérsonnalisée prédéfinie
+ b: voir les commandes groupés
+ w: ouvrir dans le navigateur (le premier port est http)
+ enter: mise au point sur le paneau principale
+
+
+## Images
+
+
+ [: onglet précédent
+ ]: onglet suivant
+ c: lancer une commande pérsonnalisée prédéfinie
+ d: retirer l'image
+ b: voir les commandes groupés
+ enter: mise au point sur le paneau principale
+
+
+## Volumes
+
+
+ [: onglet précédent
+ ]: onglet suivant
+ c: lancer une commande pérsonnalisée prédéfinie
+ d: retirer le volume
+ b: voir les commandes groupés
+ enter: mise au point sur le paneau principale
+
+
+## Principale
+
+
+ esc: retour
+
From ca0956137bc87a397b37cac566ee35e1bdadfe3c Mon Sep 17 00:00:00 2001
From: Clement Sauvage
- e: modifier la configuration lazydocker
- o: ouvrir la configuration lazydocker
- [: onglet précédent
- ]: onglet suivant
- m: voir le journal
- enter: mise au point sur le paneau principale
-
-
-## Conteneurs
-
-
- [: onglet précédent
- ]: onglet suivant
- d: retirer
- e: Cacher/Montrer les conteneurs arrêtés
- s: arrêter
- r: redémarrer
- a: attacher
- m: voir le journal
- E: shell d'exécution
- c: lancer une commande pérsonnalisée prédéfinie
- b: voir les commandes groupés
- w: ouvrir dans le navigateur (le premier port est http)
- enter: mise au point sur le paneau principale
-
-
-## Services
-
-
- d: retirer les conteneurs
- s: arrêter
- r: redémarrer
- a: attacher
- m: voir le journal
- [: onglet précédent
- ]: onglet suivant
- R: voir les options de redémarrage
- c: lancer une commande pérsonnalisée prédéfinie
- b: voir les commandes groupés
- w: ouvrir dans le navigateur (le premier port est http)
- enter: mise au point sur le paneau principale
-
-
-## Images
-
-
- [: onglet précédent
- ]: onglet suivant
- c: lancer une commande pérsonnalisée prédéfinie
- d: retirer l'image
- b: voir les commandes groupés
- enter: mise au point sur le paneau principale
-
-
-## Volumes
-
-
- [: onglet précédent
- ]: onglet suivant
- c: lancer une commande pérsonnalisée prédéfinie
- d: retirer le volume
- b: voir les commandes groupés
- enter: mise au point sur le paneau principale
-
-
-## Principale
-
-
- esc: retour
-
From 2afd84d19285777c9bcfb318fed2907a908204b6 Mon Sep 17 00:00:00 2001
From: Clement Sauvage
+ e: modifier la configuration lazydocker
+ o: ouvrire la configuration lazydocker
+ [: onglet précédent
+ ]: onglet suivant
+ m: voir les enregistrements
+ enter: focus paneau principal
+
+
+## Conteneurs
+
+
+ [: onglet précédent
+ ]: onglet suivant
+ d: supprimer
+ e: cacher/montrer les conteneurs arrêtés
+ p: pause
+ s: arrêter
+ r: redémarrer
+ a: attacher
+ m: voir les enregistrements
+ E: executer le shell
+ c: executer une commande prédéfinie
+ b: voir les commandes groupés
+ w: ouvrir dans le navgateur (le premier port est http)
+ enter: focus paneau principal
+
+
+## Services
+
+
+ d: supprimer les conteneurs
+ s: arrêter
+ p: pause
+ r: redémarrer
+ S: démarrer
+ a: attacher
+ m: voir les enregistrements
+ [: onglet précédent
+ ]: onglet suivant
+ R: voir les options de redémarrage
+ c: executer une commande prédéfinie
+ b: voir les commandes groupés
+ E: executer le shell
+ w: ouvrir dans le navgateur (le premier port est http)
+ enter: focus paneau principal
+
+
+## Images
+
+
+ [: onglet précédent
+ ]: onglet suivant
+ c: executer une commande prédéfinie
+ d: supprimer l'image
+ b: voir les commandes groupés
+ enter: focus paneau principal
+
+
+## Volumes
+
+
+ [: onglet précédent
+ ]: onglet suivant
+ c: executer une commande prédéfinie
+ d: supprimer le volume
+ b: voir les commandes groupés
+ enter: focus paneau principal
+
+
+## Principal
+
+
+ esc: retour
+
From 32ffbae56c3945650b5c6c2c0f0d168fcb84249b Mon Sep 17 00:00:00 2001
From: KOLOSSA Tilman
d: entferne Container s: anhalten + p: pause r: neustarten + S: start a: anbinden m: zeige Protokolle [: vorheriges Tab @@ -42,6 +47,7 @@ R: zeige Neustartoptionen c: führe vordefinierten benutzerdefinierten Befehl aus b: view bulk commands + E: exec shell w: open in browser (first port is http) enter: fokussieren aufs Hauptpanel@@ -73,3 +79,10 @@
esc: zurück+ +## Global + +
+ +: next screen mode (normal/half/fullscreen) + _: prev screen mode +diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index 85e67026..db306cda 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -1,3 +1,5 @@ +_This file is auto-generated. To update, make the changes in the pkg/i18n directory and then run `go run scripts/generate_cheatsheet.go` from the project root._ + # Lazydocker menu ## Project @@ -17,7 +19,8 @@ [: previous tab ]: next tab d: remove - e: Hide/Show stopped containers + e: hide/show stopped containers + p: pause s: stop r: restart a: attach @@ -34,7 +37,9 @@
d: remove containers s: stop + p: pause r: restart + S: start a: attach m: view logs [: previous tab @@ -42,6 +47,7 @@ R: view restart options c: run predefined custom command b: view bulk commands + E: exec shell w: open in browser (first port is http) enter: focus main panel@@ -73,3 +79,10 @@
esc: return+ +## Global + +
+ +: next screen mode (normal/half/fullscreen) + _: prev screen mode +diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index f0f50dbc..6f86660b 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -1,3 +1,5 @@ +_This file is auto-generated. To update, make the changes in the pkg/i18n directory and then run `go run scripts/generate_cheatsheet.go` from the project root._ + # Lazydocker menu ## Project @@ -17,7 +19,8 @@ [: vorige tab ]: volgende tab d: verwijder - e: Verberg gestopte containers + e: verberg gestopte containers + p: pause s: stop r: herstart a: verbinden @@ -34,7 +37,9 @@
d: verwijder containers s: stop + p: pause r: herstart + S: start a: verbinden m: bekijk logs [: vorige tab @@ -42,6 +47,7 @@ R: bekijk herstart opties c: draai een vooraf bedacht aangepaste opdracht b: view bulk commands + E: exec shell w: open in browser (first port is http) enter: focus hoofdpaneel@@ -73,3 +79,10 @@
esc: terug+ +## Globaal + +
+ +: next screen mode (normal/half/fullscreen) + _: prev screen mode +diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index a902386f..921b3db8 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -1,3 +1,5 @@ +_This file is auto-generated. To update, make the changes in the pkg/i18n directory and then run `go run scripts/generate_cheatsheet.go` from the project root._ + # Lazydocker menu ## Projekt @@ -17,7 +19,8 @@ [: poprzednia zakładka ]: następna zakładka d: usuń - e: Hide/Show stopped containers + e: hide/show stopped containers + p: pause s: zatrzymaj r: restartuj a: przyczep @@ -34,7 +37,9 @@
d: usuń kontenery s: zatrzymaj + p: pause r: restartuj + S: start a: przyczep m: pokaż logi [: poprzednia zakładka @@ -42,6 +47,7 @@ R: pokaż opcje restartu c: wykonaj predefiniowaną własną komende b: view bulk commands + E: exec shell w: open in browser (first port is http) enter: skup na głównym panelu@@ -73,3 +79,10 @@
esc: powrót+ +## Globalne + +
+ +: next screen mode (normal/half/fullscreen) + _: prev screen mode +diff --git a/docs/keybindings/Keybindings_tr.md b/docs/keybindings/Keybindings_tr.md index 85b43165..4c16e232 100644 --- a/docs/keybindings/Keybindings_tr.md +++ b/docs/keybindings/Keybindings_tr.md @@ -1,3 +1,5 @@ +_This file is auto-generated. To update, make the changes in the pkg/i18n directory and then run `go run scripts/generate_cheatsheet.go` from the project root._ + # Lazydocker menü ## Proje @@ -17,7 +19,8 @@ [: önceki sekme ]: sonraki sekme d: kaldır - e: Hide/Show stopped containers + e: hide/show stopped containers + p: pause s: durdur r: yeniden başlat a: bağlan/iliştir @@ -34,7 +37,9 @@
d: konteynerleri kaldır s: durdur + p: pause r: yeniden başlat + S: start a: bağlan/iliştir m: kayıt defterini görüntüle [: önceki sekme @@ -42,6 +47,7 @@ R: yeniden başlatma seçeneklerini görüntüle c: önceden tanımlanmış özel komutu çalıştır b: view bulk commands + E: exec shell w: open in browser (first port is http) enter: ana panele odaklan@@ -73,3 +79,10 @@
esc: dönüş+ +## Global + +
+ +: next screen mode (normal/half/fullscreen) + _: prev screen mode +diff --git a/scripts/generate_cheatsheet.go b/scripts/generate_cheatsheet.go index c1237701..79893b74 100644 --- a/scripts/generate_cheatsheet.go +++ b/scripts/generate_cheatsheet.go @@ -40,6 +40,12 @@ func main() { bindingSections := getBindingSections(mApp) content := formatSections(mApp, bindingSections) + content = fmt.Sprintf( + "_This file is auto-generated. To update, make the changes in the "+ + "pkg/i18n directory and then run `%s` from the project root._\n\n%s", + commandToRun(), + content, + ) writeString(file, content) } } @@ -134,3 +140,7 @@ func formatSections(mApp *app.App, bindingSections []*bindingSection) string { return content } + +func commandToRun() string { + return "go run scripts/generate_cheatsheet.go" +} From a5eece155c3d5ab71f6e13edd4a3fe516fe12c22 Mon Sep 17 00:00:00 2001 From: Gustavo Andrioli
+ u: up service d: entferne Container s: anhalten p: pause diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index dd0925e2..86f1b8cf 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -35,6 +35,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct ## Services+ u: up service d: remove containers s: stop p: pause diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index 00dc7f88..17077899 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -35,6 +35,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct ## Diensten+ u: up service d: verwijder containers s: stop p: pause diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index 174beb15..08b89c5b 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -35,6 +35,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct ## Serwisy+ u: up service d: usuń kontenery s: zatrzymaj p: pause diff --git a/docs/keybindings/Keybindings_tr.md b/docs/keybindings/Keybindings_tr.md index bb83faee..263db57b 100644 --- a/docs/keybindings/Keybindings_tr.md +++ b/docs/keybindings/Keybindings_tr.md @@ -35,6 +35,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct ## Servisler+ u: up service d: konteynerleri kaldır s: durdur p: pause diff --git a/pkg/commands/service.go b/pkg/commands/service.go index f45146bc..2918b339 100644 --- a/pkg/commands/service.go +++ b/pkg/commands/service.go @@ -38,29 +38,27 @@ func (s *Service) Remove(options types.ContainerRemoveOptions) error { // Stop stops the service's containers func (s *Service) Stop() error { - templateString := s.OSCommand.Config.UserConfig.CommandTemplates.StopService - command := utils.ApplyTemplate( - templateString, - s.DockerCommand.NewCommandObject(CommandObject{Service: s}), - ) - return s.OSCommand.RunCommand(command) + return s.runCommand(s.OSCommand.Config.UserConfig.CommandTemplates.StopService) +} + +// Up up's the service +func (s *Service) Up() error { + return s.runCommand(s.OSCommand.Config.UserConfig.CommandTemplates.UpService) } // Restart restarts the service func (s *Service) Restart() error { - templateString := s.OSCommand.Config.UserConfig.CommandTemplates.RestartService - command := utils.ApplyTemplate( - templateString, - s.DockerCommand.NewCommandObject(CommandObject{Service: s}), - ) - return s.OSCommand.RunCommand(command) + return s.runCommand(s.OSCommand.Config.UserConfig.CommandTemplates.RestartService) } // Restart starts the service func (s *Service) Start() error { - templateString := s.OSCommand.Config.UserConfig.CommandTemplates.StartService + return s.runCommand(s.OSCommand.Config.UserConfig.CommandTemplates.StartService) +} + +func (s *Service) runCommand(templateCmdStr string) error { command := utils.ApplyTemplate( - templateString, + templateCmdStr, s.DockerCommand.NewCommandObject(CommandObject{Service: s}), ) return s.OSCommand.RunCommand(command) diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 78064067..a68cb444 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -138,6 +138,9 @@ type CommandTemplatesConfig struct { // StartService is just like the above but for starting StartService string `yaml:"startService,omitempty"` + // UpService ups the service (creates and starts) + UpService string `yaml:"upService,omitempty"` + // DockerCompose is for your docker-compose command. You may want to combine a // few different docker-compose.yml files together, in which case you can set // this to "docker-compose -f foo/docker-compose.yml -f @@ -348,6 +351,7 @@ func GetDefaultConfig() UserConfig { DockerCompose: "docker-compose", RestartService: "{{ .DockerCompose }} restart {{ .Service.Name }}", StartService: "{{ .DockerCompose }} start {{ .Service.Name }}", + UpService: "{{ .DockerCompose }} up -d {{ .Service.Name }}", RebuildService: "{{ .DockerCompose }} up -d --build {{ .Service.Name }}", RecreateService: "{{ .DockerCompose }} up -d --force-recreate {{ .Service.Name }}", StopService: "{{ .DockerCompose }} stop {{ .Service.Name }}", diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 05ce3498..54a6b7e7 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -283,6 +283,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Handler: gui.handleContainersOpenInBrowserCommand, Description: gui.Tr.OpenInBrowser, }, + { + ViewName: "services", + Key: 'u', + Modifier: gocui.ModNone, + Handler: gui.handleServiceUp, + Description: gui.Tr.UpService, + }, { ViewName: "services", Key: 'd', diff --git a/pkg/gui/services_panel.go b/pkg/gui/services_panel.go index 76d0116b..67cb3613 100644 --- a/pkg/gui/services_panel.go +++ b/pkg/gui/services_panel.go @@ -248,6 +248,19 @@ func (gui *Gui) handleServiceStop(g *gocui.Gui, v *gocui.View) error { }, nil) } +func (gui *Gui) handleServiceUp(g *gocui.Gui, v *gocui.View) error { + service, err := gui.getSelectedService() + if err != nil { + return nil + } + + if err := service.Up(); err != nil { + return gui.createErrorPanel(err.Error()) + } + + return nil +} + func (gui *Gui) handleServiceRestart(g *gocui.Gui, v *gocui.View) error { service, err := gui.getSelectedService() if err != nil { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 9f225c4d..eed1fcb4 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -46,6 +46,7 @@ type TranslationSet struct { RunningCustomCommandStatus string RunningBulkCommandStatus string RemoveService string + UpService string Stop string Pause string Restart string @@ -149,6 +150,7 @@ func englishSet() TranslationSet { ForceRemove: "force remove", RemoveWithVolumes: "remove with volumes", RemoveService: "remove containers", + UpService: "up service", Stop: "stop", Pause: "pause", Restart: "restart", From cddfb417b66b97aedc661ec7589a8490612faa2a Mon Sep 17 00:00:00 2001 From: Jesse DuffieldDate: Mon, 10 Oct 2022 19:57:34 -0700 Subject: [PATCH 37/42] wait when upping --- pkg/gui/services_panel.go | 10 ++++++---- pkg/i18n/english.go | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/gui/services_panel.go b/pkg/gui/services_panel.go index 67cb3613..af95e925 100644 --- a/pkg/gui/services_panel.go +++ b/pkg/gui/services_panel.go @@ -254,11 +254,13 @@ func (gui *Gui) handleServiceUp(g *gocui.Gui, v *gocui.View) error { return nil } - if err := service.Up(); err != nil { - return gui.createErrorPanel(err.Error()) - } + return gui.WithWaitingStatus(gui.Tr.UppingStatus, func() error { + if err := service.Up(); err != nil { + return gui.createErrorPanel(err.Error()) + } - return nil + return nil + }) } func (gui *Gui) handleServiceRestart(g *gocui.Gui, v *gocui.View) error { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index eed1fcb4..cc11470f 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -41,6 +41,7 @@ type TranslationSet struct { RestartingStatus string StartingStatus string StoppingStatus string + UppingStatus string PausingStatus string RemovingStatus string RunningCustomCommandStatus string @@ -117,6 +118,7 @@ func englishSet() TranslationSet { RestartingStatus: "restarting", StartingStatus: "starting", StoppingStatus: "stopping", + UppingStatus: "upping", PausingStatus: "pausing", RunningCustomCommandStatus: "running custom command", RunningBulkCommandStatus: "running bulk command", From 8b04b3ecf47568be0af03f075053c1a48c39613a Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 10 Oct 2022 20:10:36 -0700 Subject: [PATCH 38/42] properly display unforwarded port --- pkg/commands/container.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/commands/container.go b/pkg/commands/container.go index c239640d..39cece20 100644 --- a/pkg/commands/container.go +++ b/pkg/commands/container.go @@ -57,6 +57,10 @@ func (c *Container) GetDisplayStrings(isFocused bool) []string { func (c *Container) displayPorts() string { portStrings := lo.Map(c.Container.Ports, func(port types.Port, _ int) string { + if port.PublicPort == 0 { + return fmt.Sprintf("%d\\%s", port.PrivatePort, port.Type) + } + // docker ps will show '0.0.0.0:80->80/tcp' but we'll show // '80->80/tcp' instead to save space (unless the IP is something other than // 0.0.0.0) From e636091bba75c65fad3ee4888fae96b5782003b3 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 10 Oct 2022 20:33:56 -0700 Subject: [PATCH 39/42] allow upping and downing whole project --- docs/Config.md | 5 +++- pkg/config/app_config.go | 11 +++++++ pkg/gui/keybindings.go | 14 +++++++++ pkg/gui/services_panel.go | 63 ++++++++++++++++++++++++++++++++++++++- pkg/i18n/english.go | 16 ++++++++-- 5 files changed, 105 insertions(+), 4 deletions(-) diff --git a/docs/Config.md b/docs/Config.md index 6e77a94a..b1d0c4d7 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -42,8 +42,11 @@ logs: commandTemplates: dockerCompose: docker-compose restartService: '{{ .DockerCompose }} restart {{ .Service.Name }}' - startService: '{{ .DockerCompose }} start {{ .Service.Name }}' + up: '{{ .DockerCompose }} up -d' + down: '{{ .DockerCompose }} down' + downWithVolumes: '{{ .DockerCompose }} down --volumes' upService: '{{ .DockerCompose }} up -d {{ .Service.Name }}' + startService: '{{ .DockerCompose }} start {{ .Service.Name }}' stopService: '{{ .DockerCompose }} stop {{ .Service.Name }}' serviceLogs: '{{ .DockerCompose }} logs --since=60m --follow {{ .Service.Name }}' viewServiceLogs: '{{ .DockerCompose }} logs --follow {{ .Service.Name }}' diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index a68cb444..104c55ca 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -141,6 +141,14 @@ type CommandTemplatesConfig struct { // UpService ups the service (creates and starts) UpService string `yaml:"upService,omitempty"` + // Runs "docker-compose up -d" + Up string `yaml:"up,omitempty"` + + // downs everything + Down string `yaml:"down,omitempty"` + // downs and removes volumes + DownWithVolumes string `yaml:"downWithVolumes,omitempty"` + // DockerCompose is for your docker-compose command. You may want to combine a // few different docker-compose.yml files together, in which case you can set // this to "docker-compose -f foo/docker-compose.yml -f @@ -351,6 +359,9 @@ func GetDefaultConfig() UserConfig { DockerCompose: "docker-compose", RestartService: "{{ .DockerCompose }} restart {{ .Service.Name }}", StartService: "{{ .DockerCompose }} start {{ .Service.Name }}", + Up: "{{ .DockerCompose }} up -d", + Down: "{{ .DockerCompose }} down", + DownWithVolumes: "{{ .DockerCompose }} down --volumes", UpService: "{{ .DockerCompose }} up -d {{ .Service.Name }}", RebuildService: "{{ .DockerCompose }} up -d --build {{ .Service.Name }}", RecreateService: "{{ .DockerCompose }} up -d --force-recreate {{ .Service.Name }}", diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 54a6b7e7..e1f12950 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -339,6 +339,20 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Handler: gui.handleServiceRenderLogsToMain, Description: gui.Tr.ViewLogs, }, + { + ViewName: "services", + Key: 'U', + Modifier: gocui.ModNone, + Handler: gui.handleProjectUp, + Description: gui.Tr.UpProject, + }, + { + ViewName: "services", + Key: 'D', + Modifier: gocui.ModNone, + Handler: gui.handleProjectDown, + Description: gui.Tr.DownProject, + }, { ViewName: "services", Key: '[', diff --git a/pkg/gui/services_panel.go b/pkg/gui/services_panel.go index af95e925..7abdd8ff 100644 --- a/pkg/gui/services_panel.go +++ b/pkg/gui/services_panel.go @@ -254,7 +254,7 @@ func (gui *Gui) handleServiceUp(g *gocui.Gui, v *gocui.View) error { return nil } - return gui.WithWaitingStatus(gui.Tr.UppingStatus, func() error { + return gui.WithWaitingStatus(gui.Tr.UppingServiceStatus, func() error { if err := service.Up(); err != nil { return gui.createErrorPanel(err.Error()) } @@ -325,6 +325,67 @@ func (gui *Gui) handleServiceRenderLogsToMain(g *gocui.Gui, v *gocui.View) error return gui.runSubprocess(c) } +func (gui *Gui) handleProjectUp(g *gocui.Gui, v *gocui.View) error { + cmdStr := utils.ApplyTemplate( + gui.Config.UserConfig.CommandTemplates.Up, + gui.DockerCommand.NewCommandObject(commands.CommandObject{}), + ) + + return gui.WithWaitingStatus(gui.Tr.UppingAllStatus, func() error { + if err := gui.OSCommand.RunCommand(cmdStr); err != nil { + return gui.createErrorPanel(err.Error()) + } + return nil + }) +} + +func (gui *Gui) handleProjectDown(g *gocui.Gui, v *gocui.View) error { + downCommand := utils.ApplyTemplate( + gui.Config.UserConfig.CommandTemplates.Down, + gui.DockerCommand.NewCommandObject(commands.CommandObject{}), + ) + + downWithVolumesCommand := utils.ApplyTemplate( + gui.Config.UserConfig.CommandTemplates.DownWithVolumes, + gui.DockerCommand.NewCommandObject(commands.CommandObject{}), + ) + + options := []*commandOption{ + { + description: gui.Tr.Down, + command: downCommand, + f: func() error { + return gui.WithWaitingStatus(gui.Tr.DowningStatus, func() error { + if err := gui.OSCommand.RunCommand(downCommand); err != nil { + return gui.createErrorPanel(err.Error()) + } + return nil + }) + }, + }, + { + description: gui.Tr.DownWithVolumes, + command: downWithVolumesCommand, + f: func() error { + return gui.WithWaitingStatus(gui.Tr.DowningStatus, func() error { + if err := gui.OSCommand.RunCommand(downWithVolumesCommand); err != nil { + return gui.createErrorPanel(err.Error()) + } + return nil + }) + }, + }, + { + description: gui.Tr.Cancel, + f: func() error { return nil }, + }, + } + + handleMenuPress := func(index int) error { return options[index].f() } + + return gui.createMenu("", options, len(options), handleMenuPress) +} + func (gui *Gui) handleServiceRestartMenu(g *gocui.Gui, v *gocui.View) error { service, err := gui.getSelectedService() if err != nil { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index cc11470f..742b2910 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -41,9 +41,11 @@ type TranslationSet struct { RestartingStatus string StartingStatus string StoppingStatus string - UppingStatus string + UppingAllStatus string + UppingServiceStatus string PausingStatus string RemovingStatus string + DowningStatus string RunningCustomCommandStatus string RunningBulkCommandStatus string RemoveService string @@ -51,6 +53,8 @@ type TranslationSet struct { Stop string Pause string Restart string + Down string + DownWithVolumes string Start string Rebuild string Recreate string @@ -58,6 +62,8 @@ type TranslationSet struct { NextContext string Attach string ViewLogs string + UpProject string + DownProject string ServicesTitle string ContainersTitle string StandaloneContainersTitle string @@ -118,7 +124,9 @@ func englishSet() TranslationSet { RestartingStatus: "restarting", StartingStatus: "starting", StoppingStatus: "stopping", - UppingStatus: "upping", + UppingServiceStatus: "upping service", + UppingAllStatus: "upping all", + DowningStatus: "downing", PausingStatus: "pausing", RunningCustomCommandStatus: "running custom command", RunningBulkCommandStatus: "running bulk command", @@ -156,6 +164,8 @@ func englishSet() TranslationSet { Stop: "stop", Pause: "pause", Restart: "restart", + Down: "down project", + DownWithVolumes: "down project with volumes", Start: "start", Rebuild: "rebuild", Recreate: "recreate", @@ -163,6 +173,8 @@ func englishSet() TranslationSet { NextContext: "next tab", Attach: "attach", ViewLogs: "view logs", + UpProject: "up project", + DownProject: "down project", RemoveImage: "remove image", RemoveVolume: "remove volume", RemoveWithoutPrune: "remove without deleting untagged parents", From dfd4db8bfa5e8de73e24ffc58400cec7db98cdc0 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 10 Oct 2022 20:34:05 -0700 Subject: [PATCH 40/42] allow jumping to top of main panel with home key --- pkg/gui/keybindings.go | 6 ++++++ pkg/gui/main_panel.go | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index e1f12950..3f8ac500 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -109,6 +109,12 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Modifier: gocui.ModNone, Handler: gui.autoScrollMain, }, + { + ViewName: "", + Key: gocui.KeyHome, + Modifier: gocui.ModNone, + Handler: gui.jumpToTopMain, + }, { ViewName: "", Key: 'x', diff --git a/pkg/gui/main_panel.go b/pkg/gui/main_panel.go index e8675df4..bf985d8c 100644 --- a/pkg/gui/main_panel.go +++ b/pkg/gui/main_panel.go @@ -66,6 +66,13 @@ func (gui *Gui) autoScrollMain(g *gocui.Gui, v *gocui.View) error { return nil } +func (gui *Gui) jumpToTopMain(g *gocui.Gui, v *gocui.View) error { + gui.getMainView().Autoscroll = false + _ = gui.getMainView().SetOrigin(0, 0) + _ = gui.getMainView().SetCursor(0, 0) + return nil +} + func (gui *Gui) onMainTabClick(tabIndex int) error { gui.Log.Warn(tabIndex) From e3f01ecb8de790746417c502c1b3366010862138 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 10 Oct 2022 20:36:34 -0700 Subject: [PATCH 41/42] update cheatsheets --- docs/keybindings/Keybindings_de.md | 2 ++ docs/keybindings/Keybindings_en.md | 2 ++ docs/keybindings/Keybindings_nl.md | 2 ++ docs/keybindings/Keybindings_pl.md | 2 ++ docs/keybindings/Keybindings_tr.md | 2 ++ 5 files changed, 10 insertions(+) diff --git a/docs/keybindings/Keybindings_de.md b/docs/keybindings/Keybindings_de.md index b28837b1..898317b4 100644 --- a/docs/keybindings/Keybindings_de.md +++ b/docs/keybindings/Keybindings_de.md @@ -43,6 +43,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct S: start a: anbinden m: zeige Protokolle + U: up project + D: down project [: vorheriges Tab ]: nächstes Tab R: zeige Neustartoptionen diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index 86f1b8cf..8cfab0de 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -43,6 +43,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct S: start a: attach m: view logs + U: up project + D: down project [: previous tab ]: next tab R: view restart options diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index 17077899..f606b880 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -43,6 +43,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct S: start a: verbinden m: bekijk logs + U: up project + D: down project [: vorige tab ]: volgende tab R: bekijk herstart opties diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index 08b89c5b..a8ab2a1b 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -43,6 +43,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct S: start a: przyczep m: pokaż logi + U: up project + D: down project [: poprzednia zakładka ]: następna zakładka R: pokaż opcje restartu diff --git a/docs/keybindings/Keybindings_tr.md b/docs/keybindings/Keybindings_tr.md index 263db57b..0124bb1f 100644 --- a/docs/keybindings/Keybindings_tr.md +++ b/docs/keybindings/Keybindings_tr.md @@ -43,6 +43,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct S: start a: bağlan/iliştir m: kayıt defterini görüntüle + U: up project + D: down project [: önceki sekme ]: sonraki sekme R: yeniden başlatma seçeneklerini görüntüle From 15e0ecb371a5c3c82e02024da4c40556c6af0d34 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 10 Oct 2022 20:40:51 -0700 Subject: [PATCH 42/42] use confirmation panel for upping project --- pkg/gui/services_panel.go | 22 ++++++++++++---------- pkg/i18n/english.go | 6 ++++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pkg/gui/services_panel.go b/pkg/gui/services_panel.go index 7abdd8ff..c0361e1a 100644 --- a/pkg/gui/services_panel.go +++ b/pkg/gui/services_panel.go @@ -326,17 +326,19 @@ func (gui *Gui) handleServiceRenderLogsToMain(g *gocui.Gui, v *gocui.View) error } func (gui *Gui) handleProjectUp(g *gocui.Gui, v *gocui.View) error { - cmdStr := utils.ApplyTemplate( - gui.Config.UserConfig.CommandTemplates.Up, - gui.DockerCommand.NewCommandObject(commands.CommandObject{}), - ) + return gui.createConfirmationPanel(gui.Tr.Confirm, gui.Tr.ConfirmUpProject, func(g *gocui.Gui, v *gocui.View) error { + cmdStr := utils.ApplyTemplate( + gui.Config.UserConfig.CommandTemplates.Up, + gui.DockerCommand.NewCommandObject(commands.CommandObject{}), + ) - return gui.WithWaitingStatus(gui.Tr.UppingAllStatus, func() error { - if err := gui.OSCommand.RunCommand(cmdStr); err != nil { - return gui.createErrorPanel(err.Error()) - } - return nil - }) + return gui.WithWaitingStatus(gui.Tr.UppingProjectStatus, func() error { + if err := gui.OSCommand.RunCommand(cmdStr); err != nil { + return gui.createErrorPanel(err.Error()) + } + return nil + }) + }, nil) } func (gui *Gui) handleProjectDown(g *gocui.Gui, v *gocui.View) error { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 742b2910..f747b5f5 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -17,6 +17,7 @@ type TranslationSet struct { OpenConfig string EditConfig string ConfirmQuit string + ConfirmUpProject string ErrorOccurred string ConnectionFailed string UnattachableContainerError string @@ -41,7 +42,7 @@ type TranslationSet struct { RestartingStatus string StartingStatus string StoppingStatus string - UppingAllStatus string + UppingProjectStatus string UppingServiceStatus string PausingStatus string RemovingStatus string @@ -125,7 +126,7 @@ func englishSet() TranslationSet { StartingStatus: "starting", StoppingStatus: "stopping", UppingServiceStatus: "upping service", - UppingAllStatus: "upping all", + UppingProjectStatus: "upping project", DowningStatus: "downing", PausingStatus: "pausing", RunningCustomCommandStatus: "running custom command", @@ -221,6 +222,7 @@ func englishSet() TranslationSet { NoVolumes: "No volumes", ConfirmQuit: "Are you sure you want to quit?", + ConfirmUpProject: "Are you sure you want to 'up' your docker compose project?", MustForceToRemoveContainer: "You cannot remove a running container unless you force it. Do you want to force it?", NotEnoughSpace: "Not enough space to render panels", ConfirmPruneImages: "Are you sure you want to prune all unused images?",