Пример #1
0
        private static int Execute <TOptions>(AbstractCommand <TOptions> command) where TOptions : AbstractCommandOptions
        {
#if DEBUG
            if (ShouldLog(Verbosity.Diagnostic))
            {
                command.Options.WriteDiagnostic();
            }
#endif
            CommandResult result = command.Execute();

            switch (result)
            {
            case CommandResult.Success:
                return(0);

            case CommandResult.NoMatch:
                return(1);

            case CommandResult.Fail:
            case CommandResult.Canceled:
                return(2);

            default:
                throw new InvalidOperationException($"Unknown enum value '{result}'.");
            }
        }
Пример #2
0
        private static int Execute <TOptions>(
            AbstractCommand <TOptions> command,
            AbstractCommandLineOptions options) where TOptions : AbstractCommandOptions
        {
#if DEBUG
            if (ShouldLog(Verbosity.Diagnostic))
            {
                WriteLine("--- RAW PARAMETERS ---", Verbosity.Diagnostic);
                DiagnosticWriter.WriteParameters(options);
                WriteLine("--- END OF RAW PARAMETERS ---", Verbosity.Diagnostic);

                WriteLine("--- APP PARAMETERS ---", Verbosity.Diagnostic);
                command.Options.WriteDiagnostic();
                WriteLine("--- END OF APP PARAMETERS ---", Verbosity.Diagnostic);
            }
#endif
            CommandResult result = command.Execute();

            switch (result)
            {
            case CommandResult.Success:
                return(ExitCodes.Match);

            case CommandResult.NoMatch:
                return(ExitCodes.NoMatch);

            case CommandResult.Fail:
            case CommandResult.Canceled:
                return(ExitCodes.Error);

            default:
                throw new InvalidOperationException($"Unknown enum value '{result}'.");
            }
        }