-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
58 lines (48 loc) · 1.85 KB
/
Program.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
52
53
54
55
56
57
58
using CliWrap;
using CliWrap.Buffered;
using GoBackendProjectStarter.Utils;
internal class Program
{
private static async Task Main()
{
bool done = false;
try
{
// get folder name
String? folderName = null;
{
InputValidation.GetUserInput(inputVar: ref folderName, message: "Please input a valid folder name for the project: ");
}
// get moduile name from user
String? moduleName = null;
{
InputValidation.GetUserInput(inputVar: ref moduleName, message: "Please input a valid module name: ");
}
// get directory from user
String? directory = null;
{
InputValidation.GetUserInput(inputVar: ref directory, message: "Please input the directory you want your project to be created: ");
}
if (string.IsNullOrWhiteSpace(directory) || string.IsNullOrWhiteSpace(moduleName) || string.IsNullOrWhiteSpace(folderName)) return;
Directory.SetCurrentDirectory(directory);
FileCreator fileCreator = new(workingDir: directory, moduleName: moduleName, projectFolderName: folderName);
Console.CancelKeyPress += (object? sender, ConsoleCancelEventArgs e) =>
{
if (!done)
{
var projectDir = Path.Combine(Directory.GetCurrentDirectory(), folderName);
if (Directory.Exists(projectDir))
{
Directory.Delete(projectDir, true);
}
}
};
done = await fileCreator.CreateProject();
Console.WriteLine("SUCCESSFULLY CREATED PROJECT");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}