@@ -41,12 +41,7 @@ class Program
4141 {
4242 static async Task < int > Main ( string [ ] args )
4343 {
44- var customCommands = new List < Command > ( ) ;
45- customCommands . Add ( new LoginCommand ( ) . Build ( ) ) ;
46- customCommands . Add ( new LogoutCommand ( ) . Build ( ) ) ;
47-
48-
49- var builder = BuildCommandLine ( customCommands )
44+ var builder = BuildCommandLine ( )
5045 . UseDefaults ( )
5146 . UseHost ( a =>
5247 {
@@ -75,7 +70,7 @@ static async Task<int> Main(string[] args)
7570 {
7671 var host = ic . GetHost ( ) ;
7772
78- ic . BindingContext . AddService ( _ => host . Services . GetRequiredService < IAuthenticationCacheUtility > ( ) ) ;
73+ ic . BindingContext . AddService ( _ => host . Services . GetRequiredService < IAuthenticationCacheManager > ( ) ) ;
7974 ic . BindingContext . AddService ( _ => host . Services . GetRequiredService < AuthenticationServiceFactory > ( ) ) ;
8075 // Needed by LogoutCommand
8176 ic . BindingContext . AddService ( _ => host . Services . GetRequiredService < LogoutService > ( ) ) ;
@@ -115,7 +110,7 @@ static async Task<int> Main(string[] args)
115110 return await parser . InvokeAsync ( args ) ;
116111 }
117112
118- static CommandLineBuilder BuildCommandLine ( IEnumerable < Command > commands )
113+ static CommandLineBuilder BuildCommandLine ( )
119114 {
120115 var rootCommand = new GraphClient ( ) . BuildRootCommand ( ) ;
121116 rootCommand . Description = "Microsoft Graph CLI" ;
@@ -125,12 +120,11 @@ static CommandLineBuilder BuildCommandLine(IEnumerable<Command> commands)
125120 // --debug for configs.
126121 rootCommand . TreatUnmatchedTokensAsErrors = false ;
127122
128- foreach ( var command in commands )
129- {
130- rootCommand . AddCommand ( command ) ;
131- }
123+ var builder = new CommandLineBuilder ( rootCommand ) ;
124+ rootCommand . AddCommand ( new LoginCommand ( builder ) ) ;
125+ rootCommand . AddCommand ( new LogoutCommand ( ) ) ;
132126
133- return new CommandLineBuilder ( rootCommand ) ;
127+ return builder ;
134128 }
135129
136130 static IHostBuilder CreateHostBuilder ( string [ ] args ) =>
@@ -188,13 +182,13 @@ static IHostBuilder CreateHostBuilder(string[] args) =>
188182 return new HttpClientRequestAdapter ( authProvider , httpClient : client ) ;
189183 } ) ;
190184 services . AddSingleton < IPathUtility , PathUtility > ( ) ;
191- services . AddSingleton < IAuthenticationCacheUtility , AuthenticationCacheUtility > ( ) ;
185+ services . AddSingleton < IAuthenticationCacheManager , AuthenticationCacheManager > ( ) ;
192186 services . AddSingleton < LogoutService > ( ) ;
193187 services . AddSingleton < AuthenticationServiceFactory > ( p =>
194188 {
195189 var authSettings = p . GetRequiredService < IOptions < AuthenticationOptions > > ( ) ? . Value ;
196190 var pathUtil = p . GetRequiredService < IPathUtility > ( ) ;
197- var cacheUtil = p . GetRequiredService < IAuthenticationCacheUtility > ( ) ;
191+ var cacheUtil = p . GetRequiredService < IAuthenticationCacheManager > ( ) ;
198192 return new AuthenticationServiceFactory ( pathUtil , cacheUtil , authSettings ) ;
199193 } ) ;
200194 } ) . ConfigureLogging ( ( ctx , logBuilder ) =>
@@ -214,7 +208,7 @@ static void ConfigureAppConfiguration(IConfigurationBuilder builder, string[] ar
214208 builder . Sources . Clear ( ) ;
215209 builder . AddJsonFile ( Path . Combine ( System . AppContext . BaseDirectory , "app-settings.json" ) , optional : true ) ;
216210 var pathUtil = new PathUtility ( ) ;
217- var authCache = new AuthenticationCacheUtility ( pathUtil ) ;
211+ var authCache = new AuthenticationCacheManager ( pathUtil ) ;
218212 var dataDir = pathUtil . GetApplicationDataDirectory ( ) ;
219213 var userConfigPath = Path . Combine ( dataDir , "settings.json" ) ;
220214 builder . AddJsonFile ( userConfigPath , optional : true ) ;
0 commit comments