aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/slskd/Program.cs')
-rw-r--r--src/slskd/Program.cs55
1 files changed, 34 insertions, 21 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index e4257037..b109c76b 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -74,45 +74,49 @@ namespace slskd
public static readonly string DefaultAppDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.DoNotVerify), AppName);
/// <summary>
- /// Gets the assembly version of the application.
+ /// Gets the unique Id of this application invocation.
/// </summary>
+ public static readonly Guid InvocationId = Guid.NewGuid();
+
+ /// <summary>
+ /// Gets the Id of the current application process.
+ /// </summary>
+ public static readonly int ProcessId = Environment.ProcessId;
+
/// <remarks>
/// Inaccurate when running locally.
/// </remarks>
- public static readonly Version AssemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.Equals(new Version(1, 0, 0, 0)) ? new Version(0, 0, 0, 0) : Assembly.GetExecutingAssembly().GetName().Version;
+ private static readonly Version AssemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.Equals(new Version(1, 0, 0, 0)) ? new Version(0, 0, 0, 0) : Assembly.GetExecutingAssembly().GetName().Version;
- /// <summary>
- /// Gets the informational version of the application, including the git sha at the latest commit.
- /// </summary>
/// <remarks>
/// Inaccurate when running locally.
/// </remarks>
- public static readonly string InformationalVersion = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion == "1.0.0" ? "0.0.0" : Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
+ private static readonly string InformationalVersion = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion == "1.0.0" ? "0.0.0" : Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
/// <summary>
- /// Gets the full application version, including both assembly and informational versions.
+ /// Occurs when a new log event is emitted.
/// </summary>
- public static readonly string Version = $"{AssemblyVersion} ({InformationalVersion})";
+ public static event EventHandler<LogRecord> LogEmitted;
/// <summary>
- /// Gets a value indicating whether the current version is a Canary build.
+ /// Gets the semantic application version.
/// </summary>
- public static readonly bool IsCanary = AssemblyVersion.Revision == 65534;
+ public static string SemanticVersion => InformationalVersion.Split('-').First();
/// <summary>
- /// Gets the unique Id of this application invocation.
+ /// Gets the full application version, including both assembly and informational versions.
/// </summary>
- public static readonly Guid InvocationId = Guid.NewGuid();
+ public static string FullVersion => $"{SemanticVersion} ({InformationalVersion})";
/// <summary>
- /// Gets the Id of the current application process.
+ /// Gets a value indicating whether the current version is a Canary build.
/// </summary>
- public static readonly int ProcessId = Environment.ProcessId;
+ public static bool IsCanary => AssemblyVersion.Revision == 65534;
/// <summary>
- /// Occurs when a new log event is emitted.
+ /// Gets a value indicating whether the current version is a Development build.
/// </summary>
- public static event EventHandler<LogRecord> LogEmitted;
+ public static bool IsDevelopment => new Version(0, 0, 0, 0) == AssemblyVersion;
/// <summary>
/// Gets the path where application data is saved.
@@ -172,7 +176,7 @@ namespace slskd
if (ShowVersion)
{
- Console.WriteLine(Version);
+ Console.WriteLine(FullVersion);
return;
}
@@ -180,7 +184,7 @@ namespace slskd
{
if (!NoLogo)
{
- PrintLogo(Version);
+ PrintLogo(FullVersion);
}
if (ShowHelp)
@@ -249,7 +253,6 @@ namespace slskd
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("System.Net.Http.HttpClient", OptionsAtStartup.Debug ? LogEventLevel.Warning : LogEventLevel.Fatal)
.MinimumLevel.Override("slskd.Authentication.PassthroughAuthenticationHandler", LogEventLevel.Warning)
- .Enrich.WithProperty("Version", Version)
.Enrich.WithProperty("InstanceName", OptionsAtStartup.InstanceName)
.Enrich.WithProperty("InvocationId", InvocationId)
.Enrich.WithProperty("ProcessId", ProcessId)
@@ -285,10 +288,15 @@ namespace slskd
if (!OptionsAtStartup.NoLogo)
{
- PrintLogo(Version);
+ PrintLogo(FullVersion);
}
- logger.Information("Version: {Version}", Version);
+ logger.Information("Version: {Version}", FullVersion);
+
+ if (IsDevelopment)
+ {
+ logger.Warning("This is a Development build; YMMV");
+ }
if (IsCanary)
{
@@ -558,6 +566,11 @@ namespace slskd
│ │
│{centeredVersion}│";
+ if (IsDevelopment)
+ {
+ banner += "\n│■■■■■■■■■■■■■■■■■■■■► DEVELOPMENT ◄■■■■■■■■■■■■■■■■■■■■■│";
+ }
+
if (IsCanary)
{
banner += "\n│■■■■■■■■■■■■■■■■■■■■■■■► CANARY ◄■■■■■■■■■■■■■■■■■■■■■■■│";