Skip to content

Commit 4078cfa

Browse files
committed
Updated install
1 parent e25e955 commit 4078cfa

File tree

2 files changed

+113
-47
lines changed

2 files changed

+113
-47
lines changed

src/Program.cs

Lines changed: 112 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,85 +5,124 @@
55
using System.Text.RegularExpressions;
66

77

8-
var version = Assembly.GetEntryAssembly()?
9-
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
10-
.InformationalVersion;
11-
12-
Console.WriteLine($"genocs v{version}");
13-
Console.WriteLine(Figgle.FiggleFonts.Doom.Render($"genocs v{version}"));
14-
ShowBot("Hello!!!");
15-
168
if (args.Length == 0)
179
{
18-
Console.WriteLine("Insufficient params.");
19-
Console.WriteLine("Use following syntax:\n");
20-
Console.WriteLine(" genocs [cleanarchitecture|microservice|blazor] [-n|--new] <CompanyName.ProjectName.ServiceName>");
21-
Console.WriteLine(" genocs [cleanarchitecture|microservice|blazor] [-n|--new] <ServiceName>");
10+
ShowBot("Hello!!!");
11+
Console.WriteLine("Missing params. Use following syntax:");
12+
WriteColorConsole(" genocs [-i|--install|-u|--update", ConsoleColor.Cyan);
13+
Console.WriteLine("Than follow with:");
14+
WriteColorConsole(" genocs [blazor|webapi|worker|cleanapi|angular|react] [n|new] <CompanyName.ProjectName.ServiceName>", ConsoleColor.Cyan);
15+
Console.WriteLine("or with:");
16+
WriteColorConsole(" genocs [blazor|webapi|worker|cleanapi|angular|react] [n|new] <ServiceName>", ConsoleColor.Cyan);
2217
Console.WriteLine("\nPlease refer to https://genocs-blog.netlify.app/");
2318
return;
2419
}
2520

21+
var version = Assembly.GetEntryAssembly()?
22+
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
23+
.InformationalVersion;
24+
25+
WriteColorConsole(Figgle.FiggleFonts.Doom.Render($"genocs v{version}"), ConsoleColor.DarkGreen);
26+
27+
2628
string firstArg = args[0].Trim().ToLower();
2729
if (firstArg == "--install" || firstArg == "-i" || firstArg == "--update" || firstArg == "-u")
2830
{
2931
await InstallTemplates();
3032
return;
3133
}
3234

33-
if (firstArg == "cleanarchitecture")
35+
if (firstArg == "angular")
3436
{
3537
if (args.Length != 3)
3638
{
37-
Console.WriteLine("Invalid command. Use something like: genocs cleanarchitecture new <CompanyName.ProjectName>");
39+
Console.WriteLine("Invalid command. Use something like: genocs angular new <CompanyName.ProjectName>");
3840
return;
3941
}
4042

4143
string command = args[1].Trim().ToLower();
4244
// Convert to Capital case
4345
string projectName = args[2].Trim();
44-
if (command == "-n" || command == "--new")
46+
if (command == "n" || command == "new")
4547
{
46-
await BootstrapCleanArchitectureSolution(projectName);
48+
await BootstrapAngularSolution(projectName);
4749
}
4850

4951
return;
5052
}
5153

52-
if (firstArg == "microservice")
54+
if (firstArg == "blazor")
5355
{
5456
if (args.Length != 3)
5557
{
56-
Console.WriteLine("Invalid command. Use something like: genocs microservice new <CompanyName.ProjectName>");
58+
Console.WriteLine("Invalid command. Use something like: genocs blazor new <CompanyName.ProjectName>");
5759
return;
5860
}
5961

6062
string command = args[1].Trim().ToLower();
6163
// Convert to Capital case
6264
string projectName = args[2].Trim();
63-
if (command == "-n" || command == "--new")
65+
if (command == "n" || command == "new")
6466
{
65-
await BootstrapMicroserviceSolution(projectName);
67+
await BootstrapBlazorSolution(projectName);
6668
}
6769

6870
return;
6971
}
7072

