-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathStoreCommand.cs
More file actions
47 lines (40 loc) · 1.67 KB
/
StoreCommand.cs
File metadata and controls
47 lines (40 loc) · 1.67 KB
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
using System;
using System.Threading.Tasks;
namespace GitCredentialManager.Commands
{
/// <summary>
/// Store a previously created <see cref="GitCredential"/> in the OS secure credential store.
/// </summary>
public class StoreCommand : GitCommandBase
{
public StoreCommand(ICommandContext context, IHostProviderRegistry hostProviderRegistry)
: base(context, "store", "[Git] Store a credential", hostProviderRegistry) { }
protected override Task ExecuteInternalAsync(InputArguments input, IHostProvider provider)
{
return provider.StoreCredentialAsync(input);
}
protected override void EnsureMinimumInputArguments(InputArguments input)
{
base.EnsureMinimumInputArguments(input);
// An empty string username/password are valid inputs, so only check for `null` (not provided)
if (input.UserName is null)
{
throw new Trace2InvalidOperationException(Context.Trace2, "Missing 'username' input argument");
}
if (input.Password is null)
{
throw new Trace2InvalidOperationException(Context.Trace2, "Missing 'password' input argument");
}
}
public async Task SaveConfigurationAsync(string filePath)
{
var configService = new ConfigurationService(Context);
await configService.SaveConfigurationAsync(filePath);
}
public async Task LoadConfigurationAsync(string filePath)
{
var configService = new ConfigurationService(Context);
await configService.LoadConfigurationAsync(filePath);
}
}
}