@@ -382,7 +382,7 @@ func runAdvancedMenu(app Application, config *config.Config) error {
382382 runDetailedSetupStatus (app , config )
383383 case "Change scan roots" :
384384 app .GetUtils ().ClearScreen ()
385- changeScanRoots (app , config )
385+ runManageCustomEnginePaths (app , config )
386386 app .GetUtils ().ClearScreen ()
387387 case "Change branch to track" :
388388 app .GetUtils ().ClearScreen ()
@@ -724,7 +724,7 @@ func runEngineEditOptions(app Application, config *config.Config, status detecti
724724// runSettings shows the settings menu
725725func runSettings (app Application , config * config.Config ) error {
726726 items := []string {
727- "Add Engine Path " ,
727+ "Manage Custom Engine Paths " ,
728728 "Change Branch to Track" ,
729729 "Open Plugin Repository" ,
730730 "Open Data Directory" ,
@@ -748,8 +748,8 @@ func runSettings(app Application, config *config.Config) error {
748748 }
749749
750750 switch choice {
751- case "Add Engine Path " :
752- changeScanRoots (app , config )
751+ case "Manage Custom Engine Paths " :
752+ runManageCustomEnginePaths (app , config )
753753 return nil
754754 case "Change Branch to Track" :
755755 changeBranch (app , config )
@@ -768,6 +768,150 @@ func runSettings(app Application, config *config.Config) error {
768768 return nil
769769}
770770
771+ // runManageCustomEnginePaths shows options to manage custom engine paths
772+ func runManageCustomEnginePaths (app Application , config * config.Config ) error {
773+ for {
774+ choice , err := showManageCustomEnginePathsMenu (app , config )
775+ if err != nil {
776+ if err == promptui .ErrInterrupt {
777+ return nil
778+ }
779+ return err
780+ }
781+
782+ switch choice {
783+ case "Add Custom Engine Path" :
784+ addCustomEnginePath (app , config )
785+ case "Delete Custom Engine Path" :
786+ deleteCustomEnginePath (app , config )
787+ case "Back" :
788+ return nil
789+ }
790+ }
791+ }
792+
793+ // showManageCustomEnginePathsMenu displays the manage custom engine paths menu
794+ func showManageCustomEnginePathsMenu (app Application , config * config.Config ) (string , error ) {
795+ fmt .Println (color .New (color .FgCyan , color .Bold ).Sprint ("🔍 Manage Custom Engine Paths" ))
796+ fmt .Println ()
797+
798+ // Show current custom engine paths
799+ if len (config .CustomEngineRoots ) == 0 {
800+ fmt .Println ("No custom engine paths configured." )
801+ } else {
802+ fmt .Println ("Current custom engine paths:" )
803+ for i , root := range config .CustomEngineRoots {
804+ fmt .Printf (" %d. %s\n " , i + 1 , root )
805+ }
806+ }
807+ fmt .Println ()
808+
809+ items := []string {
810+ "Add Custom Engine Path" ,
811+ "Delete Custom Engine Path" ,
812+ "Back" ,
813+ }
814+
815+ prompt := promptui.Select {
816+ Label : "Select an option" ,
817+ Items : items ,
818+ Size : 10 ,
819+ HideHelp : true ,
820+ Stdout : & utils.BellSkipper {},
821+ }
822+
823+ _ , result , err := prompt .Run ()
824+ return result , err
825+ }
826+
827+ // addCustomEnginePath allows the user to add a new custom engine path
828+ func addCustomEnginePath (app Application , config * config.Config ) {
829+ fmt .Println (color .New (color .FgCyan , color .Bold ).Sprint ("➕ Add Custom Engine Path" ))
830+ fmt .Println ()
831+
832+ fmt .Print ("Enter path to scan: " )
833+ scanner := bufio .NewScanner (os .Stdin )
834+ scanner .Scan ()
835+ newRoot := strings .TrimSpace (scanner .Text ())
836+
837+ // Handle quoted paths by removing quotes if present
838+ newRoot = strings .Trim (newRoot , "\" " )
839+
840+ if newRoot != "" {
841+ // Check if path already exists
842+ for _ , existingRoot := range config .CustomEngineRoots {
843+ if existingRoot == newRoot {
844+ fmt .Printf ("⚠️ Path '%s' is already configured.\n " , newRoot )
845+ utils .Pause ()
846+ return
847+ }
848+ }
849+
850+ config .CustomEngineRoots = append (config .CustomEngineRoots , newRoot )
851+ if err := app .GetConfig ().Save (config ); err != nil {
852+ fmt .Printf ("❌ Failed to save configuration: %v\n " , err )
853+ } else {
854+ fmt .Printf ("✅ Custom engine path added: %s\n " , newRoot )
855+ }
856+ } else {
857+ fmt .Println ("❌ Empty path not allowed." )
858+ }
859+
860+ utils .Pause ()
861+ }
862+
863+ // deleteCustomEnginePath allows the user to delete an existing custom engine path
864+ func deleteCustomEnginePath (app Application , config * config.Config ) {
865+ fmt .Println (color .New (color .FgRed , color .Bold ).Sprint ("🗑️ Delete Custom Engine Path" ))
866+ fmt .Println ()
867+
868+ if len (config .CustomEngineRoots ) == 0 {
869+ fmt .Println ("No custom engine paths to delete." )
870+ utils .Pause ()
871+ return
872+ }
873+
874+ fmt .Println ("Select a custom engine path to delete:" )
875+ fmt .Println ()
876+
877+ // Show current paths with numbers
878+ for i , root := range config .CustomEngineRoots {
879+ fmt .Printf (" %d. %s\n " , i + 1 , root )
880+ }
881+ fmt .Println ()
882+
883+ fmt .Print ("Enter path number to delete (or 0 to cancel): " )
884+ var choice int
885+ fmt .Scanln (& choice )
886+
887+ if choice == 0 {
888+ return
889+ }
890+
891+ if choice < 1 || choice > len (config .CustomEngineRoots ) {
892+ fmt .Println ("❌ Invalid selection." )
893+ utils .Pause ()
894+ return
895+ }
896+
897+ // Confirm deletion
898+ pathToDelete := config .CustomEngineRoots [choice - 1 ]
899+ if ! utils .Confirm (fmt .Sprintf ("Are you sure you want to delete '%s'?" , pathToDelete )) {
900+ return
901+ }
902+
903+ // Remove the path from the slice
904+ config .CustomEngineRoots = append (config .CustomEngineRoots [:choice - 1 ], config .CustomEngineRoots [choice :]... )
905+
906+ if err := app .GetConfig ().Save (config ); err != nil {
907+ fmt .Printf ("❌ Failed to save configuration: %v\n " , err )
908+ } else {
909+ fmt .Printf ("✅ Custom engine path deleted: %s\n " , pathToDelete )
910+ }
911+
912+ utils .Pause ()
913+ }
914+
771915// runSetupForEngine sets up a specific engine
772916func runSetupForEngine (app Application , config * config.Config , enginePath , engineVersion string ) error {
773917 fmt .Printf ("Setting up UE %s...\n " , engineVersion )
@@ -1041,33 +1185,6 @@ func showConfiguration(config *config.Config) {
10411185 utils .Pause ()
10421186}
10431187
1044- // changeScanRoots allows the user to modify custom engine scan roots
1045- func changeScanRoots (app Application , config * config.Config ) {
1046- fmt .Println (color .New (color .FgCyan , color .Bold ).Sprint ("🔍 Custom Engine Scan Roots" ))
1047- fmt .Println ()
1048-
1049- fmt .Printf ("Current custom roots: %v\n " , config .CustomEngineRoots )
1050- fmt .Println ()
1051-
1052- if utils .Confirm ("Would you like to add a new scan root?" ) {
1053- fmt .Print ("Enter path to scan: " )
1054- scanner := bufio .NewScanner (os .Stdin )
1055- scanner .Scan ()
1056- newRoot := strings .TrimSpace (scanner .Text ())
1057-
1058- // Handle quoted paths by removing quotes if present
1059- newRoot = strings .Trim (newRoot , "\" " )
1060-
1061- if newRoot != "" {
1062- config .CustomEngineRoots = append (config .CustomEngineRoots , newRoot )
1063- app .GetConfig ().Save (config )
1064- fmt .Println ("✅ Scan root added!" )
1065- }
1066- }
1067-
1068- utils .Pause ()
1069- }
1070-
10711188// changeBranch allows the user to change the tracked branch
10721189func changeBranch (app Application , config * config.Config ) {
10731190 fmt .Println (color .New (color .FgCyan , color .Bold ).Sprint ("🌿 Change Tracked Branch" ))
0 commit comments