WMCommandFramework 0.1.9
dotnet add package WMCommandFramework --version 0.1.9
NuGet\Install-Package WMCommandFramework -Version 0.1.9
<PackageReference Include="WMCommandFramework" Version="0.1.9" />
<PackageVersion Include="WMCommandFramework" Version="0.1.9" />
<PackageReference Include="WMCommandFramework" />
paket add WMCommandFramework --version 0.1.9
#r "nuget: WMCommandFramework, 0.1.9"
#addin nuget:?package=WMCommandFramework&version=0.1.9
#tool nuget:?package=WMCommandFramework&version=0.1.9
This repository is deprecated and will be replaced.
WMCommandFramework will be split into two repositories.
- WMComamndFramework.COSMOS - For COSMOS-based projects.
- WMCommandFramework.NETStandard - For .NETStandard and WinForms applications.
This repository will be deleted as it serves an outdated and unstable version of CommandFramework. It will NOT be updated and it will NOT be managed. You have been warned. All versions in the repository are unstable and should not be used. Look for the above repos for stable repositories.
CommandFramework
CommandFramework is a simple command parser/invoker built in C# for the COSMOS operating system library. The library was built to work with COSMOS/.NET Core, however, you can use this library in any application even console applications.
Use with COSMOS
In the COSMOS kernel class implement the CommandProcessor class.
using System;
using Sys = Cosmos.System;
//Import the CommandFramework.
using WMCommandFramework;
public Kernel : Sys.Kernel
{
//Add the command processor class.
private static ComamndProcessor processor;
protected override void BeforeRun()
{
if (processor == null) processor = new CommandProcessor();
CommandUtils.CurrentToken = "CommandFramework"; //Adds the "CommandFramework" string in front of the command input.
CommandUtils.DebugMode = true; //Shows any errors that was produced by the *CommandFramework* if any.
//Register Commands Below.
processor.GetInvoker().AddCommand(new ExampleCommand()); //Registers the command created below.
}
protected override void Run()
{
//Don't need to add a while loop with COSMOS as the Run method loops.
processor.Process();
}
}
Once the CommandProcessor was implemented into the COSMOS Kernel you need to create the command. Create a new class that implements the abstract Command class.
using System;
using System.Collections.Generic;
using System.Text;
namespace Project.Commands
{
public class ExampleCommand : Command
{
public override string[] CommandAliases()
{
return new string[] { "print", "return" };
}
public override string CommandDesc()
{
return "Prints the specified information to the console.";
}
public override string CommandName()
{
return "example";
}
public override string CommandSynt()
{
return "<message>";
}
public override CommandVersion CommandVersion()
{
return new WMCommandFramework.CommandVersion(1,0,1,"b");
}
public override void OnCommandInvoked(CommandInvoker invoker, CommandArgs args)
{
if (args.IsEmpty()) throw new Exceptions.SyntaxException("The \"message\" argument cannot be null or empty.");
else
{
Console.WriteLine($"{args.GetArgAtPosition(0)}");
}
}
}
}
After the class containing the command was created and was implemented into the CommandInvoker class it should work in your OS. Just be sure to register your command with the command invoker if you haven't done so already, but if you followed this README then the command would have been registered before the command was created.
Use with non-COSMOS applications
Implememnt the CommandProcessor into your MAIN Program class.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
partial class Program
{
static void Main(string[] args)
{
new Program().Start();
}
//Add the CommandProcessor class.
private CommandProcessor processor;
//Add the Boolean that tells the Program to exit.
internal static bool canExit = false;
public Program()
{
if (processor == null) processor = new CommandProcessor();
CommandUtils.CurrentToken = "CommandFramework"; //Adds the "CommandFramework" string in front of the command input.
CommandUtils.DebugMode = true; //Shows any errors that was produced by the *CommandFramework* if any.
//Register Commands Below.
processor.GetInvoker().AddCommand(new ExampleCommand()); //Registers the command created below.
processor.GetInvoker().AddCommand(new ExitCommand()); //Registers the ExitCommand.
}
public void Start()
{
//In non-COSMOS applications that doesn't loop you need to add a while loop.
while (true)
{
if (canExit) break;
processor.Process();
}
}
}
Once the CommandProcessor was implemented into your MAIN Program class and registered in CommandProcessor you can create the command.}
using System;
using System.Collections.Generic;
using System.Text;
namespace Project.Commands
{
public class ExampleCommand : Command
{
public override string[] CommandAliases()
{
return new string[] { "print", "return" };
}
public override string CommandDesc()
{
return "Prints the specified information to the console.";
}
public override string CommandName()
{
return "example";
}
public override string CommandSynt()
{
return "<message>";
}
public override CommandVersion CommandVersion()
{
return new WMCommandFramework.CommandVersion(1,0,1,"b");
}
public override void OnCommandInvoked(CommandInvoker invoker, CommandArgs args)
{
if (args.IsEmpty()) throw new Exceptions.SyntaxException("The \"message\" argument cannot be null or empty.");
else
{
Console.WriteLine($"{args.GetArgAtPosition(0)}");
}
}
}
}
When implementing the CommandProcessor into your own application it's recommended you add a close command so you can freely close the application.
using System;
using System.Collections.Generic;
using System.Text;
namespace Project.Commands
{
public class ExitCommand : Command
{
public override string[] CommandAliases()
{
return new string[] { "close", "stop", "terminate", "quit", "escape", "end" };
}
public override string CommandDesc()
{
return "Closes the application.";
}
public override string CommandName()
{
return "exit";
}
public override string CommandSynt()
{
return "";
}
public override CommandVersion CommandVersion()
{
return new WMCommandFramework.CommandVersion(1,0,1,"b");
}
public override void OnCommandInvoked(CommandInvoker invoker, CommandArgs args)
{
CommandUtils.AllowExit = true;
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|