An open API service indexing awesome lists of open source software.

https://github.com/sh1kxrv/awwarecmds

.NET Framework library
https://github.com/sh1kxrv/awwarecmds

arguments command-line commands cshrap library netframework

Last synced: 3 months ago
JSON representation

.NET Framework library

Awesome Lists containing this project

README

        

# AwwareCmds
.NET Framework library to help implement command line with your commands
# Mini-Manual
With modules
```cs
var executer = new CommandService()
executer.AttachModulesFromFolder("UR FOLDER");
```
If your commands are in this assembly
```cs
var executer = new CommandService()
executer.AttachModule(Assembly.GetExecutingAssembly());
```

For more - see CmdTest and TestModule

How to add command?
```cs
public class TestCommand : AbstractCommand
{
public override string Name => "Test Command";

public override string InputCommand => "test";

public override string InputCommandAbbr => "t";

public override Task CommandExecute(object[] attributes, string[] subcmds)
{
TaskCompletionSource res = new TaskCompletionSource();
res.SetResult(CommandResult.Default);
return res.Task;
}

public override void CommandInitialization()
{

}
}
```

How to use subcommands?
```cs
public override Task CommandExecute(object[] attributes, string[] subcmds)
{
TaskCompletionSource res = new TaskCompletionSource();
res.SetResult(CommandResult.Default);
//Instead 'args.SubCmds[0]' you can use args.IsSubcmd(INDEX, "SUBCMD");
if(subcmds[0] == "test") // -> /CMD test
{
CommandService.Interactor.Info("It's 'test' subcommand");
if(subcmds[1] == "test2") // -> /CMD test test2
{
CommandService.Interactor.Info("It's 'test2' subcommand");
//etc.
}
}
else if(subcmds[1] == "test3") // -> /CMD test3
{
//Code
}
return res.Task;
}
```
How to use String arguments?
```cs
public override Task CommandExecute(object[] attributes, string[] subcmds)
{
TaskCompletionSource res = new TaskCompletionSource();
res.SetResult(CommandResult.Default);
if(subcmds[0] == "str") // -> /CMD str "My string"
{
CommandService.Interactor.Info($"Your string is '{attributes[0]}'");
}
return res.Task;
}
```

How to use NumberArguments?
```cs
public override Task CommandExecute(object[] attributes, string[] subcmds)
{
TaskCompletionSource res = new TaskCompletionSource();
res.SetResult(CommandResult.Default);
if(subcmds[0] == "numb") // -> /CMD numb 0.25 25
{
CommandService.Interactor.Info($"Your first number is '{(double)attributes[0]}', your second numb is '{(int)attributes[1]}'");
}
return res.Task;
}
```