Exemple #1
0
 public CommandArgs(CommandArgs arg)
 {
     Values.AddRange(arg.Values);
 }
Exemple #2
0
        private static ProcessResult ExecAsync(CommandArgs args, bool redirect, Action <string, Process> onNewLine = null, TimeSpan?timeout = null)
        {
            if (!args.IsSet())
            {
                return(null);
            }

            var fileName  = args[0].GetEnv();
            var arguments = args.Pop(1).ToString().GetEnv();

            var start = new ProcessStartInfo(fileName);

            if (arguments.Length > 0)
            {
                start.Arguments = arguments;
            }

            if (redirect)
            {
                start.RedirectStandardOutput = true;
                start.RedirectStandardError  = true;
                start.RedirectStandardError  = true;
                start.UseShellExecute        = false;
            }

            Console.WriteLine(fileName + " " + arguments);

            var proc   = Process.Start(start);
            var result = new ProcessResult(proc, timeout);

            if (redirect)
            {
                var th = new Thread(() =>
                {
                    var buf = new char[1];
                    var sb  = new StringBuilder();
                    while (true)
                    {
                        var count = proc.StandardOutput.Read(buf, 0, 1);
                        if (count == 0)
                        {
                            break;
                        }
                        Console.Write(buf[0]);
                        if (buf[0] == '\n')
                        {
                            var line = sb.ToString();
                            onNewLine?.Invoke(line, proc);
                            sb.Clear();
                        }
                        else
                        {
                            if (buf[0] != '\r')
                            {
                                sb.Append(buf[0]);
                            }
                        }
                    }
                });
                th.Start();

                //var data = proc.StandardOutput.ReadToEnd();
                var error = proc.StandardError.ReadToEnd();
                //Console.WriteLine(data);
                Console.WriteLine(error);
            }

            return(result);
        }
Exemple #3
0
        private static CommandResult BuildImage(CommandArgs args)
        {
            Console.WriteLine("Starting Build...");

            string file;

            if (args[0] == "loader")
            {
                file = Env.Get("ABANU_BOOTLOADER_EXE");

                var builderBoot = new AbanuBuilder_Loader(file);
                builderBoot.Build();
            }
            else if (args[0] == "kernel")
            {
                file = Env.Get("ABANU_EXE");

                var builder = new AbanuBuilder_Kernel(file);
                builder.Build();
            }
            else if (args[0] == "app")
            {
                file = Env.Get("${ABANU_PROJDIR}/bin/App.HelloKernel.exe");

                var builder = new AbanuBuilder_App(file);
                builder.Build();
            }
            else if (args[0] == "app2")
            {
                file = Env.Get("${ABANU_PROJDIR}/bin/App.HelloService.exe");

                var builder = new AbanuBuilder_App(file);
                builder.Build();
            }
            else if (args[0] == "service.consoleserver")
            {
                file = Env.Get("${ABANU_PROJDIR}/bin/Abanu.Service.ConsoleServer.exe");

                var builder = new AbanuBuilder_App(file);
                builder.Build();
            }
            else if (args[0] == "service.basic")
            {
                file = Env.Get("${ABANU_PROJDIR}/bin/Abanu.Service.Basic.exe");

                var builder = new AbanuBuilder_App(file);
                builder.Build();
            }
            else if (args[0] == "external")
            {
                file = args[1];

                var builder = new AbanuBuilder_App(file);
                builder.Build();
            }
            else if (args[0] == "service.hostcommunication")
            {
                file = Env.Get("${ABANU_PROJDIR}/bin/Abanu.Service.HostCommunication.exe");

                var builder = new AbanuBuilder_App(file);
                builder.Build();
            }
            else if (args[0] == "app.shell")
            {
                file = Env.Get("${ABANU_PROJDIR}/bin/App.Shell.exe");

                var builder = new AbanuBuilder_App(file);
                builder.Build();
            }
            else if (args[0] == "image")
            {
                LinkImages();
            }
            Console.WriteLine("ready");
            //System.Console.ReadLine();

            return(null);
        }
Exemple #4
0
 private static ProcessResult ExecAsync(CommandArgs args)
 {
     return(ExecAsync(args, false));
 }