示例#1
0
        public VerifyRulesCommand(VerifyRulesCommandOptions opt)
        {
            _arg_verify_default_rules  = opt.VerifyDefaultRules;
            _arg_custom_rules_path     = opt.CustomRulesPath;
            _arg_outputFile            = opt.OutputFilePath;
            _arg_consoleVerbosityLevel = opt.ConsoleVerbosityLevel ?? "medium";
            _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;

            _rules_path = _arg_verify_default_rules ? Utils.GetPath(Utils.AppPath.defaultRulesSrc) : _arg_custom_rules_path;

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

            try
            {
                ConfigureConsoleOutput();
                ConfigFileOutput();
                ConfigRules();
            }
            catch (Exception e) //group error handling
            {
                WriteOnce.Error(e.Message);
                if (_arg_close_log_on_exit)
                {
                    Utils.Logger  = null;
                    WriteOnce.Log = null;
                }
                throw;
            }
        }
        public VerifyRulesCommand(VerifyRulesCommandOptions opt)
        {
            _arg_customRulesPath    = opt.CustomRulesPath;
            _arg_ignoreDefaultRules = opt.IgnoreDefaultRules;
            _arg_outputFile         = opt.OutputFilePath;
            _arg_logger             = opt.Log;

            if (!Enum.TryParse(opt.ConsoleVerbosityLevel, true, out _arg_consoleVerbosityLevel))
            {
                throw new OpException(String.Format(ErrMsg.FormatString(ErrMsg.ID.CMD_INVALID_ARG_VALUE, "-x")));
            }
            WriteOnce.Verbosity = _arg_consoleVerbosityLevel;
            ConfigureOutput();
            ConfigRules();
        }
        public VerifyRulesCommand(VerifyRulesCommandOptions opt)
        {
            _arg_customRulesPath       = opt.CustomRulesPath;
            _arg_outputFile            = opt.OutputFilePath;
            _arg_consoleVerbosityLevel = opt.ConsoleVerbosityLevel ?? "medium";
            _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;

            ConfigOutput();
            ConfigRules();
        }