Skip to content

Commit

Permalink
add and fix stop/down command (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhuda authored Aug 4, 2024
1 parent efc716b commit 6f25245
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions internal/dockercompose/dockercompose.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func FindServices(root string, force bool) (DockermiTypes.ServiceScriptReturn, e
} else if activeExists {
color.Yellow("Service '%s' is inactive (dockermi.active=false). Skipping...", serviceName)
} else {
color.Red("Service '%s' is missing 'dockermi.order' or 'dockermi.active' labels. Skipping...", serviceName)
color.HiYellowString("Service '%s' is missing 'dockermi.order' or 'dockermi.active' labels. Skipping...", serviceName)
}
}
return nil
Expand Down Expand Up @@ -139,7 +139,7 @@ func FindServicesWithKey(root string) (map[string][]DockermiTypes.ServiceScript,
} else if activeExists {
color.Yellow("Service '%s' is inactive (dockermi.active=false). Skipping...", serviceName)
} else {
color.Red("Service '%s' is missing 'dockermi.order' or 'dockermi.active' labels. Skipping...", serviceName)
color.HiYellowString("Service '%s' is missing 'dockermi.order' or 'dockermi.active' labels. Skipping...", serviceName)
}
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/script/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func CreateDockermiScript(scriptPath string, services DockermiTypes.ServiceScrip
})
for _, service := range services {
dockermiScript.WriteString(fmt.Sprintf(" echo \"Stopping %s...\"\n", service.ServiceName))
dockermiScript.WriteString(fmt.Sprintf(" docker-compose -f \"%s\" down \"%s\" \"$@\"\n", service.ComposeFile, service.ServiceName))
dockermiScript.WriteString(fmt.Sprintf(" docker-compose -f \"%s\" stop \"%s\" \"$@\"\n", service.ComposeFile, service.ServiceName))
bar.Add(1)
time.Sleep(500 * time.Millisecond) // Simulate delay for demonstration
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/dockermi.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

func GetVersion() string {
return "v0.1.5"
return "v0.1.6"
}

// RunDockermi executes the main logic of the dockermi command. It takes a
Expand Down Expand Up @@ -55,7 +55,9 @@ func RunDockermi(projectDir string) (string, error) {
case "up":
return handleUpDownCommand(projectDir, "up", os.Args[2:])
case "down":
return handleUpDownCommand(projectDir, "down", os.Args[2:]) // Handle the down command
return handleUpDownCommand(projectDir, "down", os.Args[2:])
case "stop":
return handleUpDownCommand(projectDir, "down", os.Args[2:])
case "create":
if len(os.Args) < 3 {
return "", fmt.Errorf("missing key for create command")
Expand Down
File renamed without changes.
13 changes: 8 additions & 5 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
// DisplayHelp prints the usage information for the dockermi command to the console.
func DisplayHelp(version string) {
fmt.Printf(`
Dockermi version: %s
Dockermi version: %s | github.com/mkhuda/dockermi
Usage: dockermi [command] [options]
This command generates a dockermi.sh script to manage Docker services defined in docker-compose.yml files.
Expand All @@ -16,16 +16,19 @@ and the 'dockermi.sh' script is created in the current directory where the 'dock
Commands:
create <service-key> Generate a dockermi.sh script for the specified service key.
up [options] Start the Docker services defined in the dockermi.sh file in current directory.
down [options] Stop the Docker services defined in the dockermi.sh file in current directory.
up [options] Start the Docker services defined in the dockermi.sh file in the current directory.
down [options] Stop the Docker services defined in the dockermi.sh file in the current directory.
Options:
--help Display this help message and exit.
--version Display current installed version.
--force Force create dockermi.sh from all valid docker-compose files, ignoring dockermi labels convention.
Examples:
dockermi # Generates a dockermi.sh script in the current directory.
dockermi create myservicekey # [Experimental] Create a script for the specified service key.
dockermi up -d --build # Start services with the --build option.
dockermi down --remove-orphans # Stop services and remove orphan containers.`, version)
dockermi up -d --build # Start services with the --build option.
dockermi down --remove-orphans # Stop services and remove orphan containers.
`, version)
}

0 comments on commit 6f25245

Please sign in to comment.