switched the input arguments of teh downloader for better user experience
This commit is contained in:
parent
0b0f4eabb4
commit
dc0d579697
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
if (args.Length < 3)
|
||||
{
|
||||
Console.WriteLine("Usage: AdventOfCode-Downloader.exe <year> <day> <session-cookie>");
|
||||
Console.WriteLine("Usage: AdventOfCode-Downloader.exe <session-cookie> <year> <day>");
|
||||
return;
|
||||
}
|
||||
|
||||
int year, day;
|
||||
if (!(int.TryParse(args[0], out year) && year <= DateTime.Now.Year && year > 2015) || !(int.TryParse(args[1], out day) && day is >= 1 and <= 25))
|
||||
if (!(int.TryParse(args[1], out year) && year <= DateTime.Now.Year && year > 2015) || !(int.TryParse(args[2], out day) && day is >= 1 and <= 25))
|
||||
{
|
||||
Console.WriteLine("Invalid year or date argument.\nYear must be between 2015 and current year and day must be between 1 and 25");
|
||||
return;
|
||||
|
|
@ -20,7 +20,7 @@ if(!Directory.Exists(Path.GetDirectoryName(path)))
|
|||
|
||||
var url = new Uri($"https://adventofcode.com/{year}/day/{day}/input");
|
||||
using var client = new HttpClient();
|
||||
client.DefaultRequestHeaders.Add("Cookie", $"session={args[2]}");
|
||||
client.DefaultRequestHeaders.Add("Cookie", $"session={args[0]}");
|
||||
var responseMessage = await client.GetAsync(url);
|
||||
if (responseMessage.IsSuccessStatusCode)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue