summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-05-28 01:58:50 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-05-28 01:58:50 -0400
commit2109229660f1d8bce001c25fc6e83c0450ffc8c1 (patch)
tree86c39fb202f6a1bfb7c821423903d03269416d88 /src
parent5af58c7b18a120ce47f230ede7f116678d97e038 (diff)
downloadSMAPI-2109229660f1d8bce001c25fc6e83c0450ffc8c1.tar.gz
SMAPI-2109229660f1d8bce001c25fc6e83c0450ffc8c1.tar.bz2
SMAPI-2109229660f1d8bce001c25fc6e83c0450ffc8c1.zip
add 'reload_i18n' console command to reload translation files (#296)
Diffstat (limited to 'src')
-rw-r--r--src/StardewModdingAPI/Program.cs44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index 6939a03d..d75d5193 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -442,10 +442,11 @@ namespace StardewModdingAPI
[SuppressMessage("ReSharper", "FunctionNeverReturns", Justification = "The thread is aborted when the game exits.")]
private void RunConsoleLoop()
{
- // prepare help command
+ // prepare console
this.Monitor.Log("Starting console...");
this.Monitor.Log("Type 'help' for help, or 'help <cmd>' for a command's usage", LogLevel.Info);
- this.CommandManager.Add("SMAPI", "help", "Lists all commands | 'help <cmd>' returns command description", this.HandleHelpCommand);
+ this.CommandManager.Add("SMAPI", "help", "Lists command documentation.\n\nUsage: help\nLists all available commands.\n\nUsage: help <cmd>\n- cmd: The name of a command whose documentation to display.", this.HandleCommand);
+ this.CommandManager.Add("SMAPI", "reload_i18n", "Reloads translation files for all mods.\n\nUsage: reload_i18n", this.HandleCommand);
// start handling command line input
Thread inputThread = new Thread(() =>
@@ -718,23 +719,36 @@ namespace StardewModdingAPI
}
}
- /// <summary>The method called when the user submits the help command in the console.</summary>
+ /// <summary>The method called when the user submits a core SMAPI command in the console.</summary>
/// <param name="name">The command name.</param>
/// <param name="arguments">The command arguments.</param>
- private void HandleHelpCommand(string name, string[] arguments)
+ private void HandleCommand(string name, string[] arguments)
{
- if (arguments.Any())
+ switch (name)
{
- Framework.Command result = this.CommandManager.Get(arguments[0]);
- if (result == null)
- this.Monitor.Log("There's no command with that name.", LogLevel.Error);
- else
- this.Monitor.Log($"{result.Name}: {result.Documentation}\n(Added by {result.ModName}.)", LogLevel.Info);
- }
- else
- {
- this.Monitor.Log("The following commands are registered: " + string.Join(", ", this.CommandManager.GetAll().Select(p => p.Name)) + ".", LogLevel.Info);
- this.Monitor.Log("For more information about a command, type 'help command_name'.", LogLevel.Info);
+ case "help":
+ if (arguments.Any())
+ {
+ Framework.Command result = this.CommandManager.Get(arguments[0]);
+ if (result == null)
+ this.Monitor.Log("There's no command with that name.", LogLevel.Error);
+ else
+ this.Monitor.Log($"{result.Name}: {result.Documentation}\n(Added by {result.ModName}.)", LogLevel.Info);
+ }
+ else
+ {
+ this.Monitor.Log("The following commands are registered: " + string.Join(", ", this.CommandManager.GetAll().Select(p => p.Name)) + ".", LogLevel.Info);
+ this.Monitor.Log("For more information about a command, type 'help command_name'.", LogLevel.Info);
+ }
+ break;
+
+ case "reload_i18n":
+ this.ReloadTranslations();
+ this.Monitor.Log("Reloaded translation files for all mods. This only affects new translations the mods fetch; if they cached some text, it may not be updated.", LogLevel.Info);
+ break;
+
+ default:
+ throw new NotSupportedException($"Unrecognise core SMAPI command '{name}'.");
}
}