Skip to content

Commit

Permalink
no --top default
Browse files Browse the repository at this point in the history
  • Loading branch information
lineville committed Nov 17, 2023
1 parent 4a86252 commit 1398bce
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]`

---

Expand Down
4 changes: 3 additions & 1 deletion USTACLI/cli/ListRankingsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion USTACLI/cli/RankingsSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions USTACLI/cli/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ public static void InteractiveFallback(RankingsSettings settings, IConfiguration
new TextPrompt<string>("[aqua]Email[/]:"));
settings.Email = email;
}

if (settings.Top == null && context == "list")
{
var top = AnsiConsole.Prompt(
new TextPrompt<int>("[aqua]Top N players[/]:"));
settings.Top = top;
}
}


Expand Down
2 changes: 1 addition & 1 deletion USTACLI/usta-cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ToolCommandName>usta-cli</ToolCommandName>
<PackageOutputPath>./nupkg</PackageOutputPath>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageVersion>2.0.8</PackageVersion>
<PackageVersion>2.0.9</PackageVersion>
<RepositoryUrl>https://github.com/lineville/usta-cli</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
Expand Down

0 comments on commit 1398bce

Please sign in to comment.