-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
70 lines (59 loc) · 2.59 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
59
60
61
62
63
64
65
66
67
68
69
70
using System.CommandLine;
using dotDevTool.src.Commands;
using dotDevTool.src.Models;
using dotDevTool.src.Models.types;
using dotDevTool.src.Services;
namespace DotDevTool
{
class Program
{
static async Task<int> Main(string[] args)
{
Console.WriteLine($"Directory: {Directory.GetCurrentDirectory()}");
ProjectConfig projectConfig = new ProjectConfig();
Database db;
var projectName = new Option<string?>(
name: "--name",
description: "Project name to be create."
);
var database = new Option<string?>(
name: "--database",
description: "Database to persist your project data."
);
var rootCommand = new RootCommand("Sample app for System.CommandLine");
rootCommand.AddOption(projectName);
rootCommand.AddOption(database);
rootCommand.SetHandler(async (name, database) =>
{
projectConfig.ProjectName = name ?? "MeuProjeto";
if (database == null)
{
projectConfig.Database = null;
}
else
{
if (Enum.TryParse<Database>(database, true, out db))
{
projectConfig.Database = db;
}
else { Console.WriteLine($"Banco de dados não encontrado, selecione uma opção valida"); }
}
Console.WriteLine($@"Start Creating a project:
Nome: {projectConfig.ProjectName}
Database: {projectConfig.Database}
");
ProjectCreator projectCreator = new ProjectCreator(projectConfig.ProjectName);
DependencyService dependencyService = new DependencyService(projectConfig.Database);
DockerService dockerService = new DockerService(projectConfig);
await projectCreator.createAsync();
await dependencyService.addPackagesAsync();
dependencyService.includeDbConnection();
dockerService.createDockerFile();
dockerService.createDockerCompose();
await projectCreator.runProject();
},
projectName, database);
return await rootCommand.InvokeAsync(args);
}
}
}