Switched to dependency injection for console use.

Created interfaces for input and output for better structure and easier testing.
This commit is contained in:
2020-02-23 20:51:39 -05:00
parent 72a1ba903b
commit fa74bc9ae5
12 changed files with 119 additions and 105 deletions

View File

@@ -23,7 +23,7 @@ namespace RecrownedGTK.Tools.NinePatchTools
commandArguments[5] = new EngineCommandArgument("-b", "bottom patch.", true);
}
public override void Run(string[] arguments = null)
public override void Run(IUserInput userInput = null, IUserOutput userOutput = null, string[] arguments = null)
{
if (arguments == null) throw new ArgumentException("Missing arguments. Type \"help 9p\" for more information.");
int leftBound = 0, rightBound = 0, topBound = 0, bottomBound = 0;
@@ -51,8 +51,8 @@ namespace RecrownedGTK.Tools.NinePatchTools
File.Move(imagePath, modifiedPath);
File.WriteAllText(outPath + ".9p", serialized);
ConsoleUtilities.WriteWrappedLine("Done. Written to \"" + outPath + "\" with values: left = " + leftBound + " right = " + rightBound + " top = " + topBound + " bottom = " + bottomBound);
ConsoleUtilities.WriteWrappedLine("Image renamed to: " + Path.GetFileName(modifiedPath));
userOutput.WrappedOutput("Done. Written to \"" + outPath + "\" with values: left = " + leftBound + " right = " + rightBound + " top = " + topBound + " bottom = " + bottomBound);
userOutput.WrappedOutput("Image renamed to: " + Path.GetFileName(modifiedPath));
}
}
}