Skip to content

Commit 8117d8f

Browse files
committed
Add -V/--version
Fixes #531
1 parent 53fefe6 commit 8117d8f

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

DepotDownloader/Program.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ static async Task<int> Main(string[] args)
2020
{
2121
if (args.Length == 0)
2222
{
23+
PrintVersion();
2324
PrintUsage();
2425

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

3940
#region Common Options
4041

42+
// Not using HasParameter because it is case insensitive
43+
if (args.Length == 1 && (args[0] == "-V" || args[0] == "--version"))
44+
{
45+
PrintVersion(true);
46+
return 0;
47+
}
48+
4149
if (HasParameter(args, "-debug"))
4250
{
51+
PrintVersion(true);
52+
4353
DebugLog.Enabled = true;
4454
DebugLog.AddListener((category, message) =>
4555
{
4656
Console.WriteLine("[{0}] {1}", category, message);
4757
});
4858

4959
var httpEventListener = new HttpDiagnosticEventListener();
50-
51-
DebugLog.WriteLine("DepotDownloader", "Version: {0}", Assembly.GetExecutingAssembly().GetName().Version);
52-
DebugLog.WriteLine("DepotDownloader", "Runtime: {0}", RuntimeInformation.FrameworkDescription);
5360
}
5461

5562
var username = GetParameter<string>(args, "-username") ?? GetParameter<string>(args, "-user");
@@ -417,5 +424,18 @@ static void PrintUsage()
417424
Console.WriteLine(" -max-downloads <#> - maximum number of chunks to download concurrently. (default: 8).");
418425
Console.WriteLine(" -loginid <#> - a unique 32-bit integer Steam LogonID in decimal, required if running multiple instances of DepotDownloader concurrently.");
419426
}
427+
428+
static void PrintVersion(bool printExtra = false)
429+
{
430+
var version = typeof(Program).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
431+
Console.WriteLine($"DepotDownloader v{version}");
432+
433+
if (!printExtra)
434+
{
435+
return;
436+
}
437+
438+
Console.WriteLine($"Runtime: {RuntimeInformation.FrameworkDescription} on {RuntimeInformation.OSDescription}");
439+
}
420440
}
421441
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Parameter | Description
8787
`-max-servers <#>` | maximum number of content servers to use. (default: 20).
8888
`-max-downloads <#>` | maximum number of chunks to download concurrently. (default: 8).
8989
`-loginid <#>` | a unique 32-bit integer Steam LogonID in decimal, required if running multiple instances of DepotDownloader concurrently.
90-
90+
`-V` or `--version` | print version and runtime
9191

9292
## Frequently Asked Questions
9393

0 commit comments

Comments
 (0)