github.com/tilotech/tilores-cli@v0.28.0/internal/pkg/step/initprojectpath.go (about) 1 package step 2 3 import ( 4 "fmt" 5 "os" 6 "path/filepath" 7 ) 8 9 // InitProjectPath creates a step that gathers information about the project path. 10 func InitProjectPath(path string, finalModulePath *string) Step { 11 return func() error { 12 err := os.MkdirAll(path, 0750) 13 if err != nil { 14 return fmt.Errorf("failed to create project directory: %v", err) 15 } 16 17 err = os.Chdir(path) 18 if err != nil { 19 return err 20 } 21 22 if *finalModulePath == "" { 23 wd, err := os.Getwd() 24 if err != nil { 25 return fmt.Errorf("failed to get current working directory: %v", err) 26 } 27 *finalModulePath = filepath.Base(wd) 28 } 29 return nil 30 } 31 }