Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
 private static void Render(string title, IRenderable chart)
 {
     AnsiConsole.Write(
         new Panel(chart)
         .Padding(1, 1)
         .Header(title));
 }
    public override async Task <bool> Execute(HistoricalDataJobInput input)
    {
        var host           = input.BuildHost();
        var barsFileSource = host.Services.GetRequiredService <BarsFileSource>();

        var ShowExtension = false;

        var table = new Table();

        table.AddColumn("Date");
        if (ShowExtension)
        {
            table.AddColumn("Ext");
        }
        table.AddColumn("%", c => c.Alignment        = Justify.Right);
        table.AddColumn("Bars", c => c.Alignment     = Justify.Right);
        table.AddColumn("Expected", c => c.Alignment = Justify.Right);

        var listResult = await barsFileSource.List(input.ExchangeFlag, input.ExchangeAreaFlag, input.Symbol, input.TimeFrame);

        foreach (var item in listResult.Chunks)
        {
            table.AddRow(item.ChunkName, item.Percent.ToString(), item.Bars.ToString(), item.ExpectedBars.ToString());
            if (input.VerboseFlag)
            {
                Console.WriteLine(item.Dump().ToString());
            }
        }

        AnsiConsole.Write(table);

        return(true);
    }
Esempio n. 4
0
 private static string GetStock()
 {
     Console.ForegroundColor = ConsoleColor.DarkGray;
     AnsiConsole.Write("Stock Ticker: ");
     Console.ForegroundColor = ConsoleColor.White;
     return(Console.ReadLine()?.ToUpperInvariant());
 }
            private string SelectCsProj()
            {
                var csprojFiles = FileSystem.Directory.GetFiles(".", "*.csproj");

                if (csprojFiles.Length == 1)
                {
                    return(csprojFiles.First());
                }

                if (csprojFiles.Length == 0)
                {
                    AnsiConsole.Write(new Markup($"[bold red]Can't find a project file in current directory![/]"));
                    AnsiConsole.WriteLine();
                    AnsiConsole.Write(new Markup($"[bold red]Please run Sergen in a folder that contains the Asp.Net Core project.[/]"));
                    AnsiConsole.WriteLine();
                    return(null);
                }

                AnsiConsole.WriteLine();
                AnsiConsole.Write(new Spectre.Console.Rule($"[bold orange1]Please select an Asp.Net Core project file[/]")
                {
                    Alignment = Justify.Left
                });
                AnsiConsole.WriteLine();
                var selections = new SelectionPrompt <string>()
                                 .PageSize(10)
                                 .MoreChoicesText("[grey](Move up and down to reveal more project files)[/]")
                                 .AddChoices(csprojFiles);

                return(AnsiConsole.Prompt(selections));
            }
Esempio n. 6
0
 private static int GetAmount()
 {
     Console.ForegroundColor = ConsoleColor.DarkGray;
     AnsiConsole.Write("Amount: ");
     Console.ForegroundColor = ConsoleColor.White;
     return(Convert.ToInt32(Console.ReadLine()?.ToUpperInvariant()));
 }
        /// <summary>
        /// Handles the <see cref="ListCorrelationsCommand"/>
        /// </summary>
        /// <param name="filter">The ODATA filter to use</param>
        /// <returns>A new awaitable <see cref="Task"/></returns>
        public async Task HandleAsync(string filter)
        {
            var query   = string.Empty;
            var filters = new List <string>();

            if (!string.IsNullOrWhiteSpace(filter))
            {
                filters.Add(filter);
            }
            if (filters.Any())
            {
                query = $"$filter={string.Join(" AND ", filters)}";
            }
            var correlations = await this.SynapseManagementApi.GetCorrelationsAsync(query);

            var table = new Table();

            table.Expand = true;
            table.Border(TableBorder.None);
            table.AddColumn("ID");
            table.AddColumn("LIFETIME");
            table.AddColumn("OUTCOME TYPE");
            table.AddColumn("OUTCOME TARGET");
            table.AddColumn("CONDITION TYPE");
            table.AddColumn("CONDITIONS");
            table.AddColumn("CONTEXTS");
            table.AddColumn("CREATED AT");
            table.AddColumn("LAST MODIFIED");
            foreach (var correlation in correlations)
            {
                table.AddRow(correlation.Id, correlation.Lifetime.ToString(), correlation.Outcome.Type.ToString(), correlation.Outcome.Target, correlation.ConditionType.ToString(), correlation.Conditions.Count.ToString(), correlation.Contexts.Count.ToString(), correlation.CreatedAt.ToString(), correlation.LastModified.ToString());
            }
            AnsiConsole.Write(table);
        }
