/// Compares a set of rules against a source path...
        /// Used for both RulesPresent and RulesNotePresent options
        /// Focus is pass/fail not detailed comparison output -see Tagdiff for more
        public TagTestCommand(TagTestCommandOptions opt)
        {
            _arg_srcPath               = opt.SourcePath;
            _arg_customRulesPath       = opt.CustomRulesPath;
            _arg_outputFile            = opt.OutputFilePath;
            _arg_consoleVerbosityLevel = opt.ConsoleVerbosityLevel ?? "medium";
            opt.TestType ??= "RulesPresent";
            _arg_logger = opt.Log;

            WriteOnce.ConsoleVerbosity verbosity = WriteOnce.ConsoleVerbosity.Medium;
            if (!Enum.TryParse(_arg_consoleVerbosityLevel, true, out verbosity))
            {
                throw new OpException(String.Format(ErrMsg.FormatString(ErrMsg.ID.CMD_INVALID_ARG_VALUE, "-x")));
            }
            WriteOnce.Verbosity = verbosity;

            if (!Enum.TryParse(opt.TestType, true, out _arg_tagTestType))
            {
                throw new OpException(ErrMsg.FormatString(ErrMsg.ID.CMD_INVALID_ARG_VALUE, opt.TestType));
            }

            _arg_ignoreDefaultRules = opt.IgnoreDefaultRules;
            _rulesSet = new RuleSet(_arg_logger);

            if (string.IsNullOrEmpty(opt.CustomRulesPath) && _arg_ignoreDefaultRules)
            {
                throw new OpException(ErrMsg.GetString(ErrMsg.ID.CMD_NORULES_SPECIFIED));
            }

            ConfigureRules();
            ConfigureOutput();
        }
Exemple #2
0
        string _arg_fileExclusionList;//see exclusion list

        /// Compares a set of rules against a source path...
        /// Used for both RulesPresent and RulesNotePresent options
        /// Focus is pass/fail not detailed comparison output -see Tagdiff for more
        public TagTestCommand(TagTestCommandOptions opt)
        {
            _arg_srcPath               = opt.SourcePath;
            _arg_customRulesPath       = opt.CustomRulesPath;
            _arg_outputFile            = opt.OutputFilePath;
            _arg_consoleVerbosityLevel = opt.ConsoleVerbosityLevel ?? "medium";
            _arg_tag_test_type_raw     = opt.TestType ?? "RulesPresent";
            _arg_logger            = opt.Log;
            _arg_log_file_path     = opt.LogFilePath;
            _arg_log_level         = opt.LogFileLevel;
            _arg_close_log_on_exit = Utils.CLIExecutionContext ? true : opt.CloseLogOnCommandExit;
            _arg_fileExclusionList = opt.FilePathExclusions;

            _arg_logger ??= Utils.SetupLogging(opt);
            WriteOnce.Log ??= _arg_logger;
            _rulesSet = new RuleSet(_arg_logger);

            try
            {
                ConfigureConsoleOutput();
                ConfigureCompareTest();
                ConfigureRules();
            }
            catch (Exception e) //group error handling
            {
                WriteOnce.Error(e.Message);
                if (_arg_close_log_on_exit)
                {
                    Utils.Logger  = null;
                    WriteOnce.Log = null;
                }
                throw;
            }
        }