//[TestMethod]
        public void TestCompile()
        {
            var compileCommand = new CompileCommand();

            var outputWriter = Console.Out;                                      //new StreamWriter(Console.OpenStandardError());
            var errorWriter  = new ColoredWriter(Console.Out, ConsoleColor.Red); //new StreamWriter(Console.OpenStandardError());

            var commandContext = CommandContext.Parse(new[]
            {
                "/home/amk/Temp/ShellScript/variables.shellscript",
                "/home/amk/Temp/ShellScript/variables.sh",
                "unix-bash",
                "--verbose",
                "--echo-dev",
            });

            Platforms.AddPlatform(new UnixBashPlatform());

            compileCommand.Execute(outputWriter, errorWriter, outputWriter, outputWriter, commandContext);
        }
Esempio n. 2
0
        public void TestCompiler()
        {
            //try
            {
                Platforms.AddPlatform(new UnixBashPlatform());

                var compiler = new Compiler();
                var result   = compiler.CompileFromSource(
                    Console.Out,
                    Console.Out,
                    Console.Out,
                    "/home/amk/Temp/ShellScript/variables.shellscript",
                    "/home/amk/Temp/ShellScript/variables.sh",
                    "unix-bash",
                    CompilerFlags.CreateDefault()
                    );

                GC.KeepAlive(result);
            }
            //catch (Exception ex)
            {
                Debugger.Break();
            }
        }
Esempio n. 3
0
        static int Main(string[] args)
        {
            var outputWriter = Console.Out; //new StreamWriter(Console.OpenStandardError());

            TextWriter errorWriter = new ColoredWriter(Console.Error, ConsoleColor.Red);

            var warningWriter = new ColoredWriter(Console.Out, ConsoleColor.Yellow);
            var logWriter     = new ColoredWriter(Console.Out, ConsoleColor.White);

            CommandContext commandContext = null;

            try
            {
                commandContext = CommandContext.Parse(args);

                if (commandContext.AnySwitch(DuplexErrorOutputSwitchName))
                {
                    var errorStdOutWriter = new ColoredWriter(Console.Out, ConsoleColor.Red);
                    var errorErrOutWriter = Console.Error;
                    errorWriter = new MultiStreamWriter(errorStdOutWriter, errorErrOutWriter);
                }

                Platforms.AddPlatform(new UnixBashPlatform());

                foreach (var command in AvailableCommands)
                {
                    if (command.CanHandle(commandContext))
                    {
                        if (commandContext.AnySwitch("help") && command != HelpCommand)
                        {
                            HelpCommand.ShowHelp(outputWriter, command);

                            return((int)ResultCodes.Successful);
                        }

                        return((int)command.Execute(outputWriter, errorWriter, warningWriter, logWriter,
                                                    commandContext));
                    }
                }
            }
            catch (Exception ex)
            {
                if (commandContext == null)
                {
                    errorWriter.WriteLine(ex.Message);
                    return((int)ResultCodes.Failure);
                }

                Action <TextWriter, TextWriter, TextWriter, TextWriter, Exception> writer = null;

                if (commandContext.AnySwitch("verbose"))
                {
                    writer = WriteCompilerDebugInfo;
                }
                else if (commandContext.AnySwitch(CompatibleOutputSwitchName))
                {
                    writer = WriteCleanErrorInfo;
                }

                if (writer == null)
                {
                    errorWriter.WriteLine(ex.Message);
                }
                else
                {
                    writer(outputWriter, errorWriter, warningWriter, logWriter, ex);
                }

                return((int)ResultCodes.Failure);
            }

            errorWriter.WriteLine(DesignGuidelines.ErrorOutputHead + " Invalid command passed. ({0})",
                                  args.Length > 0 ? args[0] : "null");
            return((int)ResultCodes.Failure);
        }