Skip to content

Commit

Permalink
changed hints logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrisyhjiang committed Jun 28, 2024
1 parent d534820 commit 405fb0e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
7 changes: 2 additions & 5 deletions src/cmd/cli/command/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,6 @@ var generateCmd = &cobra.Command{
}

Track("Generate Started", P{"language", language}, P{"sample", sample}, P{"description", prompt.Description}, P{"folder", prompt.Folder})

// create the folder if needed
cd := ""
if prompt.Folder != "." {
Expand Down Expand Up @@ -585,10 +584,8 @@ var generateCmd = &cobra.Command{
for _, service := range compose.Services {
if len(service.Environment) > 0 {
envVars := make([]string, 0, len(service.Environment))
for _, envVar := range service.Environment {
envVars = append(envVars, envVar)
}
printDefangHint("To deploy the service, run:", "cd "+prompt.Folder+"\ndefang config set "+strings.Join(envVars, " ")+"\ndefang compose up")
envVars = append(envVars, service.Environment...)
fmt.Printf("To deploy the service, run:\n%s\n defang config set %s\n defang compose up\n", " "+cd, strings.Join(envVars, " "))
}
}
}
Expand Down
8 changes: 1 addition & 7 deletions src/pkg/cli/composeStart.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cli
import (
"context"
"fmt"
"strings"

"github.com/DefangLabs/defang/src/pkg/cli/client"
"github.com/DefangLabs/defang/src/pkg/cli/compose"
Expand Down Expand Up @@ -64,12 +63,7 @@ func ComposeStart(ctx context.Context, c client.Client, force bool) (*defangv1.D
Services: services,
})
if err != nil {
if strings.Contains(err.Error(), "missing configs") {
// Extract the list of missing configs
formattedMissingConfigs := strings.Join(strings.Fields(err.Error()[strings.Index(err.Error(), "[")+1:strings.Index(err.Error(), "]")]), ", ")
return nil, fmt.Errorf("missing configs: run defang config set on %s", formattedMissingConfigs)
}
return nil, fmt.Errorf("deployment failed: %w", err) // Wrap the original error with a new message
return nil, err
}

if term.DoDebug() {
Expand Down

0 comments on commit 405fb0e

Please sign in to comment.