diff --git a/eng/update-dependencies/Program.cs b/eng/update-dependencies/Program.cs index 7005fb777f..76171ac077 100644 --- a/eng/update-dependencies/Program.cs +++ b/eng/update-dependencies/Program.cs @@ -1,8 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.CommandLine; +using System.CommandLine.Help; using System.CommandLine.Hosting; +using System.IO; using System.Net.Http; using Dotnet.Docker; using Microsoft.DotNet.DarcLib; @@ -22,8 +25,20 @@ var config = new CommandLineConfiguration(rootCommand); config.UseHost( - _ => Host.CreateDefaultBuilder(), - host => host.ConfigureServices(services => + hostBuilderFactory: unmatchedArgs => + { + if (unmatchedArgs.Length > 0) + { + var helpBuilder = new HelpBuilder(); + using var stringWriter = new StringWriter(); + helpBuilder.Write(rootCommand, stringWriter); + Console.WriteLine(stringWriter.ToString()); + throw new InvalidOperationException($"Unmatched tokens: {string.Join(" ", unmatchedArgs)}"); + } + + return Host.CreateDefaultBuilder(); + }, + configureHost: host => host.ConfigureServices(services => { services.AddSingleton(_ => new BarApiClient(null, null, disableInteractiveAuth: true));