Skip to content

Commit

Permalink
Merge pull request #181 from ptr727/keyboard-quit
Browse files Browse the repository at this point in the history
Version line only
  • Loading branch information
ptr727 committed Jun 21, 2023
2 parents f6e111f + c618b6c commit 12205f8
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions PlexCleaner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,29 @@ private static int Main()
return exitCode;
}

public static string GetVersion(bool versionOnly)
{
var assembly = Assembly.GetEntryAssembly();
assembly ??= Assembly.GetExecutingAssembly();

var versionAttribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();

string version = versionAttribute?.InformationalVersion;
version ??= assembly.GetName()?.Version?.ToString();
version ??= "?";

string name = assembly.GetName()?.Name;
name ??= "?";

return versionOnly ? version : $"{name} : {version}";
}

private static bool ShowVersionInformation()
{
// Use the raw commandline and look for --version
if (Environment.CommandLine.Contains("--version"))
{
string appVersion = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
Console.WriteLine(appVersion);
Console.WriteLine(GetVersion(false));
return true;
}
return false;
Expand Down Expand Up @@ -496,9 +512,7 @@ private static Program Create(CommandLineOptions options, bool verifyTools)
#else
const bool debugBuild = false;
#endif
string appVersion = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
string runtimeVersion = Environment.Version.ToString();
Log.Logger.Information("Application Version : {AppVersion}, Runtime Version : {RuntimeVersion}, Debug Build: {DebugBuild}", appVersion, runtimeVersion, debugBuild);
Log.Logger.Information("Application Version : {AppVersion}, Runtime Version : {RuntimeVersion}, Debug Build: {DebugBuild}", GetVersion(true), Environment.Version.ToString(), debugBuild);

// Parallel processing config
if (Options.Parallel)
Expand Down

0 comments on commit 12205f8

Please sign in to comment.