Esempio n. 8
0
 public void Write(string message)
 {
     lock (_lock)
     {
         _console?.Write(message);
     }
 }
Esempio n. 9
0
    public static void Main()
    {
        var content = new Markup(
            "[underline]I[/] heard [underline on blue]you[/] like panels\n\n\n\n" +
            "So I put a panel in a panel").Centered();

        AnsiConsole.Write(
            new Panel(
                new Panel(content)
                .Border(BoxBorder.Rounded)));

        // Left adjusted panel with text
        AnsiConsole.Write(
            new Panel(new Text("Left adjusted\nLeft").LeftAligned())
            .Expand()
            .SquareBorder()
            .Header("[red]Left[/]"));

        // Centered ASCII panel with text
        AnsiConsole.Write(
            new Panel(new Text("Centered\nCenter").Centered())
            .Expand()
            .AsciiBorder()
            .Header("[green]Center[/]")
            .HeaderAlignment(Justify.Center));

        // Right adjusted, rounded panel with text
        AnsiConsole.Write(
            new Panel(new Text("Right adjusted\nRight").RightAligned())
            .Expand()
            .RoundedBorder()
            .Header("[blue]Right[/]")
            .HeaderAlignment(Justify.Right));
    }
Esempio n. 10
0
 public void WriteHeader(IProjectionDatabase database)
 {
     AnsiConsole.Write(new Rule($"Database: {database.Identifier}")
     {
         Alignment = Justify.Left
     });
 }
Esempio n. 11
0
 private static void Render(IRenderable canvas, string title)
 {
     AnsiConsole.WriteLine();
     AnsiConsole.Write(new Rule($"[yellow]{title}[/]").LeftAligned().RuleStyle("grey"));
     AnsiConsole.WriteLine();
     AnsiConsole.Write(canvas);
 }
Esempio n. 12
0
        private void WriteSummaries(LamarServicesInput input, IGrouping <Assembly, IServiceFamilyConfiguration>[] configurations, WhatDoIHaveDisplay display,
                                    IContainer container)
        {
            if (display == WhatDoIHaveDisplay.Summary)
            {
                AnsiConsole.MarkupLine("[bold]Key:[/] ");

                var rule = new Rule($"[blue]Assembly Name (Assembly Version)[/]")
                {
                    Alignment = Justify.Left
                };
                AnsiConsole.Write(rule);


                var node = new Tree("{Service Type Namespace}");
                node.AddNode("{Service Type Full Name}").AddNode("{Lifetime}: {Description of Registration}");
                AnsiConsole.Write(node);
                Console.WriteLine();
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("Build Plans for registrations built by calling constructors");
                Console.WriteLine();
            }


            foreach (var group in configurations)
            {
                WriteAssemblyServices(input, @group, display, container);
            }
        }
Esempio n. 13
0
        private void GameLoop()
        {
            var header = new Rule($"\n[grey]World of {this.Game.World.Name}[/]")
                         .RuleStyle(Style.Parse("white dim"))
                         .LeftAligned();

            AnsiConsole.Write(header);

            AnsiConsole.MarkupLine("[green]You are currently in the city of {0}.[/]", this.Game.HomeCity.Name);
            AnsiConsole.MarkupLine("[green]There are {0} members in your guild.[/]", this.Game.GuildMembers.Count);

            string input = string.Empty;

            while (input != "exit")
            {
                AnsiConsole.Write(new Rule());

                input = AnsiConsole.Prompt(this.IngameMenu).ToLower();

                if (input == "save")
                {
                    this.SaveGame();
                }
            }
        }
