more cli commands

This commit is contained in:
Matthew Parker [SSW]
2024-01-21 15:10:24 +10:00
parent 57ec0b85d7
commit 9c53d5d079
4 changed files with 38 additions and 9 deletions

View File

@@ -3,7 +3,7 @@ using Spectre.Console.Cli;
namespace DotNetSolutionTools.CLI.Commands;
public class UpdateProjectToNet80Command : Command<UpdateProjectToNet80Command.Settings>
public class UpdateProjectToNet80Command : AsyncCommand<UpdateProjectToNet80Command.Settings>
{
public sealed class Settings : CommandSettings
{
@@ -11,16 +11,15 @@ public class UpdateProjectToNet80Command : Command<UpdateProjectToNet80Command.S
public required string CsprojFilePath { get; set; }
}
public override int Execute(CommandContext context, Settings settings)
public override async Task<int> ExecuteAsync(CommandContext context, Settings settings)
{
// validate a real folder path was passed in
if (!Directory.Exists(settings.CsprojFilePath))
{
Console.WriteLine("Invalid folder path");
Console.WriteLine("Invalid file path. Please pass in a valid file path to a .csproj file.");
return 1;
}
Console.WriteLine("Deleting bin, obj, and node_modules folders");
CleanFolder.DeleteBinObjAndNodeModulesFoldersInFolder(settings.CsprojFilePath);
Console.WriteLine("Upgrading project to .NET 8.0");
await DotNetUpgrade.UpdateProjectAtPathToNet80(settings.CsprojFilePath);
Console.WriteLine("==================================================");
Console.WriteLine("Done!");