Skip to content
This repository was archived by the owner on Dec 24, 2021. It is now read-only.

Commit 3e65ac6

Browse files
committed
feat: start id command
1 parent beb56a9 commit 3e65ac6

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

comictracker/comictracker/Program.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static void Main(string[] args)
4646
break;
4747
case "search":
4848
// Implement search
49-
if (args.Length == 2)
49+
if (args.Length >= 2)
5050
{
5151
Login();
5252
Search(args[1]);
@@ -62,7 +62,7 @@ static void Main(string[] args)
6262
break;
6363
case "s-coll":
6464
// Search a collection
65-
if (args.Length == 2)
65+
if (args.Length >= 2)
6666
{
6767
SearchCollection(args[1]);
6868
}
@@ -71,6 +71,21 @@ static void Main(string[] args)
7171
WriteToConsole("You need to enter a comic to search for. Try again.", false, ConsoleColor.Red, Console.BackgroundColor);
7272
}
7373
break;
74+
case "id":
75+
if (args.Length >= 2)
76+
{
77+
try
78+
{
79+
Login();
80+
int id = Convert.ToInt32(args[1]);
81+
Id(id);
82+
}
83+
catch
84+
{
85+
WriteToConsole("There was an error retrieving the comic by ID. Please make sure your input is a number.", true, ConsoleColor.Red, Console.BackgroundColor);
86+
}
87+
}
88+
break;
7489
}
7590
}
7691
else
@@ -731,5 +746,18 @@ public static void UpdateComics(Comic comic)
731746

732747
ShowVolumeDetails(comic);
733748
}
749+
750+
private static void Id(int id)
751+
{
752+
try
753+
{
754+
var comic = Service.GetVolumeDetails(id);
755+
ShowVolumeDetails(comic);
756+
}
757+
catch
758+
{
759+
WriteToConsole("Comic with that Id was not found.", true, ConsoleColor.Red, Console.BackgroundColor);
760+
}
761+
}
734762
}
735763
}

0 commit comments

Comments
 (0)