private static CommandResultsWriter GetVerifyRulesWriter(CLIVerifyRulesCmdOptions options)
        {
            CommandResultsWriter?writer;

            switch (options.OutputFileFormat.ToLower())
            {
            case "_dummy":
                writer = new VerifyRulesDummyWriter();
                break;

            case "json":
                writer = new JsonWriter();
                break;

            case "text":
                writer = new VerifyRulesTextWriter();
                break;

            default:
                WriteOnce.Error(MsgHelp.FormatString(MsgHelp.ID.CMD_INVALID_ARG_VALUE, "-f"));
                throw new OpException((MsgHelp.FormatString(MsgHelp.ID.CMD_INVALID_ARG_VALUE, "-f")));
            }

            //assign the stream as a file or console
            writer.OutputFileName = options.OutputFilePath;
            writer.TextWriter     = GetTextWriter(writer.OutputFileName);

            return(writer);
        }
Exemple #2
0
        private static int VerifyOutputArgsRun(CLIVerifyRulesCmdOptions options)
        {
            loggerFactory = options.GetLoggerFactory();

            CommonOutputChecks(options);
            return(RunVerifyRulesCommand(options));
        }
Exemple #3
0
        private static int VerifyOutputArgsRun(CLIVerifyRulesCmdOptions options)
        {
            Logger logger = Utils.SetupLogging(options, true);

            WriteOnce.Log = logger;
            options.Log   = logger;

            CommonOutputChecks(options);
            return(RunVerifyRulesCommand(options));
        }
Exemple #4
0
 /// <summary>
 /// Responsible for returning the correct cmd and format writer for output of cmd results.  An an output
 /// file will be opened as a stream if provided otherwise the console.out stream is used
 /// A downcast is expected as the input param containing the common output format and filepath for simplifying
 /// the allocation to a single method and serves as a type selector but is also recast for command specific
 /// options in the writer as needed
 /// </summary>
 /// <param name="options"></param>
 /// <returns></returns>
 public CommandResultsWriter GetWriter(CLICommandOptions options)
 {
     return(options switch
     {
         CLIAnalyzeCmdOptions cliAnalyzeCmdOptions => GetAnalyzeWriter(cliAnalyzeCmdOptions),
         CLITagDiffCmdOptions cliTagDiffCmdOptions => GetTagDiffWriter(cliTagDiffCmdOptions),
         CLIExportTagsCmdOptions cliExportTagsCmdOptions => GetExportTagsWriter(cliExportTagsCmdOptions),
         CLIVerifyRulesCmdOptions cliVerifyRulesCmdOptions => GetVerifyRulesWriter(cliVerifyRulesCmdOptions),
         CLIPackRulesCmdOptions cliPackRulesCmdOptions => GetPackRulesWriter(cliPackRulesCmdOptions),
         _ => throw new OpException($"Unrecognized object type {options.GetType().Name} in writer request")
     });
Exemple #5
0
        private static int RunVerifyRulesCommand(CLIVerifyRulesCmdOptions cliOptions)
        {
            VerifyRulesCommand command = new(new VerifyRulesOptions()
            {
                VerifyDefaultRules = cliOptions.VerifyDefaultRules,
                CustomRulesPath = cliOptions.CustomRulesPath,
                ConsoleVerbosityLevel = cliOptions.ConsoleVerbosityLevel,
                Failfast = cliOptions.Failfast,
                Log = cliOptions.Log
            });

            VerifyRulesResult exportTagsResult = command.GetResult();

            ResultsWriter.Write(exportTagsResult, cliOptions);

            return((int)exportTagsResult.ResultCode);
        }
Exemple #6
0
        private static int RunVerifyRulesCommand(CLIVerifyRulesCmdOptions cliOptions)
        {
            VerifyRulesCommand command = new(new VerifyRulesOptions()
            {
                VerifyDefaultRules = cliOptions.VerifyDefaultRules,
                CustomRulesPath = cliOptions.CustomRulesPath,
                CustomCommentsPath = cliOptions.CustomCommentsPath,
                CustomLanguagesPath = cliOptions.CustomLanguagesPath,
                Failfast = cliOptions.Failfast,
            }, loggerFactory);

            VerifyRulesResult exportTagsResult = command.GetResult();

            ResultsWriter writer = new(loggerFactory);

            writer.Write(exportTagsResult, cliOptions);

            return((int)exportTagsResult.ResultCode);
        }