forked from git-ecosystem/git-credential-manager
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Program.cs
57 lines (50 loc) · 1.74 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
using System.IO;
using System.Reflection;
using Atlassian.Bitbucket;
using GitHub;
using Microsoft.AzureRepos;
namespace Microsoft.Git.CredentialManager
{
public static class Program
{
public static void Main(string[] args)
{
string appPath = GetApplicationPath();
using (var context = new CommandContext())
using (var app = new Application(context, appPath))
{
// Register all supported host providers
app.RegisterProviders(
new AzureReposHostProvider(context),
new BitbucketHostProvider(context),
new GitHubHostProvider(context),
new GenericHostProvider(context)
);
// Run!
int exitCode = app.RunAsync(args)
.ConfigureAwait(false)
.GetAwaiter()
.GetResult();
Environment.Exit(exitCode);
}
}
private static string GetApplicationPath()
{
Assembly entryAssembly = Assembly.GetExecutingAssembly();
if (entryAssembly is null)
{
throw new InvalidOperationException();
}
string candidatePath = entryAssembly.Location;
// Strip the .dll from assembly name on Mac and Linux
if (!PlatformUtils.IsWindows() && Path.HasExtension(candidatePath))
{
return Path.ChangeExtension(candidatePath, null);
}
return candidatePath;
}
}
}