public void CollectInput(ScaffolderContext context) { var queryName = AnsiConsole.Ask <string>("What is the name of the query?"); queryName = queryName.Replace("Query", string.Empty, StringComparison.CurrentCultureIgnoreCase); context.Variables.Set(Constants.QueryName, queryName); }
public void CollectInput(ScaffolderContext context) { var controllerName = AnsiConsole.Ask <string>("In which controller do you want to add an endpoint?"); controllerName = controllerName.Replace("Controller", string.Empty, StringComparison.CurrentCultureIgnoreCase); context.Variables.Set(Constants.ControllerName, controllerName); }
public static async Task Main(string[] args) { AnsiConsole.Write(new FigletText("QuickBullet").LeftAligned()); await GenerateSettingsFile(); GenerateConfigsFolder(); GenerateWordlistsFolder(); Microsoft.Playwright.Program.Main(new string[] { "install" }); if (args.Any()) { await Parser.Default.ParseArguments <RunOptions>(args).WithParsedAsync(RunAsync); } else { var configFiles = GetAllConfigFiles(); var wordlistsFiles = GetAllWordlistsFiles(); var config = AnsiConsole.Prompt(new SelectionPrompt <string>() .Title("Select config:") .AddChoices(configFiles.Select(c => Path.GetFileNameWithoutExtension(c)))); var wordlists = AnsiConsole.Prompt(new SelectionPrompt <string>() .Title("Select wordlists:") .AddChoices(wordlistsFiles.Select(c => Path.GetFileNameWithoutExtension(c)))); var runOptions = new RunOptions { ConfigFile = Path.Combine(ConfigsFolder, $"{config}.loli"), WordlistFile = Path.Combine(WordlistsFolder, $"{wordlists}.txt") }; runOptions.ProxiesFile = AnsiConsole.Ask("proxies file", "none"); runOptions.ProxiesType = runOptions.ProxiesFile.Equals("none") ? string.Empty : AnsiConsole.Prompt(new SelectionPrompt <string>() .Title("proxies type") .AddChoices(new string[] { "http", "socks4", "socks5" })); runOptions.Skip = AnsiConsole.Ask("skip", -1); var bots = AnsiConsole.Ask("bots", 1); while (bots > 200) { AnsiConsole.MarkupLine("[red]The number of bots must be less than 200[/]"); bots = AnsiConsole.Ask("bots", 1); } runOptions.Bots = bots; runOptions.Verbose = AnsiConsole.Ask("verbose:", false); await RunAsync(runOptions); } }
private static Employes CreateEmployees() { var configurations = Configuration.ValidateConfiguration(); string name = AnsiConsole.Ask <string>("Ingrese : [green]nombre[/]?"); string idCard = AnsiConsole.Ask <string>("Ingrese : [green]identificacion[/]?"); int birthdate = AnsiConsole.Ask <int>("Ingrese : [green]fecha nacimiento[/]?"); var city = AnsiConsole.Prompt( new SelectionPrompt <string>() .Title("Ingrese : [green]ciudad[/]?") .PageSize(10) .AddChoices(Cities)); string address = AnsiConsole.Ask <string>("Ingrese : [green]direccion[/]?"); string phone = AnsiConsole.Ask <string>("Ingrese : [green]telefono[/]?"); string position = AnsiConsole.Ask <string>("Ingrese : [green]cargo[/]?"); salary: int salary = AnsiConsole.Ask <int>("Ingrese : [green]salario[/]?"); if (salary < configurations.Salary) { Console.WriteLine($"Salario ${salary} no permitido, ingrese un salario mayor o igual a {configurations.Salary}"); goto salary; } return(new Employes(name, idCard, birthdate, city, address, phone, position, salary)); }
public void CollectInput(ScaffolderContext context) { var commandName = AnsiConsole.Ask <string>("What is the name of the command?"); commandName = commandName.Replace("Command", string.Empty, StringComparison.CurrentCultureIgnoreCase); context.Variables.Set(Constants.CommandName, commandName); }
private static string AskName() { AnsiConsole.WriteLine(); AnsiConsole.Render(new Rule("[yellow]Strings[/]").RuleStyle("grey").LeftAligned()); var name = AnsiConsole.Ask <string>("What's your [green]name[/]?"); return(name); }
private Player GetPlayerDetails() { var name = AnsiConsole.Ask <string>("Name:"); var chips = AnsiConsole.Ask <int>("Amount of starting chips(recommended 100+):"); return(new Player { Name = name, ChipCount = chips, }); }
public void CollectInput(ScaffolderContext context) { while (!HasValidPathToSolutionRootDirectory(context)) { var path = AnsiConsole.Ask <string>($"In which directory is '{Constants.SolutionName}' located?"); context.AppSettings.PathToSolutionRootDirectory = path; if (!HasValidPathToSolutionRootDirectory(context)) { Console.WriteLine($"{Constants.SolutionName} not found in directory '{path}'."); } } }
private static string GetHighResDir() { var pathToArcDir = AnsiConsole.Ask <string>("[green]Insert path to Arcanum dir[/]:"); var pathToHighResDir = Path.Combine(pathToArcDir + "\\HighRes"); while (!Directory.Exists(pathToHighResDir)) { ConsoleExtensions.Log("HighRes dir not found!", "error"); pathToArcDir = AnsiConsole.Ask <string>("[green]Insert path to Arcanum dir again[/]:"); pathToHighResDir = Path.Combine(pathToArcDir + "\\HighRes"); } return(pathToHighResDir); }
static void Main(string[] args) { AnsiConsole.MarkupLine("HEYYYYY"); AnsiConsole.Render(new Markup("WELCOME!", new Style(Color.DarkCyan, null, Decoration.Bold))); var str = AnsiConsole.Ask <string>("Give string"); var parsed = SharedLib.Models.Serialization.DeserializationUtils.ParseSTR(str); AnsiConsole.MarkupLine(parsed.Value); Task.Delay(-1).Wait(); Console.ReadKey(); }
public override int Execute(CommandContext context) { var subject = AnsiConsole.Ask <string>("Enter the commit subject:"); var message = CommitCommandUtils.GenerateCommitMessage(true, subject); if (string.IsNullOrWhiteSpace(message)) { SpectreHelper.WriteError("There was an error generating the commit message."); return(1); } SpectreHelper.WriteWrappedHeader("Your commit message:"); SpectreHelper.WriteInfo(message); return(0); }
static void Main(string[] args) { Dictionary <int, List <string> > answers = new Dictionary <int, List <string> >(); string filePath = AnsiConsole.Ask <string>("Please Enter the file path."); InputReader inputReader = new InputReader(filePath); //var survey = new Survey(); //var question = survey.GetQuestion(); var question = inputReader.GetQuestion(); var prompt = new TextPrompt <string>(question.Question); foreach (var a in question.Answers) { prompt.AddChoice(a); } var answer = AnsiConsole.Prompt(prompt); List <string> lst_answ = new List <string>(); lst_answ.Add(question.Question); lst_answ.Add(answer); answers.Add(1, lst_answ); Console.WriteLine(answers); if (answer == inputReader.GetCorrectAnswer()) { AnsiConsole.Markup("That's [underline green]correct[/]!"); } // var prompt = new TextPrompt<string>(question.Question); // foreach(var a in question.Answers) { // prompt.AddChoice(a); // } // var answer = AnsiConsole.Prompt(prompt); // if(answer == survey.GetCorrectAnswer()) { // AnsiConsole.Markup("That's [underline green]correct[/]!"); // } // else { // AnsiConsole.Markup("That's [underline red]wrong[/]!"); // } }
private static void JournalStart() { if (!string.IsNullOrWhiteSpace(trackId)) { AnsiConsole.MarkupLine($"You are alredy tracking your journal with the ID '{trackId}'"); if (!AnsiConsole.Confirm("Do you want to overwrite it?")) { return; } } trackId = AnsiConsole.Ask <string>("Please enter your journal id: "); HttpClient.DefaultRequestHeaders.Remove(TRACKID_HEADER); HttpClient.DefaultRequestHeaders.Add(TRACKID_HEADER, trackId); }
public static void Main(string[] args) { // Check if we can accept key strokes if (!AnsiConsole.Capabilities.SupportsInteraction) { AnsiConsole.MarkupLine("[red]Environment does not support interaction.[/]"); return; } // Confirmation if (!AnsiConsole.Confirm("Run prompt example?")) { AnsiConsole.MarkupLine("Ok... :("); return; } // String AnsiConsole.WriteLine(); AnsiConsole.Render(new Rule("[yellow]Strings[/]").RuleStyle("grey").LeftAligned()); var name = AnsiConsole.Ask <string>("What's your [green]name[/]?"); // String with choices AnsiConsole.WriteLine(); AnsiConsole.Render(new Rule("[yellow]Choices[/]").RuleStyle("grey").LeftAligned()); var fruit = AnsiConsole.Prompt( new TextPrompt <string>("What's your [green]favorite fruit[/]?") .InvalidChoiceMessage("[red]That's not a valid fruit[/]") .DefaultValue("Orange") .AddChoice("Apple") .AddChoice("Banana") .AddChoice("Orange")); // Integer AnsiConsole.WriteLine(); AnsiConsole.Render(new Rule("[yellow]Integers[/]").RuleStyle("grey").LeftAligned()); var age = AnsiConsole.Prompt( new TextPrompt <int>("How [green]old[/] are you?") .PromptStyle("green") .ValidationErrorMessage("[red]That's not a valid age[/]") .Validate(age => { return(age switch { <= 0 => ValidationResult.Error("[red]You must at least be 1 years old[/]"), >= 123 => ValidationResult.Error("[red]You must be younger than the oldest person alive[/]"), _ => ValidationResult.Success(), });
public static string GenerateCommitMessage(bool completeCommit, string message) { var commitBody = string.Empty; string[] closedIssues = null; string[] seeAlso = null; if (string.IsNullOrWhiteSpace(message)) { message = AnsiConsole.Ask <string>("Enter the commit subject:"); } var tag = AnsiConsole.Prompt( new SelectionPrompt <string>() .Title("Select the commit tag:") .PageSize(10) .MoreChoicesText("[grey](Move up and down to reveal more branches)[/]") .AddChoices(Constants.CommitTagsWithDescriptions[..^ 1]))
private static void BasicPrompts() { AnsiConsole.WriteLine(); var name = AnsiConsole.Ask <string>("What's your [blue]name[/]?"); AnsiConsole.WriteLine(); var age = AnsiConsole.Prompt( new TextPrompt <int>("What's the age?") .Validate(age => { return(age switch { < 10 => ValidationResult.Error("[red]Too young[/]"), > 90 => ValidationResult.Error("[red]Too old[/]"), _ => ValidationResult.Success(), });
public static void CreateNewConfiguration() { if (ConfigAccess.ReadConfiguration() is not null) { ShowConfiguration(); var option = AnsiConsole.Confirm("Desea eliminar la configuración?"); if (option) ConfigAccess.DeleteConfiguration(); } else { var color1 = AnsiConsole.Prompt(new SelectionPrompt<string>().Title("Color 1, row 1 table?").AddChoices(Colors)); var color2 = AnsiConsole.Prompt(new SelectionPrompt<string>().Title("Color 2, row 2 table?").AddChoices(Colors)); var color3 = AnsiConsole.Prompt(new SelectionPrompt<string>().Title("Color 3, header table?").AddChoices(Colors)); var salary = AnsiConsole.Ask<int>("Salario minimo"); ConfigAccess.CreateConfigurations(color1, color2, color3, salary); } }
public static void EditEmployee() { string idCard = AnsiConsole.Ask <string>("[blue]Ingrese cedula del usuario a editar[/]"); var connection = new SqliteConnection($"Data Source={dbFile}"); connection.Open(); var command = connection.CreateCommand(); command.CommandText = @" SELECT Name FROM Employes WHERE IdCard = $IdCard "; command.Parameters.AddWithValue("$IdCard", idCard); var reader = command.ExecuteReader(); if (!reader.Read()) { return; } reader.Close(); AnsiConsole.Render(new Rule("[red]La cedula no se puede modificar![/]")); var employe = CreateEmployees(); command.CommandText = $@" UPDATE Employes SET Name = '{employe.Name}',City ='{employe.City}',BirthDate='{employe.BirthDate}', YearsOld={employe.YearsOld},Address='{employe.Address}', Phone='{employe.Phone}',Position='{employe.Position}',Salary={employe.Salary} WHERE IdCard = '{idCard}' "; command.Parameters.AddWithValue("$IdCard", idCard); command.ExecuteNonQuery(); Console.WriteLine($"Empleado {employe.Name} modificado exitosamente"); }
static void Main(string[] args) { Controller calc = new Controller(); if (Console.IsInputRedirected) { Console.Out.WriteLine(calc.Eval(Console.In.ReadLine()).Msg); } else { AnsiConsole.Console.Clear(true); while (calc.Running) { try { AnsiConsole.Render(DrawStack(calc.StackView)); string input = AnsiConsole.Ask <string>("[green]" + calc.GetString("PROMPT") + "[/]"); AnsiConsole.Console.Clear(true); EvalReturn eval = calc.Eval(input); if (eval.Response == Response.Error) { AnsiConsole.MarkupLine("[red]" + eval.Msg + "[/]"); } else if (eval.Response == Response.Help) { AnsiConsole.MarkupLine("[bold]" + eval.Msg + "[/]"); } } catch (Exception e) { AnsiConsole.WriteException(e); } } } }
static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; string lastStateSave; PrintList printList = new PrintList(); // класс для вывода списка Properties properties = new Properties(); // класс настроек properties.SetProperetiesPath(); if (File.Exists(properties.ProperetiesPath)) //если файл настроек уже существует - загрузка настроек { properties.LoadSettings(); } if (properties.LastState != null) // если существует настройка с последним активным каталогом - загружаем его { Directory.SetCurrentDirectory(properties.LastState); printList.ListDirsAndFiles(); } else //в другом случае проводим первый старт программы { printList.InitialStart(); var helpPanel = new Table(); helpPanel.AddColumn("write help to get controls"); helpPanel.Collapse(); helpPanel.Alignment(Justify.Right); helpPanel.RightAligned(); helpPanel.HeavyBorder(); AnsiConsole.Render(helpPanel); Properties.PageLength = 100; } List <Command> commands = new List <Command>(); // создаем список доступных команд commands.Add(new GoToCommand()); commands.Add(new CopyCommand()); commands.Add(new DeleteCommand()); commands.Add(new InfoCommand()); commands.Add(new HelpCommand()); commands.Add(new PageCommand()); while (true) { var table = new Table(); userCommand = AnsiConsole.Ask <string>("Command Line:"); string userCommandToLowerCase = userCommand.ToLower(); if (userCommandToLowerCase == "exit") // комманда выведена отдельно вне списка т.к. не имеет аргументов и исполняется в одну строку { break; } else if (userCommandToLowerCase == "up") //тоже вне спика т.к. нет аргументов и метод исполнения внутри класса PrintList { printList.GoUp(); } var parsedCommand = Regex.Match(userCommandToLowerCase, @"^([\w\-]+)").ToString(); // считывание команды var parsedArgument = userCommandToLowerCase.Split(' ', 2).Skip(1).FirstOrDefault(); // считывание аргумента foreach (Command command in commands) { if (command.CanHandle(parsedCommand)) { command.Handle(parsedArgument); } } } lastStateSave = Directory.GetCurrentDirectory(); properties.Save(lastStateSave, Properties.PageLength); // сохранение настроек при завершении программы }
private static string AskExampleProjectName() { return(AnsiConsole.Ask <string>("What would you like to name this project (e.g. [green]MyExampleProject[/])?")); }
static async Task Main(string[] args) { string name, surname; int birthday; List <Person> personsList = new List <Person> (); do { Console.WriteLine("1- Para agregar persona\n2- Para mostrar información"); var option = int.Parse(Console.ReadLine()); switch (option) { case 1: name = AnsiConsole.Ask <string> ("Cual es tu [blue]nombre[/]?"); surname = AnsiConsole.Ask <string> ("Cual es tu [blue]apellido[/]?"); birthday = AnsiConsole.Ask <int> ("Cual es tu [green]año de nacimiento[/]?"); Person persona = new Person(name, surname, birthday); personsList.Add(persona); AnsiConsole.Status() .Start("Guardando...", ctx => { Thread.Sleep(1000); // Update the status and spinner ctx.Status("Finalizado"); ctx.Spinner(Spinner.Known.Star); ctx.SpinnerStyle(Style.Parse("green")); Thread.Sleep(1000); }); Console.Clear(); break; case 2: var saveTable = AnsiConsole.Confirm("Guardar tabla?"); AnsiConsole.Record(); Table table = new Table(); table.AddColumn("Nombre"); table.AddColumn("Apellido"); table.AddColumn("Edad"); table.AddColumn("Pais"); table.AddColumn("Ciudad"); table.AddColumn("Idioma"); table.AddColumn("Cordenadas"); foreach (var item in personsList) { table.AddRow(item.Name, item.Surname, item.Birthday.ToString(), item.Country, item.City, item.Language, item.Cordinates); } var title = new TableTitle("Empleado", Style.WithDecoration(Decoration.Bold)); table.Title = title; table.Border(TableBorder.Rounded); table.BorderColor <Table> (Color.Blue); AnsiConsole.Render(table); if (saveTable) { string html = AnsiConsole.ExportHtml(); Directory.CreateDirectory("../Employes"); File.WriteAllText("../Employes/index.html", html); Console.ForegroundColor = Color.Green; Console.WriteLine("Guardado Exitosamente"); Console.ForegroundColor = Color.White; } break; default: break; } } while (true); }
static void Main(string[] args) { //Welcome text Console.WriteLine(); var table = new Table(); table.Border = TableBorder.None; table.AddColumn(new TableColumn("[bold dodgerblue2]Welcome to the Prague Parking![/]").Centered()); table.AddRow("[bold dodgerblue2]---------------------------------------------[/]"); table.Expand(); AnsiConsole.Render(table); Console.WriteLine(); Console.WriteLine(); PrintParkingSpots(); Console.WriteLine(""); Console.WriteLine(""); //Menu starts here bool isOpen = true; while (isOpen) { Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine(""); // Ask for the user's favorite fruit var menuItem = AnsiConsole.Prompt( new SelectionPrompt <string>() .Title("[bold paleturquoise1]Please choose from the menu below?[/]") .PageSize(5) .AddChoices(new[] { "1. Leave a vehicle for parking", "2. Change a vehicle's parkingspot", "3. Get your vehicle", "4. Search for a vehicle" })); Console.WriteLine(""); // Echo the fruit back to the terminal char charFirst = menuItem[0]; //Console.WriteLine("You have chosen: " + charFirst); switch (charFirst) { case '1': //Leaving vehicle to the garage Console.WriteLine(""); Console.WriteLine("You chose to leave your vehicle for parking"); Console.WriteLine(""); string regNr = "empty"; //checks if registration nr is valid bool isValidRegNr = false; while (!isValidRegNr) { string strRegNr = AnsiConsole.Ask <string>("[paleturquoise1]Please enter your vehicle's registration number: [/]"); bool isRegnrValid = IsInputRegnrValid(strRegNr); if (isRegnrValid) { regNr = strRegNr; isValidRegNr = true; } else { Console.WriteLine(""); Console.WriteLine("Registration number is not valid"); Console.WriteLine(""); } } Console.WriteLine(""); Console.WriteLine("Your reg number is: " + regNr); Console.WriteLine(""); //Getting vehicle's type string type = "empty"; type = AnsiConsole.Prompt( new SelectionPrompt <string>() .Title("[bold paleturquoise1]Please choose type of your vehicle?[/]") .PageSize(3) .AddChoices(new[] { "Car", "MC" })); Console.WriteLine(""); Console.WriteLine("You have chosen: " + type); Console.WriteLine(""); Vehicle vh = new Vehicle(); if (type == "MC") { MC motorcycle = new MC(regNr); vh = motorcycle; } else { Car car = new Car(regNr); vh = car; } AddVehicle(vh); break; case '2': Console.WriteLine("You chose to change parkingspot for your vehicle"); string regNrInput = "empty"; int parkingNrInput = 0; int position = -1; //checks if registration nr is valid bool isValidregNrInput = false; while (!isValidregNrInput) { string strRegNrInput = AnsiConsole.Ask <string>("[paleturquoise1]Please enter your vehicle's registration number: [/]"); bool isRegnrValid = IsInputRegnrValid(strRegNrInput); position = IsRegnrAvailable(strRegNrInput); if (isRegnrValid && position != -1) { regNrInput = strRegNrInput; isValidregNrInput = true; } else { Console.WriteLine(""); Console.WriteLine("Registration number is not found in the garage"); Console.WriteLine(""); } } //checks if new parking nr is valid bool isValidParkingNrInput = false; while (!isValidParkingNrInput) { Console.WriteLine(""); string strNr = AnsiConsole.Ask <string>("[paleturquoise1]Please enter parkingspot number where you want to move your vehicle: [/]"); int intNr = IsNewParkingNrValid(strNr, position); //returns position of a new parkingspot if (intNr != -1) { parkingNrInput = intNr; isValidParkingNrInput = true; } } //end of while Console.WriteLine(""); Console.WriteLine("Your reg number is: " + regNrInput); Console.WriteLine("Position of your vehicle is: " + position); Console.WriteLine("Your new ps nummer is valid: " + parkingNrInput); Console.WriteLine(""); ChangeParkingSpot(position, parkingNrInput, regNrInput); break; case '3': Console.WriteLine(""); Console.WriteLine("3. You chose to get your vehicle"); Console.WriteLine(""); string regNrInputG = "empty"; int positionG = -1; //checks if registration nr is valid bool isValidregNrInputG = false; while (!isValidregNrInputG) { string strRegNrInputG = AnsiConsole.Ask <string>("[paleturquoise1]Please enter your vehicle's registration number: [/]"); bool isRegnrValid = IsInputRegnrValid(strRegNrInputG); positionG = IsRegnrAvailable(strRegNrInputG); if (isRegnrValid && positionG != -1) { regNrInputG = strRegNrInputG; isValidregNrInputG = true; } else { Console.WriteLine(""); Console.WriteLine("Registration number is not found in the garage"); Console.WriteLine(""); } } //Console.WriteLine("Reg nr available. You can get your car" + regNrInputG); RemoveVehicle(regNrInputG, positionG); break; case '4': Console.WriteLine(""); Console.WriteLine("4. You chose to search your vehicle"); Console.WriteLine(""); //checks if registration nr is valid bool isValidregNrInputS = false; while (!isValidregNrInputS) { string strRegNrInputS = AnsiConsole.Ask <string>("[paleturquoise1]Please enter your vehicle's registration number: [/]"); bool isRegnrValidS = IsInputRegnrValid(strRegNrInputS); int positionS = IsRegnrAvailable(strRegNrInputS); if (isRegnrValidS && positionS != -1) { //regNrInputS = strRegNrInputS; isValidregNrInputS = true; int psNr = positionS + 1; Console.WriteLine("Your vehicle with registration number " + strRegNrInputS + " is in the parkingspot " + psNr); } else { Console.WriteLine(""); Console.WriteLine("Registration number is not found in the garage"); Console.WriteLine(""); } } break; default: Console.WriteLine("Please choose from the menu"); break; } } //end of while menu } //end of main
static void Main(string[] args) { TextPrompt <string> modePrompt = new TextPrompt <string>("Select DynamoDB Connect Mode") .InvalidChoiceMessage("[red]Invalid Mode[/]") .AddChoice("ApiKey") .AddChoice("CredentialsFile") .DefaultValue("ApiKey"); var apiKey = ApiKey; var secret = Secret; string credentialsFilePath = string.Empty; string profileName = string.Empty; var mode = AnsiConsole.Prompt(modePrompt); if (mode == "ApiKey") { if (string.IsNullOrEmpty(apiKey)) { apiKey = AnsiConsole.Ask <string>("Enter your DynamoDB [blue]API Key[/]"); } TextPrompt <string> secretPrompt = new TextPrompt <string>("Enter your DynamoDB [blue]API Secret[/]") .PromptStyle("red") .Secret(); if (string.IsNullOrEmpty(secret)) { secret = AnsiConsole.Prompt(secretPrompt); } } else { var credentialsFilePathPrompt = new TextPrompt <string>("Enter your [blue]Credentials File Path[/]"); credentialsFilePath = AnsiConsole.Prompt(credentialsFilePathPrompt); var profilePrompt = new TextPrompt <string>("Enter your [blue]Credentials Profile name[/]"); profileName = AnsiConsole.Prompt(profilePrompt); } TextPrompt <string> regionPrompt = new TextPrompt <string>("Enter your DynamoDB [blue]Region[/]?") .InvalidChoiceMessage("[red]Invalid Region[/]") .DefaultValue("APNortheast2"); foreach (string regionName in Enum.GetNames(typeof(AwsRegion))) { regionPrompt.AddChoice(regionName); } var region = AnsiConsole.Prompt(regionPrompt); var connection = new PrimarSqlConnection(new PrimarSqlConnectionStringBuilder { AccessKey = apiKey, AccessSecretKey = secret, CredentialsFilePath = credentialsFilePath, ProfileName = profileName, AwsRegion = Enum.Parse <AwsRegion>(region), }); connection.Open(); while (true) { try { var query = AnsiConsole.Prompt(new TextPrompt <string>("[blue]Query[/]")); var command = connection.CreateDbCommand(query); using var dbDataReader = command.ExecuteReader(); var table = new Table { Border = TableBorder.Rounded }; for (int i = 0; i < dbDataReader.FieldCount; i++) { table.AddColumn($"[green]{Markup.Escape(dbDataReader.GetName(i))}[/]"); } while (dbDataReader.Read()) { var list = new List <string>(); for (int i = 0; i < dbDataReader.FieldCount; i++) { var value = dbDataReader[i]; list.Add(Markup.Escape(value switch { byte[] bArr => Convert.ToBase64String(bArr), DateTime dt => dt.ToString("u"), _ => value.ToString() })); } table.AddRow(list.ToArray()); }
static void Main(string[] args) { GradientMarkup.DefaultStartColor = "#ed4264"; GradientMarkup.DefaultEndColor = "#ffedbc"; AnsiConsole.Markup(GradientMarkup.Ascii("Awesome Miner", FigletFont.Default, "#009245", "#FCEE21")); AnsiConsole.Markup(GradientMarkup.Text("Awesome Miner v8.4.x Keygen by Ankur Mathur")); var filePath = Path.Combine(Environment.CurrentDirectory, "AwesomeMiner.exe"); if (!File.Exists(filePath)) { AnsiConsole.MarkupLine($"\r\n[bold red]File not found in the current directory ![/] ({filePath})"); Console.ReadKey(); Environment.Exit(0); } var p = new Patcher(filePath); var licMgr = p.FindMethodsByOpCodeSignature( OpCodes.Call, OpCodes.Ldarg_1, OpCodes.Stfld); foreach (var item in licMgr) { var ins = p.GetInstructions(item); var operands = ins.Where(x => x.OpCode == OpCodes.Stfld).Select(x => x.Operand).OfType <dnlib.DotNet.FieldDef>(); if (operands.Any(x => x.Name == "RegistrationSettings")) { item.Method = null; CLS_LicenseManager = item; AnsiConsole.Markup(GradientMarkup.Text($"Found LicenseManager Class at : {CLS_LicenseManager.Class}")); break; } } var targets = p.FindMethodsByOpCodeSignature( OpCodes.Ldc_I4_1, OpCodes.Newarr, OpCodes.Stloc_0, OpCodes.Ldloc_0, OpCodes.Ldc_I4_0, OpCodes.Ldarg_0, OpCodes.Stelem_Ref, OpCodes.Call, OpCodes.Call, OpCodes.Ldstr, OpCodes.Ldloc_0, OpCodes.Call, OpCodes.Unbox, OpCodes.Ldobj, OpCodes.Ret).Where(t => t.Class.Equals(CLS_LicenseManager.Class)).ToArray(); FN_GetSoftwareEdition = targets.FirstOrDefault(x => p.FindInstruction(x, Instruction.Create(OpCodes.Unbox, new TypeDefUser("AwesomeMiner.Components.SoftwareEdition"))) > -1); if (FN_GetSoftwareEdition != null) { AnsiConsole.Markup(GradientMarkup.Text($"GetSoftwareEdition Method at : {FN_GetSoftwareEdition.Method} ... ")); FN_GetSoftwareEdition.Instructions = new Instruction[] { Instruction.Create(OpCodes.Ldc_I4, 10), Instruction.Create(OpCodes.Ret) }; p.Patch(FN_GetSoftwareEdition); AnsiConsole.Markup("[Green]Success[/]"); } targets = p.FindMethodsByArgumentSignatureExact(CLS_LicenseManager, null, "AwesomeMiner.Entities.Settings.RegistrationSettings", "System.Boolean", "System.String"); FN_ValidateRegistrationCode = targets.FirstOrDefault(); if (FN_ValidateRegistrationCode != null) { AnsiConsole.Markup(GradientMarkup.Text($"ValidateRegistrationCode Method at : {FN_ValidateRegistrationCode.Method} ... ")); FN_ValidateRegistrationCode.Instructions = new Instruction[] { Instruction.Create(OpCodes.Ldc_I4_0), Instruction.Create(OpCodes.Ret) }; p.Patch(FN_ValidateRegistrationCode); AnsiConsole.MarkupLine("[Green]Success[/]"); } targets = p.FindMethodsByArgumentSignatureExact(CLS_LicenseManager, "System.Boolean", "System.Boolean"); FN_IsRegisteredFromBackgroundThread = targets.FirstOrDefault(); if (FN_IsRegisteredFromBackgroundThread != null) { AnsiConsole.Markup(GradientMarkup.Text($"IsRegisteredFromBackgroundThread Method at : {FN_IsRegisteredFromBackgroundThread.Method} ... ")); p.WriteReturnBody(FN_IsRegisteredFromBackgroundThread, true); AnsiConsole.MarkupLine("[Green]Success[/]"); } AnsiConsole.Markup(GradientMarkup.Text("Saving patched file... ")); p.Save(true); AnsiConsole.MarkupLine("[Green]Success[/]"); AnsiConsole.MarkupLine($"[bold]Edition: [yellow]UltimatePlus[/][/]"); var email = AnsiConsole.Ask <string>("Enter [green]email address[/] to register"); AnsiConsole.MarkupLine($"[bold red on silver]Serial Number: {GenerateSerial("UltimatePlus", email)}[/]"); Console.ReadKey(); }
public async Task <Checker> BuildAsync() { var quickBulletSettings = JsonConvert.DeserializeObject <QuickBulletSettings>(File.ReadAllText(settingsFile)); var loliScriptManager = new LoliScriptManager(); (var configSettings, var blocks) = loliScriptManager.Build(_configFile); if (string.IsNullOrEmpty(configSettings.Name)) { configSettings.Name = Path.GetFileNameWithoutExtension(_configFile); } if (!string.IsNullOrEmpty(configSettings.AdditionalInfo)) { AnsiConsole.MarkupLine($"[grey]CONFIG INFO:[/] {configSettings.AdditionalInfo}"); } if (configSettings.CustomInputs.Any()) { AnsiConsole.Write(new Rule("[darkorange]Custom input[/]").RuleStyle("grey").LeftAligned()); foreach (var customInput in configSettings.CustomInputs) { customInput.Value = AnsiConsole.Ask <string>($"{customInput.Description}:"); } } var botInputs = File.ReadAllLines(_wordlistFile).Where(w => !string.IsNullOrEmpty(w)).Select(w => new BotInput(w)); if (configSettings.InputRules.Any()) { botInputs = botInputs.Where(b => configSettings.InputRules.All(i => _checkInputRuleFunctions[i.Name].Invoke(b, i))); } var useProxy = _proxies.Any(); var proxyHttpClients = _proxies.Any() ? new List <ProxyHttpClient>(_proxies.Select(p => BuildProxy(p, _proxyType)).Select(p => new ProxyHttpClient(new HttpClientHandler() { UseCookies = false, Proxy = p }, p) { Timeout = TimeSpan.FromSeconds(15) })) : new List <ProxyHttpClient>() { new ProxyHttpClient(new HttpClientHandler() { UseCookies = false }, null) { Timeout = TimeSpan.FromSeconds(15) } }; var proxyHttpClientManager = new ProxyHttpClientManager(proxyHttpClients); if (useProxy) { _ = proxyHttpClientManager.StartValidateAllProxiesAsync(); } var record = GetRecord(configSettings.Name); Directory.CreateDirectory(Path.Combine(quickBulletSettings.OutputDirectory, configSettings.Name)); var skip = _skip == -1 ? record.Progress : _skip; var checkerStats = new CheckerStats(skip) { DegreeOfParallelism = _bots }; var statusesToBreak = new string[] { "toCheck", "failure", "retry", "ban", "error" }; var statusesToRecheck = new string[] { "retry", "ban", "error" }; var readerWriterLock = new ReaderWriterLock(); var handler = new HttpClientHandler() { UseCookies = false }; var httpClient = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(15) }; var playwright = await Playwright.CreateAsync(); Func <BotInput, CancellationToken, Task <bool> > check = new(async(input, cancellationToken) => { BotData botData = null; for (var attempts = 0; attempts < 8; attempts++) { var proxyHttpClient = proxyHttpClientManager.GetRandomProxyHttpClient(); botData = new BotData(quickBulletSettings, input, httpClient, proxyHttpClient, playwright) { UseProxy = useProxy }; botData.Variables.Add("data.proxy", proxyHttpClient.Proxy is null ? string.Empty : proxyHttpClient.Proxy.ToString()); foreach (var customInput in configSettings.CustomInputs) { botData.Variables.Add(customInput.Name, customInput.Value); } foreach (var block in blocks) { try { await block.RunAsync(botData); } catch (HttpRequestException) { proxyHttpClient.IsValid = false; botData.Variables["botStatus"] = "retry"; } catch (Exception error) { if (error.Message.Contains("HttpClient.Timeout") || error.Message.Contains("ERR_TIMED_OUT")) { proxyHttpClient.IsValid = false; } else if (_verbose) { AnsiConsole.WriteException(error); } botData.Variables["botStatus"] = "retry"; } if (statusesToBreak.Contains(botData.Variables["botStatus"], StringComparer.OrdinalIgnoreCase)) { break; } } await botData.DisposeAsync(); if (statusesToRecheck.Contains(botData.Variables["botStatus"], StringComparer.OrdinalIgnoreCase)) { if (botData.Variables["botStatus"].Equals("ban", StringComparison.OrdinalIgnoreCase)) { proxyHttpClient.IsValid = false; } checkerStats.Increment(botData.Variables["botStatus"]); } else { break; } } var botStatus = statusesToRecheck.Contains(botData.Variables["botStatus"], StringComparer.OrdinalIgnoreCase) ? "tocheck" : botData.Variables["botStatus"].ToLower(); if (botStatus.Equals("failure")) { checkerStats.Increment(botData.Variables["botStatus"]); } else { var outputPath = Path.Combine(quickBulletSettings.OutputDirectory, configSettings.Name, $"{botStatus}.txt"); var output = botData.Captures.Any() ? new StringBuilder().Append(botData.Input.ToString()).Append(quickBulletSettings.OutputSeparator).AppendJoin(quickBulletSettings.OutputSeparator, botData.Captures.Select(c => $"{c.Key} = {c.Value}")).ToString() : botData.Input.ToString(); try { readerWriterLock.AcquireWriterLock(int.MaxValue); using var streamWriter = File.AppendText(outputPath); await streamWriter.WriteLineAsync(output); } finally { readerWriterLock.ReleaseWriterLock(); } switch (botStatus) { case "success": AnsiConsole.MarkupLine($"[green4]SUCCESS:[/] {output}"); break; case "tocheck": AnsiConsole.MarkupLine($"[cyan3]TOCHECK:[/] {output}"); break; default: AnsiConsole.MarkupLine($"[orange3]{botStatus.ToUpper()}:[/] {output}"); break; } checkerStats.Increment(botStatus); } checkerStats.Increment("checked"); return(true); }); var paradllelizer = ParallelizerFactory <BotInput, bool> .Create(type : ParallelizerType.TaskBased, workItems : botInputs, workFunction : check, degreeOfParallelism : _bots, totalAmount : botInputs.Skip(skip).Count(), skip : skip); return(new Checker(paradllelizer, checkerStats, record)); }
static void Main(string[] args) { IDictionary <string, ILaunchInformation> launchInformation = new Dictionary <string, ILaunchInformation>(); IProcessRunner processRunner = null; AnsiConsole.Status() .Start("Starting...", ctx => { var bootStrapper = new BootStrapper(); var dataAccess = bootStrapper.ServiceProvider.GetRequiredService <IDataAccess>(); launchInformation = dataAccess.GetLaunchInformation(); processRunner = bootStrapper.ServiceProvider.GetRequiredService <IProcessRunner>(); }); AnsiConsole.MarkupLine($"Loaded {launchInformation.Count} links"); var table = new Table().Centered(); while (true) { string command = AnsiConsole.Ask <string>("Enter command:").Trim().ToLower(); if (command.Equals("exit")) { break; } if (command.Equals("list")) { PrintLaunchInformation(launchInformation); continue; } if (command.Equals("clear")) { System.Console.Clear(); continue; } if (launchInformation.TryGetValue(command, out ILaunchInformation value)) { processRunner.Run(value); continue; } var matches = launchInformation.Where(i => i.Key.Contains(command)).ToList(); if (matches.Count.Equals(0)) { AnsiConsole.WriteLine($"Invalid entry"); continue; } if (matches.Count > 1) { AnsiConsole.WriteLine($"{matches.Count} matches"); PrintLaunchInformation(matches); continue; } } System.Console.ReadLine(); }
public override Answer ask() { string response = AnsiConsole.Ask <string>(Question); return(new FreeAnswer(this, "voterName", response)); }
public void CollectInput(ScaffolderContext context) { var entityName = AnsiConsole.Ask <string>("What is the name of the entity?"); context.Variables.Set(Constants.EntityName, entityName); }
public static void Main(string[] args) { int option; new DataAccess().InitializeDatabase(); new ConfigAccess().InitializeDatabase(); do { Console.ForegroundColor = ConsoleColor.Blue; var panel = new Panel("1-Listar empleados\n2-Agregar empleado\n3-Eliminar empleado\n4-Modificar\n5-Buscar empleado\n6-Configuración\n0-Salir"); panel.Header("Menu", Justify.Center); panel.Border = BoxBorder.Rounded; AnsiConsole.Render(panel); option = AnsiConsole.Ask <int>("[purple]Ingrese la opción[/]"); Console.Clear(); Console.ForegroundColor = ConsoleColor.White; switch (option) { case 1: List <Employes> employees = DataAccess.ReadEmployees(); if (employees is not null) { ShowEmployeesTable(employees); ExportEmployeeListToHtml(); } else { ShowEmployeesTable(null); } break; case 2: DataAccess.CreateEmployee(); break; case 3: DataAccess.DeleteEmployee(); break; case 4: DataAccess.EditEmployee(); break; case 5: string idCard = AnsiConsole.Ask <string>("[green]Ingrese la cedula del empleado[/]"); employees = new List <Employes> { DataAccess.FindEmployeeByIdCard(idCard) }; // Add single employe to list ShowEmployeesTable(employees); break; case 6: var opt = AnsiConsole.Ask <int>("1-Crear configuracion\n2-Eliminar configuración\n3-Mostrar configuración"); Configuration.ConfigurationMenu(opt); Configuration = Configuration.ValidateConfiguration(); break; case 0: option = 0; break; default: Console.WriteLine($"La opción {option} no existe"); break; } } while (option != 0); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Adios!"); Thread.Sleep(1000); }