public PackRulesCommand(PackRulesCommandOptions opt) { _path = opt.RepackDefaultRules ? Utils.GetPath(Utils.AppPath.defaultRulesSrc) : opt.CustomRulesPath; _outputfile = opt.RepackDefaultRules && String.IsNullOrEmpty(opt.OutputFilePath) ? Utils.GetPath(Utils.AppPath.defaultRulesPackedFile) : opt.OutputFilePath; _arg_consoleVerbosityLevel = opt.ConsoleVerbosityLevel; if (!opt.RepackDefaultRules && string.IsNullOrEmpty(opt.CustomRulesPath) || string.IsNullOrEmpty(_outputfile)) { throw new OpException(ErrMsg.FormatString(ErrMsg.ID.PACK_MISSING_OUTPUT_ARG)); } _outputfile = Path.GetFullPath(_outputfile); _indent = !opt.NotIndented; 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; }
public PackRulesCommand(PackRulesCommandOptions opt) { _arg_repack_default_rules = opt.RepackDefaultRules; _arg_indent = !opt.NotIndented; _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_repack_default_rules ? Utils.GetPath(Utils.AppPath.defaultRulesSrc) : _arg_custom_rules_path; _arg_outputfile = _arg_repack_default_rules && String.IsNullOrEmpty(_arg_custom_rules_path) ? Utils.GetPath(Utils.AppPath.defaultRulesPackedFile) : _arg_outputfile; _arg_logger ??= Utils.SetupLogging(opt); WriteOnce.Log ??= _arg_logger; ConfigureConsoleOutput(); try { ConfigFileOutput(); ConfigRules(); } catch (Exception e) { WriteOnce.Error(e.Message); if (_arg_close_log_on_exit) { Utils.Logger = null; WriteOnce.Log = null; } throw; } }