Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void ProcessArgs(IEnumerable<string> args)
- {
- string output = null;
- var dirs = new Stack<string>();
- var files = new Stack<string>();
- string searchPattern = "*.*";
- var option = SearchOption.AllDirectories;
- foreach (string arg in args)
- {
- string argument = arg.ToLower().Trim();
- // Get output path
- Match match = Regex.Match(argument, @"/output=(?<Path>[^""]+)");
- {
- if (match.Success)
- {
- output = match.Groups["Path"].Value;
- continue;
- }
- }
- // Get input files
- match = Regex.Match(argument, @"/inputfile=(?<Path>[^""]+)");
- if (match.Success)
- {
- files.Push(match.Groups["Path"].Value);
- continue;
- }
- // Get input files
- match = Regex.Match(argument, @"/inputdir=(?<Path>[^""]+)");
- if (match.Success)
- {
- dirs.Push(match.Groups["Path"].Value);
- continue;
- }
- // Get search option
- if (argument == "/true")
- {
- option = SearchOption.AllDirectories;
- }
- else if (argument == "/false")
- {
- option = SearchOption.TopDirectoryOnly;
- }
- // Get search pattern
- match = Regex.Match(argument, @"/searchpattern=(?<Pat>[^""]+)");
- if (match.Success)
- {
- searchPattern = match.Groups["Pat"].Value;
- }
- }
- if (output == null)
- {
- ShowErrorMessage("No output path specified in arguments");
- return;
- }
- if (files.Count == 0 && dirs.Count == 0)
- {
- ShowErrorMessage("No paths to content specified");
- return;
- }
- foreach (string dir in dirs.Where(d => !Directory.Exists(d)))
- {
- ShowErrorMessage(@"The directory """ + dir + @""" does not exist");
- return;
- }
- foreach (string file in files.Where(f => !Directory.Exists(f)))
- {
- ShowErrorMessage(@"The file """ + file + @""" does not exist");
- return;
- }
- var combiner = new SourceCombiner(output);
- combiner.SearchOption = option;
- combiner.SearchPattern = searchPattern;
- combiner.AppendFiles(files.ToArray());
- combiner.AppendDirectories(dirs.ToArray());
- combiner.Save();
- }
Advertisement
Add Comment
Please, Sign In to add comment