File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
4+ using System ;
45using System . CommandLine ;
6+ using System . CommandLine . Help ;
57using System . CommandLine . Hosting ;
8+ using System . IO ;
69using System . Net . Http ;
710using Dotnet . Docker ;
811using Microsoft . DotNet . DarcLib ;
2225var config = new CommandLineConfiguration ( rootCommand ) ;
2326
2427config . UseHost (
25- _ => Host . CreateDefaultBuilder ( ) ,
26- host => host . ConfigureServices ( services =>
28+ hostBuilderFactory : unmatchedArgs =>
29+ {
30+ if ( unmatchedArgs . Length > 0 )
31+ {
32+ var helpBuilder = new HelpBuilder ( ) ;
33+ using var stringWriter = new StringWriter ( ) ;
34+ helpBuilder . Write ( rootCommand , stringWriter ) ;
35+ Console . WriteLine ( stringWriter . ToString ( ) ) ;
36+ throw new InvalidOperationException ( $ "Unmatched tokens: { string . Join ( " " , unmatchedArgs ) } ") ;
37+ }
38+
39+ return Host . CreateDefaultBuilder ( ) ;
40+ } ,
41+ configureHost : host => host . ConfigureServices ( services =>
2742 {
2843 services . AddSingleton < IBasicBarClient > ( _ =>
2944 new BarApiClient ( null , null , disableInteractiveAuth : true ) ) ;
You can’t perform that action at this time.
0 commit comments