0 Comments

Alias engine is a new MIT-licensed open source C# & .NET Standard based engine for creating aliases for your commands. It's inspired by the alias support which mIRC provides.

Example: Alias “ae” can be used to execute command “Alias Engine”.

The project can be found from GitHub and the engine is available through Nuget https://www.nuget.org/packages/AliasEngine/.

Background

What is an alias and what you can do with them? Aliases can be used to shorten commands. If your application provides a “help” command, you can provide a shorter alias “h” for running it.

Alias Engine can also be used to provide alias feature for the end user. Your application can provide a fixed set of commands like “help”, “show”, “create” and the user of your application can create aliases for executing the commands.

Features

Alias Engine supports these features:

  • Multi-Command aliases
  • Multi-Parameter aliases
  • Multi-Word parameters

Here’s a quick example of using the engine:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var converter =new AliasConverter(new InMemoryAliasStore(),new NullLogger<AliasConverter>());
converter.AddAlias("/x multiple return words");
converter.AddAlias("/j /join {0}");
...
[Test]
[TestCase("/x", ExpectedResult ="multiple return words")]
public string CanRunAlias(string alias)
{
var result = converter.Convert(alias);
return result[0];
}
...
[Test]
[TestCase("/j hello", ExpectedResult ="/join hello")]
public string CanRunAliasWithParameters(string alias)
{
var result = _converter.Convert(alias);
return result[0];
}

For more examples, the best place is to check Alias Engine tests: https://github.com/mikoskinen/AliasEngine/blob/master/src/AliasEngine.Tests/AliasEngineTests.cs