-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathDeployCommand.cs
More file actions
50 lines (41 loc) · 1.65 KB
/
DeployCommand.cs
File metadata and controls
50 lines (41 loc) · 1.65 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
48
49
50
namespace PolyDeploy.DeployClient
{
using System.IO.Abstractions;
using Spectre.Console.Cli;
using Spectre.Console;
public class DeployCommand : AsyncCommand<DeployInput>
{
private readonly IFileSystem fileSystem;
private readonly IDeployer deployer;
public DeployCommand(IDeployer deployer, IFileSystem fileSystem)
{
this.deployer = deployer;
this.fileSystem = fileSystem;
}
public override async Task<int> ExecuteAsync(CommandContext context, DeployInput input)
{
var exitCode = await this.deployer.StartAsync(input);
return (int)exitCode;
}
public override ValidationResult Validate(CommandContext context, DeployInput settings)
{
if (!string.IsNullOrWhiteSpace(settings.PackagesDirectoryPath) && !this.fileSystem.Directory.Exists(settings.PackagesDirectoryPath))
{
return ValidationResult.Error("--packages-directory must be a valid path");
}
if (!Uri.TryCreate(settings.TargetUri, UriKind.Absolute, out _))
{
return ValidationResult.Error("--target-uri must be a valid URI");
}
if (settings.InstallationStatusTimeout < 0)
{
return ValidationResult.Error("--installation-status-timeout must be non-negative");
}
if (!Enum.GetValues<LogLevel>().Contains(settings.LogLevel))
{
return ValidationResult.Error("--log-level must be a valid log level");
}
return ValidationResult.Success();
}
}
}