From 1398bcec7f4151632acd60065ed45815509c1d13 Mon Sep 17 00:00:00 2001 From: Liam Neville Date: Fri, 17 Nov 2023 11:21:54 -0500 Subject: [PATCH] no --top default --- README.md | 2 +- USTACLI/cli/ListRankingsCommand.cs | 4 +++- USTACLI/cli/RankingsSettings.cs | 2 +- USTACLI/cli/Utilities.cs | 7 +++++++ USTACLI/usta-cli.csproj | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c698186..920a451 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Lists the top players in a given section and level - `-l | --level [3.0|3.5|4.0|4.5|5.0]` - `-s | --section [Eastern|Florida|Hawaii Pacific|Intermountain|Mid-Atlantic|Middle States|Midwest|Missouri Valley|New England|Northern California|Northern|Pacific NW|Southern|Southern California|Southwest|Texas|Unassigned]` - `-o | --output [html|json]` -- `t | --top [20|50|100]` +- `-t | --top [20|50|100]` --- diff --git a/USTACLI/cli/ListRankingsCommand.cs b/USTACLI/cli/ListRankingsCommand.cs index 5917fcd..e35d1b2 100644 --- a/USTACLI/cli/ListRankingsCommand.cs +++ b/USTACLI/cli/ListRankingsCommand.cs @@ -49,7 +49,9 @@ public override int Execute(CommandContext context, RankingsSettings settings) using (var driver = Driver.Create()) { // Scrape a page of players, add them to the list, update the live table and increment the page number - var pageOfPlayers = ScrapeRankings(driver, configuration, settings, context.Name, pageNumber).Take(Math.Min(20, settings.Top - players.Count())); +#nullable disable + var pageOfPlayers = ScrapeRankings(driver, configuration, settings, context.Name, pageNumber).Take(Math.Min(20, settings.Top.Value - players.Count())); +#nullable enable players.AddRange(pageOfPlayers); pageNumber++; if (pageOfPlayers.Count() < 20 || players.Count() >= settings.Top) diff --git a/USTACLI/cli/RankingsSettings.cs b/USTACLI/cli/RankingsSettings.cs index bc78142..126fa48 100644 --- a/USTACLI/cli/RankingsSettings.cs +++ b/USTACLI/cli/RankingsSettings.cs @@ -35,7 +35,7 @@ public class RankingsSettings : CommandSettings public string? Email { get; set; } [CommandOption("-t|--top")] - public int Top { get; set; } = 100; + public int? Top { get; set; } } public enum MatchFormat diff --git a/USTACLI/cli/Utilities.cs b/USTACLI/cli/Utilities.cs index 782f004..324aca9 100644 --- a/USTACLI/cli/Utilities.cs +++ b/USTACLI/cli/Utilities.cs @@ -69,6 +69,13 @@ public static void InteractiveFallback(RankingsSettings settings, IConfiguration new TextPrompt("[aqua]Email[/]:")); settings.Email = email; } + + if (settings.Top == null && context == "list") + { + var top = AnsiConsole.Prompt( + new TextPrompt("[aqua]Top N players[/]:")); + settings.Top = top; + } } diff --git a/USTACLI/usta-cli.csproj b/USTACLI/usta-cli.csproj index 9b501cd..5991986 100644 --- a/USTACLI/usta-cli.csproj +++ b/USTACLI/usta-cli.csproj @@ -10,7 +10,7 @@ usta-cli ./nupkg README.md - 2.0.8 + 2.0.9 https://github.com/lineville/usta-cli git