@@ -16,7 +16,6 @@ static async Task Main(string[] args)
1616
1717 var workerStartupOptions = await GetStartupOptionsFromCmdLineArgs ( args ) ;
1818
19-
2019 using var appLoader = new AppLoader ( ) ;
2120 var grpcClient = new GrpcClient ( workerStartupOptions , appLoader ) ;
2221
@@ -30,30 +29,36 @@ static async Task Main(string[] args)
3029
3130 private static async Task < GrpcWorkerStartupOptions > GetStartupOptionsFromCmdLineArgs ( string [ ] args )
3231 {
33- var hostOption = new Option < string > ( "--host" ) ;
34- var portOption = new Option < int > ( "--port" ) ;
35- var workerOption = new Option < string > ( "--workerId" ) ;
36- var grpcMsgLengthOption = new Option < int > ( "--grpcMaxMessageLength" ) ;
37- var requestIdOption = new Option < string > ( "--requestId" ) ;
32+ var uriOption = new Option < string > ( "--functions-uri" ) { IsRequired = true } ;
33+ var requestIdOption = new Option < string > ( "--functions-request-id" ) { IsRequired = true } ;
34+ var workerIdOption = new Option < string > ( "--functions-worker-id" ) { IsRequired = true } ;
35+ var grpcMaxMessageLengthOption = new Option < int > ( "--functions-grpc-max-message-length" ) { IsRequired = true } ;
36+
37+ var rootCommand = new RootCommand
38+ {
39+ TreatUnmatchedTokensAsErrors = false
40+ } ;
3841
39- var rootCommand = new RootCommand ( ) ;
40- rootCommand . AddOption ( portOption ) ;
41- rootCommand . AddOption ( hostOption ) ;
42- rootCommand . AddOption ( workerOption ) ;
43- rootCommand . AddOption ( grpcMsgLengthOption ) ;
42+ rootCommand . AddOption ( uriOption ) ;
4443 rootCommand . AddOption ( requestIdOption ) ;
44+ rootCommand . AddOption ( workerIdOption ) ;
45+ rootCommand . AddOption ( grpcMaxMessageLengthOption ) ;
4546
4647 var workerStartupOptions = new GrpcWorkerStartupOptions ( ) ;
4748
48- rootCommand . SetHandler ( ( host , port , workerId , grpcMsgLength , requestId ) =>
49+ rootCommand . SetHandler ( ( context ) =>
4950 {
50- workerStartupOptions . Host = host ;
51- workerStartupOptions . Port = port ;
52- workerStartupOptions . WorkerId = workerId ;
53- workerStartupOptions . GrpcMaxMessageLength = grpcMsgLength ;
54- workerStartupOptions . RequestId = requestId ;
55- } ,
56- hostOption , portOption , workerOption , grpcMsgLengthOption , requestIdOption ) ;
51+ var uriString = context . ParseResult . GetValueForOption ( uriOption ) ;
52+ if ( ! Uri . TryCreate ( uriString , UriKind . Absolute , out var endpointUri ) )
53+ {
54+ throw new UriFormatException ( $ "'{ uriString } ' is not a valid value for argument '{ uriOption . Name } '. Value should be a valid URL.") ;
55+ }
56+
57+ workerStartupOptions . ServerUri = endpointUri ;
58+ workerStartupOptions . GrpcMaxMessageLength = context . ParseResult . GetValueForOption ( grpcMaxMessageLengthOption ) ;
59+ workerStartupOptions . RequestId = context . ParseResult . GetValueForOption ( requestIdOption ) ;
60+ workerStartupOptions . WorkerId = context . ParseResult . GetValueForOption ( workerIdOption ) ;
61+ } ) ;
5762
5863 Logger . LogTrace ( $ "raw args:{ string . Join ( " " , args ) } ") ;
5964
0 commit comments