private FolderParams UpdateValues(int choice, FolderParams folderParam) { FolderParams result = folderParam; string response = string.Empty; switch (choice) { case 0: for (int i = 1; i < 4; i++) { result = UpdateValues(i, result); } break; case 1: result.SourceRoot = UpdateValue(result.SourceRoot); break; case 2: result.TargetRoot = UpdateValue(result.TargetRoot); break; case 3: result.ModFolderName = UpdateValue(result.ModFolderName); break; default: break; } return(result); }
public void Execute() { folderParam = GetFolders(folderParam); var avilableMods = modFilesService.GetMods(folderParam.SourceRoot); ShowMods(avilableMods); int[] selectedMods = SelectMods(); modFilesService.CleanTarget(Path.Combine(folderParam.TargetRoot, folderParam.ModFolderName)); CopyMods(avilableMods, selectedMods); }
private FolderParams GetFolders(FolderParams folderParam) { bool isChanged = false; Console.WriteLine($"{folderParam}"); //TODO! Change this block to be more efficient //If anyone is changed set isChanged //add the folderparam == null check in execute if (folderParam == null) { Console.WriteLine("The required files are empty, please enter the needed directories..."); folderParam = UpdateValues(0, new FolderParams()); isChanged = true; } else { int chosenOption = 0; do { //TODO! if a single one is empty go here //while loop to ask the question again when parse fails? Console.WriteLine( "which would you like to change?\n" + "0: all three options\n" + $"1: the root directory where the original modfiles are stored (currently in {folderParam.SourceRoot})\n" + $"2: the target directory where the modfiles are copied into the game (currently in {folderParam.TargetRoot})\n" + $"3: the name of the target mod folder where the files are copied into (currently named {folderParam.ModFolderName})\n" + "9: quit"); string input = Console.ReadLine(); string msg = string.Empty; if (Int32.TryParse(input, out chosenOption)) { if (chosenOption > -1 && chosenOption < 4) { folderParam = UpdateValues(chosenOption, folderParam); } else { msg = "not a valid selection"; } } else { msg = "not a valid number"; } Console.WriteLine(msg); } while (chosenOption != 9); } //Keep as it is! Update as we do already isChanged = !folderParam.Equals(options.Value);//The values differs if (isChanged) { options.Update(newFolderParam => { newFolderParam.SourceRoot = folderParam.SourceRoot; newFolderParam.TargetRoot = folderParam.TargetRoot; newFolderParam.ModFolderName = folderParam.ModFolderName; }); } return(folderParam); }
public Executor(IModFilesService modFilesService, IWritableOptions <FolderParams> options) { this.modFilesService = modFilesService; this.options = options; folderParam = options.Value; }