From f5e37b96fca1e1fe808adf4dcfd848877e6aef1a Mon Sep 17 00:00:00 2001 From: Alexey Golub Date: Sat, 16 May 2020 14:49:25 +0300 Subject: [PATCH] Default to semantic representation of assembly version in help text --- CliFx/CliApplicationBuilder.cs | 3 ++- CliFx/Internal/VersionExtensions.cs | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 CliFx/Internal/VersionExtensions.cs diff --git a/CliFx/CliApplicationBuilder.cs b/CliFx/CliApplicationBuilder.cs index e6f2dd1..153a039 100644 --- a/CliFx/CliApplicationBuilder.cs +++ b/CliFx/CliApplicationBuilder.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Reflection; using CliFx.Domain; +using CliFx.Internal; namespace CliFx { @@ -194,7 +195,7 @@ namespace CliFx private static string? GetDefaultVersionText() => EntryAssembly != null - ? $"v{EntryAssembly.GetName().Version}" + ? $"v{EntryAssembly.GetName().Version.ToSemanticString()}" : null; } } \ No newline at end of file diff --git a/CliFx/Internal/VersionExtensions.cs b/CliFx/Internal/VersionExtensions.cs new file mode 100644 index 0000000..3f7aeca --- /dev/null +++ b/CliFx/Internal/VersionExtensions.cs @@ -0,0 +1,10 @@ +using System; + +namespace CliFx.Internal +{ + internal static class VersionExtensions + { + public static string ToSemanticString(this Version version) => + version.Revision <= 0 ? version.ToString(3) : version.ToString(); + } +} \ No newline at end of file