Esempio n. 14
0
        public void Start()
        {
            System.Console.Clear();

            var header = new Rule("[grey]WorldGM v0.1[/]")
                         .RuleStyle(Style.Parse("white dim"))
                         .LeftAligned();

            AnsiConsole.Write(header);

            var choice = AnsiConsole.Prompt(this.MainMenu);

            if (choice == "New")
            {
                this.GenerateNewWorld();
            }
            else if (choice == "Load")
            {
                this.LoadExistingWorld();
            }
            else
            {
                // Exit
            }
        }
        /// <summary>
        /// Handles the <see cref="ListWorkflowsCommand"/>
        /// </summary>
        /// <param name="id">The id of the workflows to list</param>
        /// <param name="filter">The ODATA filter to use</param>
        /// <returns>A new awaitable <see cref="Task"/></returns>
        public async Task HandleAsync(string id, string filter)
        {
            var query   = string.Empty;
            var filters = new List <string>();

            if (!string.IsNullOrWhiteSpace(id))
            {
                filters.Add($"startswith({nameof(V1Workflow.Definition)}/{nameof(WorkflowDefinition.Id)},'{id}')");
            }
            if (!string.IsNullOrWhiteSpace(filter))
            {
                filters.Add(filter);
            }
            if (filters.Any())
            {
                query = $"$filter={string.Join(" AND ", filters)}";
            }
            var workflows = await this.SynapseManagementApi.GetWorkflowsAsync(query);

            var table = new Table();

            table.Expand = true;
            table.Border(TableBorder.None);
            table.AddColumn("ID");
            table.AddColumn("VERSION");
            table.AddColumn("CREATED AT");
            table.AddColumn("LAST INSTANCIATED AT");
            foreach (var workflow in workflows)
            {
                table.AddRow(workflow.Definition.Id !, workflow.Definition.Version, workflow.CreatedAt.ToString(), (workflow.LastInstanciated.HasValue ? workflow.LastInstanciated.ToString() : "-") !);
            }
            AnsiConsole.Write(table);
        }
Esempio n. 16
0
        static int Main(string[] args)
        {
            var rootCommand = new RootCommand("CLI for executing various actions against elmah.io")
            {
                new Option <bool>("--nologo", "Doesn't display the startup banner or the copyright message"),
            };

            rootCommand.AddCommand(ClearCommand.Create());
            rootCommand.AddCommand(DataloaderCommand.Create());
            rootCommand.AddCommand(DeploymentCommand.Create());
            rootCommand.AddCommand(ExportCommand.Create());
            rootCommand.AddCommand(LogCommand.Create());
            rootCommand.AddCommand(SourceMapCommand.Create());
            rootCommand.AddCommand(TailCommand.Create());

            if (args == null || args.All(arg => arg != "--nologo"))
            {
                AnsiConsole.Write(new FigletText("elmah.io")
                                  .LeftAligned()
                                  .Color(new Color(13, 165, 142)));
                AnsiConsole.MarkupLine("[yellow]Copyright (C)[/] [rgb(13,165,142)]elmah.io[/]. All rights reserved.");
            }

            args = args.Where(arg => arg != "--nologo").ToArray();
            AnsiConsole.WriteLine();

            return(rootCommand.InvokeAsync(args).Result);
        }
Esempio n. 17
0
        public static void Enter()
        {
            do
            {
                AnsiConsole.Write("> ");
                var userInput = Console.ReadLine()
                                .Trim();

                //if the input is a command
                if (userInput.StartsWith("/"))
                {
                    command.Commands.Execute(userInput, "calc");
                    continue;
                }

                //if the input is an assignment
                if (userInput.Contains("="))
                {
                    Variables.Assign(userInput);
                    continue;
                }

                var expression = new Expression(userInput);
                if (expression.IsValid)
                {
                    var value = expression.Solve();
                    if (value is null)
                    {
                        continue;
                    }
                    AnsiConsole.MarkupLine($"[blue]{value}[/]");
                }
            } while (true);
        }
