Exemple #1
0
        private int Run(string[] args)
        {
            // Add a default trace listener
            Trace.AddListener(new SimpleColorConsoleTraceListener {
                TraceOutputOptions = System.Diagnostics.TraceOptions.None
            });

            // Output version info
            Trace.Information($"Wyam version {Engine.Version}");

            // It's not a serious console app unless there's some ASCII art
            OutputLogo();

            // Make sure we're not running under Mono
            if (Type.GetType("Mono.Runtime") != null)
            {
                Trace.Critical("The Mono runtime is not supported. Please check the GitHub repository and issue tracker for information on .NET Core support for cross platform execution.");
                return((int)ExitCode.UnsupportedRuntime);
            }

            // Parse the command line
            Preprocessor preprocessor = new Preprocessor();
            Command      command;

            try
            {
                bool hasParseArgsErrors;
                command = CommandParser.Parse(args, preprocessor, out hasParseArgsErrors);
                if (command == null)
                {
                    return(hasParseArgsErrors ? (int)ExitCode.CommandLineError : (int)ExitCode.Normal);
                }
            }
            catch (Exception ex)
            {
                Trace.Error("Error while parsing command line: {0}", ex.Message);
                if (Trace.Level == SourceLevels.Verbose)
                {
                    Trace.Error("Stack trace:{0}{1}", Environment.NewLine, ex.StackTrace);
                }
                return((int)ExitCode.CommandLineError);
            }

            // Run the command
            return((int)command.Run(preprocessor));
        }
Exemple #2
0
        private int Run(string[] args)
        {
            // Add a default trace listener
            Trace.AddListener(new SimpleColorConsoleTraceListener {
                TraceOutputOptions = System.Diagnostics.TraceOptions.None
            });

            // Output version info
            AssemblyInformationalVersionAttribute versionAttribute
                = Attribute.GetCustomAttribute(typeof(Program).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;

            Trace.Information("Wyam version {0}", versionAttribute == null ? "unknown" : versionAttribute.InformationalVersion);

            // It's not a serious console app unless there's some ASCII art
            OutputLogo();

            // Parse the command line
            Preprocessor preprocessor = new Preprocessor();
            Command      command;

            try
            {
                bool hasParseArgsErrors;
                command = CommandParser.Parse(args, preprocessor, out hasParseArgsErrors);
                if (command == null)
                {
                    return(hasParseArgsErrors ? (int)ExitCode.CommandLineError : (int)ExitCode.Normal);
                }
            }
            catch (Exception ex)
            {
                Trace.Error("Error while parsing command line: {0}", ex.Message);
                if (Trace.Level == SourceLevels.Verbose)
                {
                    Trace.Error("Stack trace:{0}{1}", Environment.NewLine, ex.StackTrace);
                }
                return((int)ExitCode.CommandLineError);
            }

            // Run the command
            return((int)command.Run(preprocessor));
        }