File tree Expand file tree Collapse file tree 4 files changed +25
-8
lines changed Expand file tree Collapse file tree 4 files changed +25
-8
lines changed Original file line number Diff line number Diff line change
1
+ using GitVersion . Infrastructure ;
2
+ using GitVersion . SystemCommandline ;
3
+
4
+ namespace GitVersion ;
5
+
6
+ public class CliModule : IGitVersionModule
7
+ {
8
+ public void RegisterTypes ( IContainerRegistrar services )
9
+ => services
10
+ . AddSingleton < IGitVersionAppRunner , GitVersionAppRunner > ( )
11
+ . AddLogging ( ) ;
12
+ }
Original file line number Diff line number Diff line change
1
+ namespace GitVersion ;
2
+
3
+ internal interface IGitVersionAppRunner
4
+ {
5
+ Task < int > RunAsync ( string [ ] args , CancellationToken cancellationToken ) ;
6
+ }
Original file line number Diff line number Diff line change 8
8
{
9
9
new CoreModule ( ) ,
10
10
new LibGit2SharpCoreModule ( ) ,
11
- new CommandsModule ( )
11
+ new CommandsModule ( ) ,
12
+ new CliModule ( )
12
13
} ;
13
14
14
15
var cts = new CancellationTokenSource ( ) ;
15
16
Console . CancelKeyPress += ( _ , _ ) => cts . Cancel ( ) ;
16
17
17
18
using var serviceProvider = RegisterModules ( modules ) ;
18
- var app = serviceProvider . GetRequiredService < GitVersionApp > ( ) ;
19
- var result = await app . RunAsync ( args , cts . Token ) . ConfigureAwait ( false ) ;
19
+ var app = serviceProvider . GetRequiredService < IGitVersionAppRunner > ( ) ;
20
20
21
+ var result = 0 ;
22
+ result = await app . RunAsync ( args , cts . Token ) . ConfigureAwait ( false ) ;
21
23
if ( ! Console . IsInputRedirected ) Console . ReadKey ( ) ;
22
-
23
24
return result ;
24
25
25
26
static IContainer RegisterModules ( IEnumerable < IGitVersionModule > gitVersionModules )
26
27
{
27
28
var serviceProvider = new ContainerRegistrar ( )
28
29
. RegisterModules ( gitVersionModules )
29
- . AddSingleton < GitVersionApp > ( )
30
- . AddLogging ( )
31
30
. Build ( ) ;
32
31
33
32
return serviceProvider ;
Original file line number Diff line number Diff line change 3
3
using GitVersion . Infrastructure ;
4
4
using Serilog . Events ;
5
5
6
- namespace GitVersion ;
6
+ namespace GitVersion . SystemCommandline ;
7
7
8
8
// ReSharper disable once ClassNeverInstantiated.Global
9
- internal class GitVersionApp ( RootCommandImpl rootCommand )
9
+ internal class GitVersionAppRunner ( RootCommandImpl rootCommand ) : IGitVersionAppRunner
10
10
{
11
11
private readonly RootCommandImpl _rootCommand = rootCommand . NotNull ( ) ;
12
12
You can’t perform that action at this time.
0 commit comments