Enhanched Github Test app

This commit is contained in:
iminet
2026-09-27 16:34:12 +02:00
parent 839bf98840
commit ae47fbab7e
+40 -5
View File
@@ -1,5 +1,4 @@
using System.Collections; using Octokit;
using Octokit;
namespace Iminetsoft.Dev.GithubTest namespace Iminetsoft.Dev.GithubTest
{ {
@@ -7,14 +6,50 @@ namespace Iminetsoft.Dev.GithubTest
{ {
public static async Task Main(string[] Args) public static async Task Main(string[] Args)
{ {
var args = Iminetcore.ConsoleParser.ArgParser.ParseDynamic(Args); var args = Iminetsoft.Iminetcore.ConsoleParser.ArgParser.Parse(Args);
var github = new GitHubClient(new ProductHeaderValue("GithubTest")); var github = new GitHubClient(new ProductHeaderValue("GithubTest"));
github.Credentials = new Credentials(Environment.GetEnvironmentVariable("GITHUB_TOKEN")); github.Credentials = new Credentials(Environment.GetEnvironmentVariable("GITHUB_TOKEN"));
var repos = await github.Repository.GetAllForCurrent(); Console.WriteLine("GITHUB TEST APPLICATION");
repos.ToList().ForEach(r => Console.WriteLine($"{r.Name}")); foreach(var arg in args.ToList())
{
switch(arg.Key)
{
case "r":
case "repositories":
var repos = await github.Repository.GetAllForCurrent();
repos.ToList().ForEach(r => Console.WriteLine($"{r.Name}"));
break;
case "i":
case "issues":
var issues = await github.Issue.GetAllForCurrent(new IssueRequest()
{
State = ItemStateFilter.Open,
SortProperty = IssueSort.Created,
SortDirection = SortDirection.Descending
});
issues.ToList().ForEach(i => Console.WriteLine($"{i.Repository.Name}/{i.Title}"));
break;
case "u":
case "user":
var userinfo = await github.User.Current();
(new Dictionary<string,object>()
{
{ "Name", userinfo.Name },
{ "Username", userinfo.Login },
{ "Disk Usage", $"{userinfo.DiskUsage ?? 0} kB ({userinfo.DiskUsage/1024 ?? 0} MB)" },
{ "Followers", userinfo.Followers },
{ "Following", userinfo.Following },
{ "Avatar URL", userinfo.AvatarUrl },
{ "Profile URL", userinfo.HtmlUrl },
}).ToList().ForEach(x => Console.WriteLine($"{x.Key}: {x.Value}"));
break;
}
}
} }
} }
} }