@@ -89,6 +89,60 @@ public async Task TwoSubCommandTest()
8989 }
9090 }
9191
92+ public class AliasCommand : BatchBase
93+ {
94+ [ Command ( new [ ] { "run" , "r" } ) ]
95+ public void Run ( string path , string pfx )
96+ {
97+ Context . Logger . LogInformation ( $ "path:{ path } ") ;
98+ Context . Logger . LogInformation ( $ "pfx:{ pfx } ") ;
99+ }
100+
101+ [ Command ( new [ ] { "su" , "summmm" } ) ]
102+ public void Sum ( [ Option ( 0 ) ] int x , [ Option ( 1 ) ] int y )
103+ {
104+ Context . Logger . LogInformation ( $ "{ x + y } ") ;
105+ }
106+ }
107+
108+ [ Fact ]
109+ public async Task AliasCommandTest ( )
110+ {
111+ {
112+ var collection = new [ ] {
113+ "r -path foo -pfx bar" . Split ( ' ' ) ,
114+ "run -path foo -pfx bar" . Split ( ' ' ) ,
115+ } ;
116+ foreach ( var args in collection )
117+ {
118+ var log = new LogStack ( ) ;
119+ await new HostBuilder ( )
120+ . ConfigureTestLogging ( testOutput , log , true )
121+ . RunBatchEngineAsync < AliasCommand > ( args ) ;
122+ log . InfoLogShouldBe ( 0 , "path:foo" ) ;
123+ log . InfoLogShouldBe ( 1 , "pfx:bar" ) ;
124+ }
125+ }
126+ {
127+ {
128+ var args = "su 10 20" . Split ( ' ' ) ;
129+ var log = new LogStack ( ) ;
130+ await new HostBuilder ( )
131+ . ConfigureTestLogging ( testOutput , log , true )
132+ . RunBatchEngineAsync < AliasCommand > ( args ) ;
133+ log . InfoLogShouldBe ( 0 , "30" ) ;
134+ }
135+ {
136+ var args = "summmm 99 100" . Split ( ' ' ) ;
137+ var log = new LogStack ( ) ;
138+ await new HostBuilder ( )
139+ . ConfigureTestLogging ( testOutput , log , true )
140+ . RunBatchEngineAsync < AliasCommand > ( args ) ;
141+ log . InfoLogShouldBe ( 0 , "199" ) ;
142+ }
143+ }
144+ }
145+
92146 public class NotFoundPath : BatchBase
93147 {
94148 [ Command ( "run" ) ]
0 commit comments