Default to semantic representation of assembly version in help text

This commit is contained in:
Alexey Golub
2020-05-16 14:49:25 +03:00
parent 4cef596fe8
commit f5e37b96fc
2 changed files with 12 additions and 1 deletions

View File

@@ -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;
}
}

View File

@@ -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();
}
}