Esempio n. 18
0
 private static double GetPrice()
 {
     Console.ForegroundColor = ConsoleColor.DarkGray;
     AnsiConsole.Write("Price: ");
     Console.ForegroundColor = ConsoleColor.White;
     return(double.Parse(Console.ReadLine()?.ToUpperInvariant()));
 }
Esempio n. 19
0
    public bool List(ProjectInformation project)
    {
        var result = FindProgram(project);

        if (result == null)
        {
            return(false);
        }

        var lines = GetLines(result);

        var table = new Table {
            ShowHeaders = false, Border = TableBorder.Rounded
        };

        table.AddColumn(new TableColumn(string.Empty)
        {
            NoWrap = true
        });
        table.AddColumn(string.Empty);

        var lineNumber = 1;

        foreach (var line in lines)
        {
            table.AddRow($"[grey]{lineNumber}[/]", line);
            lineNumber++;
        }

        AnsiConsole.WriteLine();
        AnsiConsole.Write(table);

        return(true);
    }
Esempio n. 20
0
        private static string AskName()
        {
            AnsiConsole.WriteLine();
            AnsiConsole.Write(new Rule("[yellow]Strings[/]").RuleStyle("grey").LeftAligned());
            var name = AnsiConsole.Ask <string>("What's your [green]name[/]?");

            return(name);
        }
        private void PlotAzureMetadataInAsciiTable(AzureMetadata metadata)
        {
            var asciiTable = CreateAzureMetadataAsciiTable();

            asciiTable.AddRow(metadata.TenantId, metadata.SubscriptionId, metadata.ResourceGroupName, metadata.Cloud.Name.Humanize(LetterCasing.Title));

            AnsiConsole.Write(asciiTable);
        }
Esempio n. 22
0
        public static void Main()
        {
            AnsiConsole.WriteLine();

            // Render the tree
            var tree = BuildTree();

            AnsiConsole.Write(tree);
        }
