Exemple #1
0
        static async Task Main(string[] args)
        {
            //NOTE:      --script "C:\Path\To\Script.genesis"
            if (args.Length == 2 && args[0].Equals("--script", StringComparison.InvariantCultureIgnoreCase) && args[1].Length > 0)
            {
                await InitializeScript(args[1]);
            }

            using var tokenSource = new CancellationTokenSource();

            Text.White($"Genesis Creation Engine "); Text.GrayLine(GetVersionDisplayString());
            Text.Line();

            await CommandLoader.InitAsync(args);

            if (_isScript)
            {
                Text.WhiteLine($"Processing script '{args[1]}' with {_script.Length} lines");
                Text.YellowLine($"----- {DateTimeOffset.UtcNow}]-----");

                foreach (var line in _script)
                {
                    if (line.StartsWith("--"))
                    {
                        Debug.WriteLine($"Skipping due to comment: [{line}]");
                        continue;
                    }

                    if (string.IsNullOrEmpty(line.Trim()))
                    {
                        continue; //blank line
                    }
                    Text.WhiteLine($"Executing: [{line}]");

                    if (line.ToLower().StartsWith("break"))
                    {
                        _isScript = false; //cheesy, but can't set it from a command apparently, CommandLineApplication?
                    }
                    ProcessCommandLine(line.ToArgs().ToArray(), tokenSource);
                }
            }

            if (!_isScript)
            {
                Text.Yellow("HINT"); Text.White(": '"); Text.Green("?"); Text.White("' for a list of "); Text.CliCommand("commands", false); Text.Line();
                do
                {
                    if (tokenSource.IsCancellationRequested)
                    {
                        Environment.Exit(-3);
                    }

                    Text.White($@"genesis{GenesisContext.Scope?.PromptString}>"); //this could be interesting? or confusing, or stupid. :D

                    args = Console.ReadLine().ToArgs().ToArray();

                    ProcessCommandLine(args, tokenSource);
                }while (!tokenSource.IsCancellationRequested);
            }
        }
Exemple #2
0
        static async Task Main(string[] args)
        {
            //comment to run the loop
            //args = new string[] { "--script", "./LocalDBSqlToCSharp.genesis" };

            //NOTE:      --script "C:\Path\To\Script.genesis"
            if (args.Length == 2 && args[0].ToLower() == "--script" && args[1].Length > 0)
            {
                await InitializeScript(args[1]);
            }

            var tokenSource = new CancellationTokenSource(); //TODO: Is this even necessary here?

            Text.White($"Genesis Creation Engine "); Text.GrayLine(GetVersionDisplayString());
            Text.Line();

            await CommandLoader.InitAsync(args);

            if (_isScript)
            {
                Text.WhiteLine($"Processing script '{args[1]}' with {_script.Length} lines");
                Text.YellowLine($"----- {DateTimeOffset.UtcNow}]-----");

                foreach (var line in _script)
                {
                    Text.WhiteLine($"Executing: '{line}' as {line.Split(" ").Length} arguments");

                    if (line.ToLower().StartsWith("break"))
                    {
                        _isScript = false; //cheesy, but can't set it from a command apparently, CommandLineApplication?
                    }
                    ProcessCommandLine(line.ToArgs().ToArray(), tokenSource);
                }
            }

            if (!_isScript)
            {
                Text.Yellow("HINT"); Text.White(": '"); Text.Green("?"); Text.White("' for a list of "); Text.Command("commands", false); Text.Line();
                do
                {
                    if (tokenSource.IsCancellationRequested)
                    {
                        Environment.Exit(-3);
                    }

                    Console.Write($@"genesis{GenesisContext.Scope?.PromptString}>");

                    args = Console.ReadLine().ToArgs().ToArray();

                    ProcessCommandLine(args, tokenSource);
                }while (!tokenSource.IsCancellationRequested);
            }
        }