Add project files.

This commit is contained in:
2024-01-21 14:50:44 -06:00
parent 6b79cee2f1
commit 9fc8818cc1
6 changed files with 178 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
// See https://aka.ms/new-console-template for more information
using Octokit;
using RepoBackupUtil.Lib;
static async Task Main()
{
// initialize our github client
ProductHeaderValue productHeaderValue = new("repo-backup-util");
GitHubClient github = new(productHeaderValue);
// check for user with received input
string username = GitHub.SetCredentialsToken(github);
User user = await GitHub.GetUser(username, github);
// get all repos for user
IEnumerable<Repository> repos = await GitHub.GetRepos(github) ?? throw new Exception("No repos found");
// organize and ensure all repositories are unique
HashSet<Repository> uniqueRepos = GitHub.GetUniqueRepos(repos);
// derive repository count and clone urls
var privateRepos = uniqueRepos.Where(r => r.Private);
var publicRepos = uniqueRepos.Where(r => !r.Private);
Console.WriteLine($"Found {privateRepos.Count()} private repos and {publicRepos.Count()} public repos.");
var cloneUrls = uniqueRepos.Select(r => r.CloneUrl);
}
await Main();