summaryrefslogtreecommitdiff
path: root/src/TrainerMod/Framework/Commands/World/SetTimeCommand.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-07-02 02:45:02 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-07-02 02:45:02 -0400
commit2ca49fba62f59135c2ed3ec7958cb78073ff486b (patch)
tree5b4e5251606622f615b105b683a2722f4e6b046c /src/TrainerMod/Framework/Commands/World/SetTimeCommand.cs
parentf9482906ae7ce4dfd41bb4236e094be5d4fa7689 (diff)
downloadSMAPI-2ca49fba62f59135c2ed3ec7958cb78073ff486b.tar.gz
SMAPI-2ca49fba62f59135c2ed3ec7958cb78073ff486b.tar.bz2
SMAPI-2ca49fba62f59135c2ed3ec7958cb78073ff486b.zip
encapsulate TrainerMod's argument parsing (#302)
Diffstat (limited to 'src/TrainerMod/Framework/Commands/World/SetTimeCommand.cs')
-rw-r--r--src/TrainerMod/Framework/Commands/World/SetTimeCommand.cs16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/TrainerMod/Framework/Commands/World/SetTimeCommand.cs b/src/TrainerMod/Framework/Commands/World/SetTimeCommand.cs
index 4ecff485..c827ea5e 100644
--- a/src/TrainerMod/Framework/Commands/World/SetTimeCommand.cs
+++ b/src/TrainerMod/Framework/Commands/World/SetTimeCommand.cs
@@ -18,24 +18,18 @@ namespace TrainerMod.Framework.Commands.World
/// <param name="monitor">Writes messages to the console and log file.</param>
/// <param name="command">The command name.</param>
/// <param name="args">The command arguments.</param>
- public override void Handle(IMonitor monitor, string command, string[] args)
+ public override void Handle(IMonitor monitor, string command, ArgumentParser args)
{
- // validate
+ // no-argument mode
if (!args.Any())
{
monitor.Log($"The current time is {Game1.timeOfDay}. Specify a value to change it.", LogLevel.Info);
return;
}
- if (!int.TryParse(args[0], out int time))
- {
- this.LogArgumentNotInt(monitor, command);
- return;
- }
- if (time > 2600 || time < 600)
- {
- this.LogUsageError(monitor, "That isn't a valid time.", command);
+
+ // parse arguments
+ if (!args.TryGetInt(0, "time", out int time, min: 600, max: 2600))
return;
- }
// handle
Game1.timeOfDay = time;