Skip to content

Commit

Permalink
fixing needed interface methods
Browse files Browse the repository at this point in the history
  • Loading branch information
AC-4 committed May 17, 2024
1 parent 07f116a commit 997bc7f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 12 deletions.
24 changes: 24 additions & 0 deletions src/Xcaciv.Command.Interface/ICommandController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,32 @@ namespace Xcaciv.Command.Interface
{
public interface ICommandController
{
/// <summary>
/// enable compiled-in commands
/// </summary>
void EnableDefaultCommands();
/// <summary>
/// add a directory from which to load commands
/// </summary>
/// <param name="directory"></param>
void AddPackageDirectory(string directory);
/// <summary>
/// load commands from the pacakge driectory with a sub directory filter
/// </summary>
/// <param name="subDirectory"></param>
void LoadCommands(string subDirectory = "bin");
/// <summary>
/// run a command using the loaded command pacakges
/// </summary>
/// <param name="commandLine"></param>
/// <param name="output"></param>
/// <returns></returns>
Task Run(string commandLine, ITextIoContext output);
/// <summary>
/// get provided help string for a command or list all commands if the command is empty
/// </summary>
/// <param name="command"></param>
/// <param name="output"></param>
void GetHelp(string command, IOutputContext output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<IsPublishable>True</IsPublishable>
<AssemblyName>Xcaciv.Command.Interface</AssemblyName>
<RootNamespace>Xcaciv.Command.Interface</RootNamespace>
Expand Down
7 changes: 4 additions & 3 deletions src/Xcaciv.Command.Tests/CommandControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,19 @@ public async Task PipeCommandsTestAsync()
// by looking at the output of the second output line
Assert.Equal(":d2hhdC13aGF0:-:aXMtaXM=:-:dXAtdXA=:", textio.ToString());
}

#pragma warning disable CS8602 // Dereference of a possibly null reference.
[Fact()]
public void LoadDefaultCommandsTest()
{
var controller = new CommandController(new Crawler(), @"..\..\..\..\..\") as ICommandController;
controller.LoadDefaultCommands();
var controller = new CommandController(new Crawler(), @"..\..\..\..\..\") as Interface.ICommandController;
controller.EnableDefaultCommands();

var textio = new TestImpementations.TestTextIo();
controller.GetHelp(string.Empty, textio);

// Note: currently Loader is not unloading assemblies for performance reasons
Assert.Contains("REGIF", textio.ToString());
}
#pragma warning restore CS8602 // Dereference of a possibly null reference.
}
}
2 changes: 1 addition & 1 deletion src/Xcaciv.Command.Tests/Commands/RegifCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task HandleExecutionTestAsync()
{
var commands = new CommandController(new Crawler(), @"..\..\..\..\..\");
commands.AddPackageDirectory(commandPackageDir);
commands.LoadDefaultCommands();
commands.EnableDefaultCommands();
commands.LoadCommands(string.Empty);


Expand Down
2 changes: 1 addition & 1 deletion src/Xcaciv.Command.Tests/Commands/SayCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class SayCommandTests
public async Task HandleExecutionTest()
{
var commands = new CommandController(new Crawler(), "");
commands.LoadDefaultCommands();
commands.EnableDefaultCommands();

var textio = new TestImpementations.TestTextIo();
// simulate user input
Expand Down
5 changes: 3 additions & 2 deletions src/Xcaciv.Command/CommandController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Xcaciv.Command;
/// <summary>
/// Command Manager
/// </summary>
public class CommandController : ICommandController
public class CommandController : Interface.ICommandController
{
protected const string PIPELINE_CHAR = "|";
protected ICrawler Crawler;
Expand Down Expand Up @@ -91,7 +91,7 @@ public void LoadCommands(string subDirectory = "bin")
/// <summary>
/// load the built in commands
/// </summary>
public void LoadDefaultCommands()
public void EnableDefaultCommands()
{
// This is the package action
var key = "Default";
Expand Down Expand Up @@ -319,4 +319,5 @@ public void GetHelp(string command, IOutputContext context)
}
}
}

}
6 changes: 2 additions & 4 deletions src/Xcaciv.Command/Xcaciv.Command.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>1.3.6</Version>
<Version>1.3.7</Version>
<AssemblyName>Xcaciv.Command</AssemblyName>
<RootNamespace>Xcaciv.Command</RootNamespace>
<IsPublishable>True</IsPublishable>
Expand All @@ -27,9 +27,7 @@
<ProjectReference Include="..\Xcaciv.Command.FileLoader\Xcaciv.Command.FileLoader.csproj">
<IncludeAssets>Xcaciv.Command.FileLoader.dll</IncludeAssets>
</ProjectReference>
<ProjectReference Packge="True" Include="..\Xcaciv.Command.Interface\Xcaciv.Command.Interface.csproj">
<IncludeAssets>Xcaciv.Command.Interface.dll</IncludeAssets>
</ProjectReference>
<ProjectReference Include="..\Xcaciv.Command.Interface\Xcaciv.Command.Interface.csproj" />

</ItemGroup>

Expand Down

0 comments on commit 997bc7f

Please sign in to comment.