Skip to content

Commit

Permalink
Add -V/--version
Browse files Browse the repository at this point in the history
Fixes #531
  • Loading branch information
xPaw committed Aug 28, 2024
1 parent 53fefe6 commit 8117d8f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
26 changes: 23 additions & 3 deletions DepotDownloader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ static async Task<int> Main(string[] args)
{
if (args.Length == 0)
{
PrintVersion();
PrintUsage();

if (OperatingSystem.IsWindowsVersionAtLeast(5, 0))
Expand All @@ -38,18 +39,24 @@ static async Task<int> Main(string[] args)

#region Common Options

// Not using HasParameter because it is case insensitive
if (args.Length == 1 && (args[0] == "-V" || args[0] == "--version"))
{
PrintVersion(true);
return 0;
}

if (HasParameter(args, "-debug"))
{
PrintVersion(true);

DebugLog.Enabled = true;
DebugLog.AddListener((category, message) =>
{
Console.WriteLine("[{0}] {1}", category, message);
});

var httpEventListener = new HttpDiagnosticEventListener();

DebugLog.WriteLine("DepotDownloader", "Version: {0}", Assembly.GetExecutingAssembly().GetName().Version);
DebugLog.WriteLine("DepotDownloader", "Runtime: {0}", RuntimeInformation.FrameworkDescription);
}

var username = GetParameter<string>(args, "-username") ?? GetParameter<string>(args, "-user");
Expand Down Expand Up @@ -417,5 +424,18 @@ static void PrintUsage()
Console.WriteLine(" -max-downloads <#> - maximum number of chunks to download concurrently. (default: 8).");
Console.WriteLine(" -loginid <#> - a unique 32-bit integer Steam LogonID in decimal, required if running multiple instances of DepotDownloader concurrently.");
}

static void PrintVersion(bool printExtra = false)
{
var version = typeof(Program).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
Console.WriteLine($"DepotDownloader v{version}");

if (!printExtra)
{
return;
}

Console.WriteLine($"Runtime: {RuntimeInformation.FrameworkDescription} on {RuntimeInformation.OSDescription}");
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Parameter | Description
`-max-servers <#>` | maximum number of content servers to use. (default: 20).
`-max-downloads <#>` | maximum number of chunks to download concurrently. (default: 8).
`-loginid <#>` | a unique 32-bit integer Steam LogonID in decimal, required if running multiple instances of DepotDownloader concurrently.

`-V` or `--version` | print version and runtime

## Frequently Asked Questions

Expand Down

0 comments on commit 8117d8f

Please sign in to comment.