forked from dotnet/dotnet-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (46 loc) · 1.82 KB
/
Program.cs
File metadata and controls
53 lines (46 loc) · 1.82 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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.CommandLine;
using System.CommandLine.Help;
using System.CommandLine.Hosting;
using System.IO;
using System.Net.Http;
using Dotnet.Docker;
using Microsoft.DotNet.DarcLib;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var rootCommand = new RootCommand()
{
FromChannelCommand.Create(
name: "from-channel",
description: "Update dependencies using the latest build from a channel"),
SpecificCommand.Create(
name: "specific",
description: "Update dependencies using specific product versions"),
};
var config = new CommandLineConfiguration(rootCommand);
config.UseHost(
hostBuilderFactory: unmatchedArgs =>
{
if (unmatchedArgs.Length > 0)
{
var helpBuilder = new HelpBuilder();
using var stringWriter = new StringWriter();
helpBuilder.Write(rootCommand, stringWriter);
Console.WriteLine(stringWriter.ToString());
throw new InvalidOperationException($"Unmatched tokens: {string.Join(" ", unmatchedArgs)}");
}
return Host.CreateDefaultBuilder();
},
configureHost: host => host.ConfigureServices(services =>
{
services.AddSingleton<IBasicBarClient>(_ =>
new BarApiClient(null, null, disableInteractiveAuth: true));
services.AddSingleton<IBuildAssetService, BuildAssetService>();
services.AddSingleton<HttpClient>();
FromChannelCommand.Register<FromChannelCommand>(services);
SpecificCommand.Register<SpecificCommand>(services);
})
);
return await config.InvokeAsync(args);