-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathWaitForMigrationCommandBase.cs
More file actions
62 lines (52 loc) · 2.08 KB
/
WaitForMigrationCommandBase.cs
File metadata and controls
62 lines (52 loc) · 2.08 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
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.CommandLine;
using System.Runtime.CompilerServices;
using Microsoft.Extensions.DependencyInjection;
using OctoshiftCLI.Contracts;
using OctoshiftCLI.Services;
[assembly: InternalsVisibleTo("OctoshiftCLI.Tests")]
namespace OctoshiftCLI.Commands.WaitForMigration;
public class WaitForMigrationCommandBase : CommandBase<WaitForMigrationCommandArgs, WaitForMigrationCommandHandler>
{
public WaitForMigrationCommandBase() : base(
name: "wait-for-migration",
description: "Waits for migration(s) to finish and reports all in progress and queued ones.")
{
}
public virtual Option<string> MigrationId { get; } = new("--migration-id")
{
IsRequired = true,
Description = "Waits for the specified migration to finish."
};
public virtual Option<string> GithubPat { get; } = new("--github-pat")
{
Description = "Personal access token of the GitHub target. Overrides GH_PAT environment variable."
};
public virtual Option<string> TargetApiUrl { get; } = new("--target-api-url")
{
Description = "The URL of the target API, if not migrating to github.com. Defaults to https://api.github.com"
};
public virtual Option<bool> Verbose { get; } = new("--verbose");
protected void AddOptions()
{
AddOption(MigrationId);
AddOption(GithubPat);
AddOption(Verbose);
AddOption(TargetApiUrl);
}
public override WaitForMigrationCommandHandler BuildHandler(WaitForMigrationCommandArgs args, IServiceProvider sp)
{
if (args is null)
{
throw new ArgumentNullException(nameof(args));
}
if (sp is null)
{
throw new ArgumentNullException(nameof(sp));
}
var log = sp.GetRequiredService<OctoLogger>();
var githubApi = sp.GetRequiredService<ITargetGithubApiFactory>().Create(args.TargetApiUrl, null, args.GithubPat);
var warningsCountLogger = sp.GetRequiredService<WarningsCountLogger>();
return new WaitForMigrationCommandHandler(log, githubApi, warningsCountLogger);
}
}