-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
62 lines (55 loc) · 2.07 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Runtime.Serialization.Json;
using System.Threading.Tasks;
namespace WebAPIClient
{
class Program
{
static void Main(string[] args)
{
while (true)
{
Console.Write("Enter a search query:");
var query = Console.ReadLine();
try
{
// only returns 30 at a time
GithubClient client = new GithubClient();
SearchResult result = client.PerformSearch(new EscapedString(query)).Result;
if(result.Count == 0)
{
Console.WriteLine("No results found.\n");
continue;
}
// basic print of results TODO put this in columns
foreach (var repo in result.items)
{
Console.WriteLine(repo.Name + "\t\t" + repo.LastPush);
}
// let the user know if there are more hidden results
var complete = result.Complete ? "some" : "all";
Console.WriteLine("\nShowing " + complete + " results: " + result.Count + " count\n\n");
}
catch(Exception e)
{
//TODO handle aggregate exceptions HttpResponseException
Console.WriteLine("Apologies, unable to reach the Github server: " + e.Message);
}
}
}
private void debugDotNetRepos()
{
System.Diagnostics.Debug.WriteLine("Hello World!");
GithubClient client = new GithubClient();
var repos = client.ProcessRepositories(new EscapedString("dotnet")).Result;
foreach (var repo in repos)
{
System.Diagnostics.Debug.WriteLine(repo.Name + " - " + repo.LastPush);
}
}
}
}