Allow database file path to be passed as the first command line argument to the app

This adds support for directly opening files with the DHT app, for ex. in Windows Explorer by using "Open With", or by associating the ".dht" extension with the app.
This commit is contained in:
chylex 2022-03-05 16:43:58 +01:00
parent 6d3db23f80
commit 9a7a2cffc2
No known key found for this signature in database
GPG Key ID: 4DE42C8F19A80548

View File

@ -14,13 +14,19 @@ namespace DHT.Desktop {
public Arguments(string[] args) {
for (int i = 0; i < args.Length; i++) {
string key = args[i];
string value;
if (i >= args.Length - 1) {
if (i == 0 && !key.StartsWith('-')) {
value = key;
key = "-db";
}
else if (i >= args.Length - 1) {
Log.Warn("Missing value for command line argument: " + key);
continue;
}
string value = args[++i];
else {
value = args[++i];
}
switch (key) {
case "-db":