Skip to content

Commit

Permalink
fix: improving the project type flag failure message
Browse files Browse the repository at this point in the history
  • Loading branch information
Pehesi97 committed Oct 19, 2023
1 parent cd28258 commit 12fa85a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strconv"
"strings"

"github.com/charmbracelet/log"
"github.com/nearform/initium-cli/src/services/git"
"github.com/nearform/initium-cli/src/services/project"
"github.com/nearform/initium-cli/src/utils/defaults"
Expand Down Expand Up @@ -75,6 +76,8 @@ func InitFlags() flags {
tempProjectType, err := project.DetectType(".")
if err == nil {
projectType = tempProjectType
} else {
log.Warn(err)
}

f := flags{
Expand Down
4 changes: 2 additions & 2 deletions src/services/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ func DetectType(directory string) (ProjectType, error) {
projectType = GoProject
}
if len(detectedRuntimes) == 0 {
return "", fmt.Errorf("cannot detect project type")
return "", fmt.Errorf("cannot detect the project type by checking the repository file structure, use the --project-type flag or the INITIUM_PROJECT_TYPE env variable to set the desired runtime")
}
if len(detectedRuntimes) > 1 {
return "", fmt.Errorf("more than one project runtimes detected (%v), use --project-type flag or the INITIUM_PROJECT_TYPE env variable to set the desired runtime", detectedRuntimes)
return "", fmt.Errorf("more than one project runtimes detected (%v), use the --project-type flag or the INITIUM_PROJECT_TYPE env variable to set the desired runtime", detectedRuntimes)
}
return projectType, nil
}
Expand Down

0 comments on commit 12fa85a

Please sign in to comment.