Skip to content

Commit

Permalink
feat: add dkr follow command
Browse files Browse the repository at this point in the history
  • Loading branch information
sznowicki committed Dec 19, 2023
1 parent 6b1caab commit e3950da
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions commands/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ func handleNuke() int {
return 0
}

func handleFollow() int {
ids := string(ReturnCommand("docker", []string{"ps", "-q"}))
// Exec a command that will list all running containers and then follow their logs.
ExecCommand("docker", []string{"logs", "-f", strings.Trim(ids, "\n")})
return 0
}

func DetectAndCallAliases(osArgs []string) (bool, int) {
// No arguments after `dkr` or `dkr c` called
if len(osArgs) == 1 ||
Expand Down Expand Up @@ -91,6 +98,8 @@ func DetectAndCallAliases(osArgs []string) (bool, int) {
return true, handleCleanup()
case "nuke":
return true, handleNuke()
case "follow":
return true, handleFollow()
}

return false, 0
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func main() {
flag.PrintDefaults()
// Subcommands
fmt.Println("aliases:")
fmt.Println(" follow - Follows all running container logs")
fmt.Println(" sh CONTAINER_NAME - Jumps into running container sh.")
fmt.Println(" bash CONTAINER_NAME - Jumps into running container bash.")
fmt.Println(" killall - Kills all active container. Equivalent: docker kill $(docker ps -q).")
Expand Down
2 changes: 1 addition & 1 deletion router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
)

var version = "0.2.0"
var version = "0.3.0"

func Route(showVersion bool, osArgs []string) {
if showVersion {
Expand Down

0 comments on commit e3950da

Please sign in to comment.