refactoring and added clear command.

This commit is contained in:
Harrison Deng 2018-12-09 14:27:31 -06:00
parent 8de9d86370
commit af7653dbdd
6 changed files with 44 additions and 6 deletions

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace RecrownedAthenaeum.Tools.CommandProcessor.Commands
{
internal class ClearConsoleCommand : EngineCommand
{
public ClearConsoleCommand() : base("clear")
{
}
public override string Help(string argument = null)
{
return "Clears the console.";
}
public override void Run(string[] arguments = null)
{
Console.Clear();
}
}
}

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace RecrownedAthenaeum.Tools.CommandProcessor
namespace RecrownedAthenaeum.Tools.CommandProcessor.Commands
{
internal class HelpCommand : EngineCommand
{

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace RecrownedAthenaeum.Tools.CommandProcessor
namespace RecrownedAthenaeum.Tools.CommandProcessor.Commands
{
internal class StopCommand : EngineCommand
{

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace RecrownedAthenaeum.Tools.CommandProcessor
namespace RecrownedAthenaeum.Tools.CommandProcessor.Commands
{
class TestCommand : EngineCommand
{

View File

@ -9,6 +9,10 @@
<RootNamespace>RecrownedAthenaeum.Tools</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>true</Optimize>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0005" />

View File

@ -1,4 +1,5 @@
using RecrownedAthenaeum.Tools.CommandProcessor;
using RecrownedAthenaeum.Tools.CommandProcessor.Commands;
using RecrownedAthenaeum.Tools.TextureAtlasTools;
using System;
using System.Reflection;
@ -18,14 +19,23 @@ namespace RecrownedAthenaeum.Tools
ce.commands.Add(new TexturePackerCommand());
ce.commands.Add(new StopCommand(ce));
ce.commands.Add(new TestCommand());
ce.commands.Add(new ClearConsoleCommand());
if (args != null)
if (args.Length > 0)
{
ConsoleUtilities.WriteWrappedLine("Executing as one time use.");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < args.Length; i++) sb.Append(args[i] + ' ');
ce.Process(sb.ToString().Trim());
} else
try
{
ce.Process(sb.ToString().Trim());
}
catch (ArgumentException e)
{
ConsoleUtilities.WriteWrappedLine("An error has occurred: " + e.Message);
}
}
else
{
ce.Run();
}