Example #1
0
        private static int EnsureDirectoryToScanAndRefFileExistsAndStartScan(ScanOptions opts)
        {
            if (opts.WhatIf)
            {
                Console.WriteLine("Skipping scan due to --whatif argument");
                WhatIf.IWouldScan(opts);
                return(ExitCodes.Success);
            }

            if (!Directory.Exists(opts.DirectoryToScan))
            {
                Console.WriteLine($"{opts.DirectoryToScan} does not exist");
                return(ExitCodes.ScanDirDoesNotExist);
            }

            if (opts.ReferenceFileIsSpecified && !File.Exists(opts.ReferenceFile))
            {
                Console.WriteLine($"{opts.ReferenceFile} does not exist");
                return(ExitCodes.RefFileDoesNotExist);
            }

            ScanOptions = opts;

            var comparison = Scan();

            var report = new ReportBuilder(comparison).Build();

            MailHelper.SendReportByMailDontThrow(report.ToString(), opts);

            return(ExitCodes.Success);
        }
Example #2
0
        private static void CreateReferenceFile(IDirectoryScanner scanner)
        {
            if (CreateRefFileOptions.WhatIf)
            {
                Console.WriteLine("Skipping reference file creation due to --whatif argument");
                WhatIf.IWouldCreateAReferenceFile(CreateRefFileOptions);
                return;
            }

            MaybePreserveOldeReferenceFile();

            new JsonReferenceFileCreator(scanner, Formatting.Indented)
            .CreateReferenceFile(CreateRefFileOptions.ReferenceFilepath);
        }