73+
if (firstArg == "worker")
74+
{
75+
if (args.Length != 3)
76+
{
77+
Console.WriteLine("Invalid command. Use something like: genocs worker new <CompanyName.ProjectName>");
78+
return;
79+
}
80+
81+
string command = args[1].Trim().ToLower();
82+
// Convert to Capital case
83+
string projectName = args[2].Trim();
84+
if (command == "n" || command == "new")
85+
{
86+
await BootstrapBlazorSolution(projectName);
87+
}
7188

72-
if (firstArg == "blazor")
89+
return;
90+
}
91+
92+
if (firstArg == "webapi")
7393
{
7494
if (args.Length != 3)
7595
{
76-
Console.WriteLine("Invalid command. Use something like: genocs blazor new <CompanyName.ProjectName>");
96+
Console.WriteLine("Invalid command. Use something like: genocs webapi new <CompanyName.ProjectName>");
97+
return;
98+
}
99+
100+
string command = args[1].Trim().ToLower();
101+
// Convert to Capital case
102+
string projectName = args[2].Trim();
103+
if (command == "n" || command == "new")
104+
{
105+
await BootstrapMicroserviceSolution(projectName);
106+
}
107+
108+
return;
109+
}
110+
111+
if (firstArg == "cleanapi")
112+
{
113+
if (args.Length != 3)
114+
{
115+
Console.WriteLine("Invalid command. Use something like: genocs cleanapi new <CompanyName.ProjectName>");
77116
return;
78117
}
79118

80119
string command = args[1].Trim().ToLower();
81120
// Convert to Capital case
82121
// Convert to Capital case
83122
string projectName = args[2].Trim();
84-
if (command == "-n" || command == "--new")
123+
if (command == "n" || command == "new")
85124
{
86-
await BootstrapBlazorWasmSolution(projectName);
125+
await BootstrapCleanArchitectureSolution(projectName);
87126
}
88127

89128
return;
@@ -132,7 +171,7 @@ ............... .'..............
132171
......... ..............
133172
.....
134173
";
135-
Console.WriteLine(bot);
174+
WriteColorConsole(bot, ConsoleColor.Blue);
136175
}
137176

138177
static void WriteColor(string message, ConsoleColor color)
@@ -193,44 +232,65 @@ async Task InstallTemplates()
193232
// --------------------------
194233

195234
WriteSuccessMessage("Installed the required templates.");
196-
Console.WriteLine("Get started by using : genocs <type> new <CompanyName.ProjectName>.");
197-
Console.WriteLine("NOTE: <type> can be [cleanarchitecture | microservice | blazor].");
198-
Console.WriteLine("Refer to documentation at https://genocs-blog.netlify.app/");
235+
WriteSuccessMessage("Type: dotnet new list to see the whole set of dotnet templates.");
236+
237+
Console.WriteLine("Get started by typing:");
238+
WriteColorConsole(" genocs [blazor|webapi|worker|cleanapi|angular|react] [n|new] <CompanyName.ProjectName.ServiceName>", ConsoleColor.Cyan);
239+
Console.WriteLine("or with:");
240+
WriteColorConsole(" genocs [blazor|webapi|worker|cleanapi|angular|react] [n|new] <ServiceName>", ConsoleColor.Cyan);
241+
Console.WriteLine("\nPlease refer to https://genocs-blog.netlify.app/");
199242
}
200243

244+
async Task BootstrapAngularSolution(string projectName)
245+
{
246+
Console.WriteLine($"Angular Template not available ...");
247+
await Task.CompletedTask;
248+
}
249+
250+
async Task BootstrapReactSolution(string projectName)
251+
{
252+
Console.WriteLine($"React Template not available ...");
253+
await Task.CompletedTask;
254+
}
255+
256+
async Task BootstrapWorkerSolution(string projectName)
257+
{
258+
Console.WriteLine($"Worker Template not available ...");
259+
await Task.CompletedTask;
260+
}
261+
262+
201263
async Task BootstrapCleanArchitectureSolution(string projectName)
202264
{
203-
Console.WriteLine($"Bootstrapping genocs Clean Architecture project at \"./{projectName}\"...");
265+
Console.WriteLine($"Bootstrapping genocs Clean Architecture project at '{projectName}' ...");
204266
var psi = new ProcessStartInfo
205267
{
206268
FileName = "dotnet",
207269
Arguments = $"new cleanarchitecture -n {projectName} -o {projectName} -v=q"
208270
};
209271
using var proc = Process.Start(psi)!;
210272
await proc.WaitForExitAsync();
211-
WriteSuccessMessage($"Genocs Architecture solution {projectName} successfully created.");
212-
WriteSuccessMessage("Application ready! Build something amazing!");
273+
WriteSuccessMessage($"Genocs Clean Architecture solution '{projectName}' successfully created.");
213274
Console.WriteLine("Refer to documentation at https://genocs-blog.netlify.app/");
214275
}
215276

