From 5d4b2c88e53f538b4ade5fba6207a25b0af80a66 Mon Sep 17 00:00:00 2001 From: Patrik Svensson Date: Thu, 25 Apr 2024 19:51:05 +0200 Subject: [PATCH] Add extension method to use automatic application version --- .../ConfiguratorExtensions.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Spectre.Console.Cli/ConfiguratorExtensions.cs b/src/Spectre.Console.Cli/ConfiguratorExtensions.cs index eb3f1be19..80895e302 100644 --- a/src/Spectre.Console.Cli/ConfiguratorExtensions.cs +++ b/src/Spectre.Console.Cli/ConfiguratorExtensions.cs @@ -82,7 +82,7 @@ public static IConfigurator SetApplicationName(this IConfigurator configurator, } /// - /// Overrides the auto-detected version of the application. + /// Sets the version of the application. /// /// The configurator. /// The version of application. @@ -98,6 +98,25 @@ public static IConfigurator SetApplicationVersion(this IConfigurator configurato return configurator; } + /// + /// Uses the version retrieved from the + /// as the application's version. + /// + /// The configurator. + /// A configurator that can be used to configure the application further. + public static IConfigurator UseAssemblyInformationalVersion(this IConfigurator configurator) + { + if (configurator == null) + { + throw new ArgumentNullException(nameof(configurator)); + } + + configurator.Settings.ApplicationVersion = + VersionHelper.GetVersion(Assembly.GetEntryAssembly()); + + return configurator; + } + /// /// Hides the DEFAULT column that lists default values coming from the /// in the options help text.