File tree Expand file tree Collapse file tree 3 files changed +24
-9
lines changed
tests/ConsoleAppFramework.GeneratorTests Expand file tree Collapse file tree 3 files changed +24
-9
lines changed Original file line number Diff line number Diff line change 1
1
using ConsoleAppFramework ;
2
2
using FilterShareProject ;
3
+ using System . Reflection ;
4
+
3
5
//using Microsoft.Extensions.DependencyInjection;
4
6
using System . Runtime . CompilerServices ;
5
7
6
-
7
- args = [ "Output" ] ;
8
-
8
+ args = [ "--version" ] ;
9
+ Console . WriteLine ( args . Length ) ;
10
+ Console . WriteLine ( args . AsSpan ( 0 ) . Length ) ;
9
11
10
12
// ConsoleApp.ServiceProvider
11
13
// ConsoleApp.Create(
12
14
13
15
16
+ // ConsoleApp.Run(args, (int x, int y) => { });
14
17
var app = ConsoleApp . Create ( ) ;
15
-
16
- // var app = ConsoleApp.Create();
17
-
18
- // app.Add<MyCommands>();
19
- app . Add < MyCommands > ( ) ;
18
+ app . Add < MyCommands > ( "zzz" ) ;
20
19
21
20
app . Run ( args ) ;
22
21
Original file line number Diff line number Diff line change @@ -500,7 +500,7 @@ void EmitLeafCommand(CommandWithId? command)
500
500
{
501
501
if ( command == null )
502
502
{
503
- sb . AppendLine ( " ShowHelp(-1);") ;
503
+ sb . AppendLine ( $ "if (!TryShowHelpOrVersion(args.AsSpan( { depth } ), -1, -1)) ShowHelp(-1);") ;
504
504
}
505
505
else
506
506
{
Original file line number Diff line number Diff line change @@ -34,6 +34,22 @@ public void Version()
34
34
expected : """
35
35
9999.9999999abcdefg
36
36
37
+ """ ) ;
38
+ }
39
+
40
+ [ Fact ]
41
+ public void VersionOnBuilder ( )
42
+ {
43
+ var version = Assembly . GetEntryAssembly ( ) ? . GetCustomAttribute < AssemblyInformationalVersionAttribute > ( ) ? . InformationalVersion ?? "1.0.0" ;
44
+
45
+ verifier . Execute ( code : """
46
+ var app = ConsoleApp.Create();
47
+ app.Run(args);
48
+ """ ,
49
+ args : "--version" ,
50
+ expected : $$ """
51
+ {{ version }}
52
+
37
53
""" ) ;
38
54
}
39
55
You can’t perform that action at this time.
0 commit comments