示例#1
0
        public override async Task <ITaskResult> Execute(GenesisContext genesis, string[] args)
        {
            var result = new OutputTaskResult();

            if (args.Length == 1 || HelpWasRequested(args)) //just 'gen' or 'gen --help,-?'
            {
                Console.WriteLine("Usage:");
                Console.WriteLine($"\t{Name} <KnownGeneratorName>\t\t\tSet the current generator to the type provided.");
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine($"\t'{Name} GeneratorName'");
                Console.ResetColor();
                Console.WriteLine();

                if (OutputManager.Outputs.Count == 0) //NO Outputs Found
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.Write("There are no generators discovered yet. Run a '");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write("scan");
                    Console.ResetColor();
                    Console.WriteLine("'.");
                }
                else //Outputs were found
                {
                    Console.WriteLine("Known Outputs:");
                    foreach (var item in OutputManager.Outputs)
                    {
                        Text.White("Command: "); Text.Green($@"{item.CommandText}"); Text.White(" From: "); Text.Cyan($"'{item.GetType().Name}'"); Text.WhiteLine($"\t\t{ item.Description} ");
                    }
                }
                result.Success = true;
                result.Message = string.Empty;
            }
            else
            {
                var generator = OutputManager.Outputs.Find(g => g.CommandText.Trim().ToLower() == args[1].Trim().ToLower());
                if (generator != null)
                {
                    await genesis.ConfigureGenerator(generator);

                    Text.White($@"The current Generator is now: "); Text.CyanLine($"'{generator.GetType().Name}'");
                    result.Success = true;
                    result.Message = string.Empty;
                }
                else
                {
                    Console.Write("'");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.Write(args[1]);
                    Console.ResetColor();
                    Console.Write("'");
                    Console.WriteLine(" is not a known Generator name.");

                    result.Message = "Invalid Generator.Name";
                }
            }

            return(await Task.FromResult(result));
        }
示例#2
0
        public override async Task <ITaskResult> Execute(GenesisContext genesis, string[] args)
        {
            var result = new OutputTaskResult(); //overridden just to loop over all the graphs

            foreach (var obj in genesis.Objects)
            {
                await ExecuteGraph(obj);
            }

            return(result);
        }
示例#3
0
        public override async Task <ITaskResult> Execute(GenesisContext genesis, string[] args)
        {
            var result = new OutputTaskResult();

            if (args.Length == 1) //config
            {
                await OnHelpRequested(args);
            }
            else if (args.Length == 2) //config executorname
            {
                WriteExecutorDetails(args[1]);
            }
            else
            {
                var generator = OutputManager.Outputs.Find(g => g.CommandText.Trim().ToLower().Equals(args[1].Trim().ToLower(), StringComparison.Ordinal));
                var populator = InputManager.Inputs.Find(p => p.CommandText.Trim().ToLower() == args[1].Trim().ToLower());

                var chunks       = args[2].Split('=');
                var propertyName = chunks[0];

                if (generator != null)
                {
                    if (!await generator.EditConfig(chunks[0], chunks[1]))
                    {
                        Text.RedLine("Couldn't update value");
                    }
                    else
                    {
                        result.Success = true;
                    }
                }
                else if (populator != null)
                {
                    if (!await populator.EditConfig(chunks[0], chunks[1]))
                    {
                        Text.RedLine("Couldn't update value");
                    }
                    else
                    {
                        result.Success = true;
                    }
                }
                else
                {
                    Text.Command(args[1]);
                    Text.RedLine(" is not a known Executor. ("); Text.FriendlyText("Input", false); Text.Red(" or "); Text.FriendlyText("Output"); Text.RedLine(".");

                    result.Message = "Invalid Executor";
                }
            }
            return(await Task.FromResult(result));
        }