public ExportTagsCommand(ExportTagsCommandOptions opt)
        {
            _rules = new RuleSet(WriteOnce.Log);
            _arg_customRulesPath       = opt.CustomRulesPath;
            _arg_outputFile            = opt.OutputFilePath;
            _arg_ignoreDefaultRules    = opt.IgnoreDefaultRules;
            _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;

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

            try
            {
                ConfigureConsoleOutput();
                ConfigFileOutput();
                ConfigRules();
            }
            catch (Exception e)
            {
                WriteOnce.Error(e.Message);
                if (_arg_close_log_on_exit)
                {
                    Utils.Logger  = null;
                    WriteOnce.Log = null;
                }
                throw;
            }
        }
Example #2
0
        public ExportTagsCommand(ExportTagsCommandOptions opt)
        {
            _rules = new RuleSet(WriteOnce.Log);
            _arg_customRulesPath    = opt.CustomRulesPath;
            _arg_outputFile         = opt.OutputFilePath;
            _arg_ignoreDefaultRules = opt.IgnoreDefaultRules;
            _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();
        }