-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommandSelector.cs
51 lines (45 loc) · 1.73 KB
/
CommandSelector.cs
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
namespace MyCliApp;
public class CommandSelector
{
private static Dictionary<string, Action<string>> commandTypes =
new Dictionary<string,Action<string>>(StringComparer.OrdinalIgnoreCase)
{
{ "template", GenrateTemplate.AddTemplate },
{ "t", GenrateTemplate.AddTemplate },
{ "all", GenrateCommand.GenerateAllStructure },
{ "class", GenrateCommand.GenerateClass },
{ "c", GenrateCommand.GenerateClass },
{ "rclass", GenrateCommand.GenerateRepositoryClass },
{ "rc", GenrateCommand.GenerateRepositoryClass },
{ "sclass", GenrateCommand.GenerateServiceClass },
{ "sc", GenrateCommand.GenerateServiceClass },
{ "efclass", GenrateCommand.GenerateEFClass },
{ "efc", GenrateCommand.GenerateEFClass },
{ "interface", GenrateCommand.GenerateInterface },
{ "i", GenrateCommand.GenerateInterface },
{ "rinterface", GenrateCommand.GenerateRepositoryInterface },
{ "ri", GenrateCommand.GenerateRepositoryInterface },
{ "sinterface", GenrateCommand.GenerateServiceInterface },
{ "si", GenrateCommand.GenerateServiceInterface },
{ "controller", GenrateCommand.GenerateController },
{ "co", GenrateCommand.GenerateController }
};
internal static void SelectType(string type, string name)
{
if (type == null)
{
Console.WriteLine("Provide type class or interface or template");
return;
}
if (commandTypes.TryGetValue(type, out var selectedType))
{
selectedType.Invoke(name);
}
else
{
Console.WriteLine($"Invalid type: {type}");
}
}
}