fix(cmd/recipe): correct import path and add error handling for user input
- Updated import path for recipe package to match module name. - Added error checking for fmt.Scanln to handle potential input errors gracefully.
This commit is contained in:
parent
8e414faa10
commit
dcac119e57
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"repos.gmgauthier.com/gmgauthier/grokkit/internal/recipe" // adjust if your module name differs
|
"gmgauthier.com/grokkit/internal/recipe" // adjust if your module name differs
|
||||||
)
|
)
|
||||||
|
|
||||||
var recipeCmd = &cobra.Command{
|
var recipeCmd = &cobra.Command{
|
||||||
@ -84,7 +84,10 @@ func resolveRecipePath(nameOrPath string) (string, error) {
|
|||||||
if _, err := os.Stat(global); err == nil {
|
if _, err := os.Stat(global); err == nil {
|
||||||
fmt.Printf("Recipe %q not found in project.\nFound globally at %s\nUse this one? [y/N] ", nameOrPath, global)
|
fmt.Printf("Recipe %q not found in project.\nFound globally at %s\nUse this one? [y/N] ", nameOrPath, global)
|
||||||
var answer string
|
var answer string
|
||||||
fmt.Scanln(&answer)
|
_, err := fmt.Scanln(&answer)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
if strings.HasPrefix(strings.ToLower(answer), "y") {
|
if strings.HasPrefix(strings.ToLower(answer), "y") {
|
||||||
return global, nil
|
return global, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user