File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -495,6 +495,26 @@ func hasGo() bool {
495495}
496496
497497func (h * Handlers ) showTrainingStartPrompt (trainingDir string ) error {
498+ homeDir , _ := os .UserHomeDir ()
499+ if homeDir != "" {
500+ absTrainingDir , err := filepath .Abs (trainingDir )
501+ if err == nil && absTrainingDir == homeDir {
502+ if ! internal .IsStdinTerminal () {
503+ return fmt .Errorf ("refusing to init in home directory %s — create a subdirectory first" , homeDir )
504+ }
505+
506+ fmt .Println ()
507+ fmt .Println (color .YellowString (" ⚠ Warning: you are about to clone training files directly into your home directory (%s)." , homeDir ))
508+ fmt .Println (color .YellowString (" This is almost never what you want. We recommend creating a subdirectory instead." ))
509+ fmt .Println ()
510+
511+ if ! internal .FConfirmPrompt (color .YellowString ("Are you sure you want to continue?" ), os .Stdin , os .Stdout ) {
512+ return ErrInterrupted
513+ }
514+ return nil
515+ }
516+ }
517+
498518 fmt .Printf (
499519 "This command will clone training source code to %s directory.\n " ,
500520 trainingDir ,
You can’t perform that action at this time.
0 commit comments