Skip to content

Commit

Permalink
fix: allow arg usage without quotes for add-service command
Browse files Browse the repository at this point in the history
  • Loading branch information
profclems committed Aug 7, 2023
1 parent dcdf504 commit 93609db
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/commands/add-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"os"
"strings"

"github.com/rs/zerolog"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -47,13 +48,18 @@ $ compozify add-service -w -f /path/to/docker-compose.yml -- docker run -i -t --
$ compozify add-service -w -f /path/to/docker-compose.yml -n my-service "docker run -i -t --rm alpine"
`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
switch len(args) {
case 0:
return cmd.Help()
case 1:
opts.Command = args[0]
default:
opts.Command = strings.Join(args, " ")
}
opts.Command = args[0]

return addServiceRun(&opts)
},
Args: cobra.MinimumNArgs(1),
}

cmd.Flags().StringVarP(&opts.ServiceName, "service-name", "n", "", "Name of the service")
Expand Down

0 comments on commit 93609db

Please sign in to comment.