216277
async Task BootstrapMicroserviceSolution(string projectName)
217278
{
218-
Console.WriteLine($"Bootstrapping genocs Microservice project at \"./{projectName}\"...");
279+
Console.WriteLine($"Bootstrapping genocs Microservice project at '{projectName}' ...");
219280
var psi = new ProcessStartInfo
220281
{
221282
FileName = "dotnet",
222283
Arguments = $"new microservice -n {projectName} -o {projectName} -v=q"
223284
};
224285
using var proc = Process.Start(psi)!;
225286
await proc.WaitForExitAsync();
226-
WriteSuccessMessage($"Genocs Microservice solution {projectName} successfully created.");
227-
WriteSuccessMessage("Application ready! Build something amazing!");
287+
WriteSuccessMessage($"Genocs Microservice solution '{projectName}' successfully created.");
228288
Console.WriteLine("Refer to documentation at https://genocs-blog.netlify.app/");
229289
}
230290

231-
async Task BootstrapBlazorWasmSolution(string projectName)
291+
async Task BootstrapBlazorSolution(string projectName)
232292
{
233-
Console.WriteLine($"Bootstrapping genocs Blazor wasm solution at \"./{projectName}\"...");
293+
Console.WriteLine($"Bootstrapping genocs Blazor WebAssembly solution at '{projectName}' ...");
234294
var psi = new ProcessStartInfo
235295
{
236296
FileName = "dotnet",
@@ -239,18 +299,22 @@ async Task BootstrapBlazorWasmSolution(string projectName)
239299

240300
using var proc = Process.Start(psi)!;
241301
await proc.WaitForExitAsync();
242-
WriteSuccessMessage($"Genocs blazor solution {projectName} successfully created.");
243-
WriteSuccessMessage("Application ready! Build something amazing!");
302+
WriteSuccessMessage($"Genocs blazor solution '{projectName}' successfully created.");
244303
Console.WriteLine("Refer to documentation at https://genocs-blog.netlify.app/");
245304
}
246305

247-
static void WriteSuccessMessage(string message)
306+
static void WriteColorConsole(string message, ConsoleColor color)
248307
{
249-
Console.ForegroundColor = ConsoleColor.Green;
308+
Console.ForegroundColor = color;
250309
Console.WriteLine(message);
251310
Console.ResetColor();
252311
}
253312

313+
static void WriteSuccessMessage(string message)
314+
{
315+
WriteColorConsole(message, ConsoleColor.Green);
316+
}
317+
254318
static void WriteColorEx(string str, params (string substring, ConsoleColor color)[] colors)
255319
{
256320
var words = Regex.Split(str, @"( )");
@@ -271,9 +335,11 @@ static void WriteColorEx(string str, params (string substring, ConsoleColor colo
271335
}
272336
}
273337

274-
Console.WriteLine("\nUsage:");
275-
Console.WriteLine(" genocs <params>");
276-
277-
// WriteColorEx("This is my message with new color with red", ("{message}", ConsoleColor.Red), ("{with}", ConsoleColor.Blue));
278-
279-
Console.WriteLine("\n");
338+
Console.WriteLine("Invalid params. Use following syntax:");
339+
WriteColorConsole(" genocs [-i|--install|-u|--update", ConsoleColor.Cyan);
340+
Console.WriteLine("Than follow with:");
341+
WriteColorConsole(" genocs [blazor|webapi|worker|cleanapi|angular|react] [n|new] <CompanyName.ProjectName.ServiceName>", ConsoleColor.Cyan);
342+
Console.WriteLine("or with:");
343+
WriteColorConsole(" genocs [blazor|webapi|worker|cleanapi|angular|react] [n|new] <ServiceName>", ConsoleColor.Cyan);
344+
Console.WriteLine("\nPlease refer to https://genocs-blog.netlify.app/");
345+
// WriteColorEx("This is my message with new color with red", ("{message}", ConsoleColor.Red), ("{with}", ConsoleColor.Blue));

src/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"genocs.cli": {
44
"commandName": "Project",
5-
"commandLineArgs": "i"
5+
"commandLineArgs": "-u"
66
}
77
}
88
}

0 commit comments

Comments
 (0)