diff --git a/CHANGELOG.md b/CHANGELOG.md index 1933fa4a87..9473854a1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added support for multipart form data request body in PHP. [#3029](https://github.com/microsoft/kiota/issues/3029) - Added uri-form encoded serialization for PHP. [#2074](https://github.com/microsoft/kiota/issues/2074) +- Added information message with base URL in the CLI experience. [#4635](https://github.com/microsoft/kiota/issues/4635) ### Changed diff --git a/src/Kiota.Builder/KiotaBuilder.cs b/src/Kiota.Builder/KiotaBuilder.cs index ef2920287b..5985e0534e 100644 --- a/src/Kiota.Builder/KiotaBuilder.cs +++ b/src/Kiota.Builder/KiotaBuilder.cs @@ -397,7 +397,10 @@ internal void FilterPathsByPatterns(OpenApiDocument doc) internal void SetApiRootUrl() { if (openApiDocument is not null && openApiDocument.GetAPIRootUrl(config.OpenAPIFilePath) is string candidateUrl) + { config.ApiRootUrl = candidateUrl; + logger.LogInformation("Client root URL set to {ApiRootUrl}", candidateUrl); + } else logger.LogWarning("No server url found in the OpenAPI document. The base url will need to be set when using the client."); } diff --git a/src/kiota/Handlers/BaseKiotaCommandHandler.cs b/src/kiota/Handlers/BaseKiotaCommandHandler.cs index 2646ccc4e3..8d9f25d494 100644 --- a/src/kiota/Handlers/BaseKiotaCommandHandler.cs +++ b/src/kiota/Handlers/BaseKiotaCommandHandler.cs @@ -287,6 +287,11 @@ private static string GetSourceArg(string path, string manifest) { return string.IsNullOrEmpty(manifest) ? $"-d \"{path}\"" : $"-a \"{manifest}\""; } + protected void DisplayUrlInformation(string? apiRootUrl, bool isPlugin = false) + { + if (!string.IsNullOrEmpty(apiRootUrl)) + DisplayInfo($"{(isPlugin ? "Plugin" : "Client")} base url set to {apiRootUrl}"); + } protected void DisplayGenerateCommandHint() { DisplayHint("Hint: use the client generate command to generate the code.", diff --git a/src/kiota/Handlers/Client/AddHandler.cs b/src/kiota/Handlers/Client/AddHandler.cs index e4d2237f89..b7eb188e97 100644 --- a/src/kiota/Handlers/Client/AddHandler.cs +++ b/src/kiota/Handlers/Client/AddHandler.cs @@ -121,7 +121,10 @@ public override async Task InvokeAsync(InvocationContext context) var builder = new KiotaBuilder(logger, Configuration.Generation, httpClient, true); var result = await builder.GenerateClientAsync(cancellationToken).ConfigureAwait(false); if (result) + { DisplaySuccess("Generation completed successfully"); + DisplayUrlInformation(Configuration.Generation.ApiRootUrl); + } else if (skipGeneration) { DisplaySuccess("Generation skipped as --skip-generation was passed"); diff --git a/src/kiota/Handlers/Client/EditHandler.cs b/src/kiota/Handlers/Client/EditHandler.cs index 6b65b92759..ae28990879 100644 --- a/src/kiota/Handlers/Client/EditHandler.cs +++ b/src/kiota/Handlers/Client/EditHandler.cs @@ -136,7 +136,10 @@ public override async Task InvokeAsync(InvocationContext context) var builder = new KiotaBuilder(logger, Configuration.Generation, httpClient, true); var result = await builder.GenerateClientAsync(cancellationToken).ConfigureAwait(false); if (result) + { DisplaySuccess("Generation completed successfully"); + DisplayUrlInformation(Configuration.Generation.ApiRootUrl); + } else if (skipGeneration) { DisplaySuccess("Generation skipped as --skip-generation was passed"); diff --git a/src/kiota/Handlers/Client/GenerateHandler.cs b/src/kiota/Handlers/Client/GenerateHandler.cs index 27e90907a3..9911911515 100644 --- a/src/kiota/Handlers/Client/GenerateHandler.cs +++ b/src/kiota/Handlers/Client/GenerateHandler.cs @@ -62,6 +62,7 @@ public override async Task InvokeAsync(InvocationContext context) if (result) { DisplaySuccess($"Update of {clientEntry.Key} client completed"); + DisplayUrlInformation(generationConfiguration.ApiRootUrl); var manifestPath = $"{GetAbsolutePath(Path.Combine(WorkspaceConfigurationStorageService.KiotaDirectorySegment, WorkspaceConfigurationStorageService.ManifestFileName))}#{clientEntry.Key}"; DisplayInfoHint(generationConfiguration.Language, string.Empty, manifestPath); } diff --git a/src/kiota/Handlers/KiotaGenerateCommandHandler.cs b/src/kiota/Handlers/KiotaGenerateCommandHandler.cs index c199f043ec..1f9cbbee49 100644 --- a/src/kiota/Handlers/KiotaGenerateCommandHandler.cs +++ b/src/kiota/Handlers/KiotaGenerateCommandHandler.cs @@ -125,7 +125,10 @@ public override async Task InvokeAsync(InvocationContext context) var builder = new KiotaBuilder(logger, Configuration.Generation, httpClient); var result = await builder.GenerateClientAsync(cancellationToken).ConfigureAwait(false); if (result) + { DisplaySuccess("Generation completed successfully"); + DisplayUrlInformation(Configuration.Generation.ApiRootUrl); + } else { DisplaySuccess("Generation skipped as no changes were detected"); diff --git a/src/kiota/Handlers/KiotaUpdateCommandHandler.cs b/src/kiota/Handlers/KiotaUpdateCommandHandler.cs index 5d71c8c9d9..629f0d30ae 100644 --- a/src/kiota/Handlers/KiotaUpdateCommandHandler.cs +++ b/src/kiota/Handlers/KiotaUpdateCommandHandler.cs @@ -62,7 +62,10 @@ public override async Task InvokeAsync(InvocationContext context) var results = await Task.WhenAll(configurations .Select(x => GenerateClientAsync(context, x, cancellationToken))); foreach (var (lockInfo, lockDirectoryPath) in locks) + { DisplaySuccess($"Update of {lockInfo?.ClientClassName} client for {lockInfo?.Language} at {lockDirectoryPath} completed"); + DisplayUrlInformation(configurations.FirstOrDefault(x => lockDirectoryPath.Equals(x.OutputPath, StringComparison.OrdinalIgnoreCase))?.ApiRootUrl); + } DisplaySuccess($"Update of {locks.Length} clients completed successfully"); foreach (var configuration in configurations) DisplayInfoHint(configuration.Language, configuration.OpenAPIFilePath, string.Empty); diff --git a/src/kiota/Handlers/Plugin/AddHandler.cs b/src/kiota/Handlers/Plugin/AddHandler.cs index be662926cd..bb31d1a269 100644 --- a/src/kiota/Handlers/Plugin/AddHandler.cs +++ b/src/kiota/Handlers/Plugin/AddHandler.cs @@ -73,7 +73,10 @@ public override async Task InvokeAsync(InvocationContext context) var builder = new KiotaBuilder(logger, Configuration.Generation, httpClient, true); var result = await builder.GeneratePluginAsync(cancellationToken).ConfigureAwait(false); if (result) + { DisplaySuccess("Generation completed successfully"); + DisplayUrlInformation(Configuration.Generation.ApiRootUrl); + } else if (skipGeneration) { DisplaySuccess("Generation skipped as --skip-generation was passed"); diff --git a/src/kiota/Handlers/Plugin/EditHandler.cs b/src/kiota/Handlers/Plugin/EditHandler.cs index ef78b19c29..a005fed5d1 100644 --- a/src/kiota/Handlers/Plugin/EditHandler.cs +++ b/src/kiota/Handlers/Plugin/EditHandler.cs @@ -90,7 +90,10 @@ public override async Task InvokeAsync(InvocationContext context) var builder = new KiotaBuilder(logger, Configuration.Generation, httpClient, true); var result = await builder.GeneratePluginAsync(cancellationToken).ConfigureAwait(false); if (result) + { DisplaySuccess("Generation completed successfully"); + DisplayUrlInformation(Configuration.Generation.ApiRootUrl); + } else if (skipGeneration) { DisplaySuccess("Generation skipped as --skip-generation was passed");