public int Run(RunArgs ra) { interactive = !ra.InArgs.ContainsKey("-ni"); if (interactive) { Utils.ReadString("Images search pattern (*.jpg by default): ", ref sp, false); Utils.ReadString("Images map file: ", ref fmap, false); if (!string.IsNullOrEmpty(fmap)) { paths = File.ReadAllText(fmap).Split(Environment.NewLine); } else { "No map file was provided, will use the current dir as a source.".PrintLine(); paths = Directory.GetFiles(ra.RootDir.FullName, sp); } if (paths != null && paths.Length > 0) { Utils.ReadString("Destination folder: ", ref dest, true); Utils.ReadString("Mode [h, v, hv or r90]: ", ref mode, true); if (Array.IndexOf(MODES, mode) < 0) { throw new ArgumentNullException("-mode", "Incorrect mode"); } Utils.ReadString("Result image filename prefix [optional]: ", ref prf, false); Utils.ReadString("Result image filename suffix [optional]: ", ref sfx, false); } else { throw new ArgumentException("", $"There are no images in {ra.RootDir.FullName}"); } } else { if (ra.InArgs.ContainsKey("-out")) { dest = ra.InArgs.GetFirstValue("-out"); } else { throw new ArgumentNullException("-out"); } if (ra.InArgs.ContainsKey("-mode")) { mode = ra.InArgs.GetFirstValue("-mode"); if (Array.IndexOf(MODES, mode) < 0) { throw new ArgumentException("-mode", "Incorrect mode."); } } else { throw new ArgumentNullException("-mode"); } if (ra.InArgs.ContainsKey("-sp")) { sp = ra.InArgs.GetFirstValue("-sp"); } if (ra.InArgs.ContainsKey("-map")) { paths = File.ReadAllText(ra.InArgs.GetFirstValue("-map")).Split(Environment.NewLine); } else { "No map file was provided, will use the current dir as a source.".PrintLine(); paths = Directory.GetFiles(ra.RootDir.FullName, sp); } if (paths == null || paths.Length < 1) { throw new ArgumentException("", $"There are no images in {ra.RootDir.FullName}"); } if (ra.InArgs.ContainsKey("-prf")) { prf = ra.InArgs.GetFirstValue("-prf"); } if (ra.InArgs.ContainsKey("-sfx")) { prf = ra.InArgs.GetFirstValue("-sfx"); } } if (string.IsNullOrEmpty(prf)) { prf = string.Empty; } if (string.IsNullOrEmpty(sfx)) { sfx = string.Empty; } if (!Directory.Exists(dest)) { Directory.CreateDirectory(dest); } flip(); return(0); }