Skip to content

Commit 52c2523

Browse files
committed
Add more error handling and info.
1 parent e275f68 commit 52c2523

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

Source/Contrib/SettingsExporter/Program.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,12 @@ static int Main(string[] args)
127127
var dir = Path.GetDirectoryName(Path.Combine(ApplicationInfo.ProcessDirectory, saveFilePath));
128128
if (!Directory.Exists(dir)) { Console.WriteLine("ERROR: Directory {0} to save to does not exist.", dir); Environment.Exit(1); }
129129
}
130-
else
131-
{
132-
// load from a custom registry key
133-
saveRegistryKey = toArg;
130+
else if (toArg.StartsWith("SOFTWARE")) { saveRegistryKey = toArg; }
131+
else
132+
{
133+
Console.WriteLine("ERROR: Invalid destination {0}.", toArg);
134+
Console.WriteLine("ERROR: Registry key must start with \"SOFTWARE\", or INI path must include \".ini\".");
135+
Environment.Exit(1);
134136
}
135137
#endregion
136138

@@ -186,6 +188,14 @@ static int Main(string[] args)
186188
// FUTURE: add here when a new settings class is added (that is not handled by UserSettings)
187189

188190
Console.WriteLine("Info: Successfully saved to {0}.", userSettings.GetSettingsStoreName());
191+
192+
if (toArg.Equals("REG") || toArg.Equals(SettingsBase.DefaultRegistryKey))
193+
{
194+
Console.WriteLine();
195+
Console.WriteLine("To use the settings in the registry, manually delete the INI file in the OpenRails folder.");
196+
Console.WriteLine(" eg: {0}", Path.Combine(ApplicationInfo.ProcessDirectory, SettingsBase.DefaultSettingsFileName));
197+
}
198+
189199
return 0;
190200
}
191201

@@ -197,8 +207,8 @@ static void ShowHelp()
197207
Console.WriteLine(" <from> Specify the source to load settings from. It may be:");
198208
Console.WriteLine(" INI : use the default INI file {0}.", SettingsBase.DefaultSettingsFileName);
199209
Console.WriteLine(" REG : use the default registry key {0}.", SettingsBase.DefaultRegistryKey);
200-
Console.WriteLine(" path : a specific INI file, relative to the OpenRails main folder. Must end with \".ini\".");
201-
Console.WriteLine(" key : a specific registry key, relative to the HKEY_CURRENT_USER key.");
210+
Console.WriteLine(" path : a specific INI file, relative to the OpenRails main folder. Must include \".ini\".");
211+
Console.WriteLine(" key : a specific registry key, relative to the HKEY_CURRENT_USER key. Must start with \"SOFTWARE\".");
202212
Console.WriteLine(" <to> Specify the destination to save the settings to. Similar to <from>.");
203213
Console.WriteLine(" /h, /help Show this help.");
204214
Console.WriteLine();

0 commit comments

Comments
 (0)