Esempio n. 23
0
    private async Task <long> Paint(Dictionary <Point, TileState> screen, ChannelReader <long> output, ChannelWriter <long> input)
    {
        bool enableOutput = true;

        try
        {
            AnsiConsole.Clear();
        }
        catch (Exception)
        {
            enableOutput = false;
            AnsiConsole.WriteLine("Console manipulation has been disabled due to redirection");
        }

        long score = 0, paddleX = 0, paddleY = 0;
        await input.WriteAsync(0);

        while (await output.WaitToReadAsync())
        {
            var x = (int)await output.ReadAsync();

            var y = (int)await output.ReadAsync();

            var state = await output.ReadAsync();

            if (x == -1 && y == 0)
            {
                score = state;
                if (enableOutput)
                {
                    AnsiConsole.Cursor.SetPosition(0, 0);
                    AnsiConsole.Write("Score: " + score);
                }
            }
            else
            {
                var tile = (TileState)state;
                if (tile == TileState.HorizontalPaddle)
                {
                    paddleX = x;
                    paddleY = y;
                }
                else if (tile == TileState.Ball)
                {
                    var num = 0;
                    if (x > paddleX)
                    {
                        num = 1;
                    }
                    else if (x < paddleX)
                    {
                        num = -1;
                    }
                    await input.WriteAsync(num);
                }

                screen[new(x, y)] = tile;
Esempio n. 24
0
 public void WriteHeader(IProjectionStore store)
 {
     AnsiConsole.WriteLine();
     AnsiConsole.Write(new Rule($"[bold blue]{store.Name}[/]")
     {
         Alignment = Justify.Left
     });
     AnsiConsole.WriteLine();
 }
Esempio n. 25
0
    private static void WritePlain(string windowsPath, string unixPath)
    {
        var table = new Table().BorderColor(Color.Grey).Title("Plain").RoundedBorder();

        table.AddColumns("[grey]OS[/]", "[grey]Path[/]");
        table.AddRow(new Text("Windows"), new TextPath(windowsPath));
        table.AddRow(new Text("Unix"), new TextPath(unixPath));

        AnsiConsole.Write(table);
    }
        private void PlotAzureMetadataInAsciiTable(AzureLandscape azureLandscape)
        {
            var asciiTable = CreateAzureMetadataAsciiTable();

            var rawSubscriptions = "- " + string.Join($"{Environment.NewLine} - ", azureLandscape.Subscriptions);

            asciiTable.AddRow(azureLandscape.TenantId, azureLandscape.Cloud.Humanize(LetterCasing.Title), rawSubscriptions);

            AnsiConsole.Write(asciiTable);
        }
Esempio n. 27
0
        private static void PrintMenuItem(string item, ConsoleColor color = ConsoleColor.White)
        {
            var itemShort = item.FirstOrDefault();

            Console.ForegroundColor = color;
            AnsiConsole.Write($"{itemShort}: ");
            Console.ForegroundColor = ConsoleColor.White;
            AnsiConsole.Write($"{item}");
            AnsiConsole.WriteLine();
        }
Esempio n. 28
0
 public static void Main(string[] args)
 {
     AnsiConsole.WriteLine();
     AnsiConsole.Write(new Calendar(2020, 10)
                       .RoundedBorder()
                       .HighlightStyle(Style.Parse("red"))
                       .HeaderStyle(Style.Parse("yellow"))
                       .AddCalendarEvent("An event", 2020, 9, 22)
                       .AddCalendarEvent("Another event", 2020, 10, 2)
                       .AddCalendarEvent("A third event", 2020, 10, 13));
 }
Esempio n. 29
0
        public override async Task <int> ExecuteAsync(CommandContext context, ShowLogHeaderSettings settings)
        {
            if (witsmlClient == null)
            {
                return(-1);
            }

            var table = CreateTable();

            var wellName     = "<?>";
            var wellboreName = "<?>";
            var logName      = "<?>";

            await AnsiConsole.Status()
            .Spinner(Spinner.Known.Dots)
            .StartAsync("Fetching log...".WithColor(Color.Orange1), async _ =>
            {
                var log      = await GetLogHeader(settings.WellUid, settings.WellboreUid, settings.LogUid);
                wellName     = log.NameWell;
                wellboreName = log.NameWellbore;
                logName      = log.Name;

                var list = settings.OrderByEndIndex
                        ? log.LogCurveInfo.OrderByDescending(lci => DateTime.Parse(lci.MaxDateTimeIndex)).ToList()
                        : log.LogCurveInfo;


                foreach (var logCurveInfo in list.Take(settings.MaxMnemonics))
                {
                    if (!string.IsNullOrEmpty(settings.FilterOnMnemonic) && logCurveInfo.Mnemonic != settings.FilterOnMnemonic)
                    {
                        continue;
                    }

                    table.AddRow(
                        logCurveInfo.Mnemonic,
                        logCurveInfo.MinDateTimeIndex ?? $"{logCurveInfo.MinIndex.Value}{logCurveInfo.MinIndex.Uom}",
                        logCurveInfo.MaxDateTimeIndex ?? $"{logCurveInfo.MaxIndex.Value}{logCurveInfo.MaxIndex.Uom}"
                        );
                }
            });

            AnsiConsole.WriteLine();
            AnsiConsole.MarkupLine($"{"Well UID:".Bold()} {settings.WellUid}");
            AnsiConsole.MarkupLine($"{"Wellbore UID:".Bold()} {settings.WellboreUid}");
            AnsiConsole.MarkupLine($"{"Log UID".Bold()} {settings.LogUid}");
            AnsiConsole.MarkupLine($"{"Well name:".Bold()} {wellName}");
            AnsiConsole.MarkupLine($"{"Wellbore name:".Bold()} {wellboreName}");
            AnsiConsole.MarkupLine($"{"Log name:".Bold()} {logName}");
            AnsiConsole.Write(table);

            return(0);
        }
Esempio n. 30
0
        public static void Main(string[] args)
        {
            AnsiConsole.Write("Hello");

            // Move the cursor 3 cells to the right
            AnsiConsole.Cursor.Move(CursorDirection.Right, 3);
            AnsiConsole.Write("World");

            // Move the cursor 5 cells to the left.
            AnsiConsole.Cursor.Move(CursorDirection.Left, 5);
            AnsiConsole.WriteLine("Universe");
        }