Skip to content

Commit

Permalink
Add extension method to use automatic application version
Browse files Browse the repository at this point in the history
  • Loading branch information
patriksvensson committed Apr 25, 2024
1 parent 3acc90e commit 5d4b2c8
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/Spectre.Console.Cli/ConfiguratorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static IConfigurator SetApplicationName(this IConfigurator configurator,
}

/// <summary>
/// Overrides the auto-detected version of the application.
/// Sets the version of the application.
/// </summary>
/// <param name="configurator">The configurator.</param>
/// <param name="version">The version of application.</param>
Expand All @@ -98,6 +98,25 @@ public static IConfigurator SetApplicationVersion(this IConfigurator configurato
return configurator;
}

/// <summary>
/// Uses the version retrieved from the <see cref="AssemblyInformationalVersionAttribute"/>
/// as the application's version.
/// </summary>
/// <param name="configurator">The configurator.</param>
/// <returns>A configurator that can be used to configure the application further.</returns>
public static IConfigurator UseAssemblyInformationalVersion(this IConfigurator configurator)
{
if (configurator == null)
{
throw new ArgumentNullException(nameof(configurator));
}

configurator.Settings.ApplicationVersion =
VersionHelper.GetVersion(Assembly.GetEntryAssembly());

return configurator;
}

/// <summary>
/// Hides the <c>DEFAULT</c> column that lists default values coming from the
/// <see cref="DefaultValueAttribute"/> in the options help text.
Expand Down

0 comments on commit 5d4b2c8

Please sign in to comment.