Example #1
0
        protected void findAction(FolderName folder)
        {
            folder.Must().Value.Must().Exist().OrThrow();

            var finder = new Finder(Pattern, Not, Unless, Include, IncludeExt, Exclude, ExcludeExt);

            if (Replacement.IsNotEmpty())
            {
                var replacement = Replacement.Replace("^", "$");
                truncFunc = line => line.Substitute(Pattern, replacement);
            }
            else if (Truncate.If(out var truncate))
            {
                if (truncate.IsIntegral())
                {
                    var amount = truncate.ToInt();
                    truncFunc = line => line.Exactly(amount);
                }
                else if (truncate == "-")
                {
                    truncFunc = line => line;
                }
                else
                {
                    truncFunc = line => line.Exactly(80);
                }
            }
            else
            {
                truncFunc = line => line;
            }

            fileTally = 0;
            lineTally = 0;

            if (Mark)
            {
                matchFolderMarked(folder, finder);
            }
            else
            {
                matchFolder(folder, finder, result => truncFunc(result.Line), true);
            }
        }