Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version line only #181

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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