File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the MIT license.
3+
4+ using System . Threading . Tasks ;
5+ using Microsoft . DotNet . DarcLib ;
6+ using Microsoft . DotNet . ProductConstructionService . Client . Models ;
7+ using Microsoft . Extensions . Logging ;
8+
9+ namespace Dotnet . Docker ;
10+
11+ internal class FromBuildCommand (
12+ IBasicBarClient barClient ,
13+ IBuildUpdaterService buildUpdaterService ,
14+ ILogger < FromBuildCommand > logger )
15+ : BaseCommand < FromBuildOptions >
16+ {
17+ private readonly IBasicBarClient _barClient = barClient ;
18+ private readonly IBuildUpdaterService _buildUpdaterService = buildUpdaterService ;
19+ private readonly ILogger < FromBuildCommand > _logger = logger ;
20+
21+ public override async Task < int > ExecuteAsync ( FromBuildOptions options )
22+ {
23+ _logger . LogInformation ( "Getting BAR build with ID {options.Id}" , options . Id ) ;
24+ Build build = await _barClient . GetBuildAsync ( options . Id ) ;
25+ return await _buildUpdaterService . UpdateFrom ( build , options ) ;
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the MIT license.
3+
4+ using System . Collections . Generic ;
5+ using System . CommandLine ;
6+
7+ namespace Dotnet . Docker ;
8+
9+ internal class FromBuildOptions : CreatePullRequestOptions , IOptions
10+ {
11+ public required int Id { get ; init ; }
12+
13+ public static new List < Argument > Arguments { get ; } =
14+ [
15+ new Argument < int > ( "id" )
16+ {
17+ Arity = ArgumentArity . ExactlyOne ,
18+ Description = "The BAR build ID to use as a source for the update (see https://aka.ms/bar)"
19+ } ,
20+ ..CreatePullRequestOptions . Arguments ,
21+ ] ;
22+
23+ public static new List < Option > Options { get ; } =
24+ [
25+ ..CreatePullRequestOptions . Options ,
26+ ] ;
27+ }
Original file line number Diff line number Diff line change 1414
1515var rootCommand = new RootCommand ( )
1616{
17+ FromBuildCommand . Create (
18+ name : "from-build" ,
19+ description : "Update dependencies using a specific BAR build" ) ,
1720 FromChannelCommand . Create (
1821 name : "from-channel" ,
1922 description : "Update dependencies using the latest build from a channel" ) ,
4649 services . AddSingleton < IBuildAssetService , BuildAssetService > ( ) ;
4750 services . AddSingleton < HttpClient > ( ) ;
4851
52+ FromBuildCommand . Register < FromBuildCommand > ( services ) ;
4953 FromChannelCommand . Register < FromChannelCommand > ( services ) ;
5054 SpecificCommand . Register < SpecificCommand > ( services ) ;
5155 } )
You can’t perform that action at this time.
0 commit comments