Browse Source

Merge pull request #11016 from abpframework/CleanCommand

Add `CleanCommand`.
pull/11052/head
Halil İbrahim Kalkan 4 years ago
committed by GitHub
parent
commit
db05c4a4a3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs
  2. 64
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CleanCommand.cs

1
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs

@ -63,6 +63,7 @@ public class AbpCliCoreModule : AbpModule
options.Commands[BundleCommand.Name] = typeof(BundleCommand);
options.Commands[CreateMigrationAndRunMigratorCommand.Name] = typeof(CreateMigrationAndRunMigratorCommand);
options.Commands[InstallLibsCommand.Name] = typeof(InstallLibsCommand);
options.Commands[CleanCommand.Name] = typeof(CleanCommand);
});
Configure<AbpCliServiceProxyOptions>(options =>

64
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CleanCommand.cs

@ -0,0 +1,64 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.Cli.Args;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Cli.Commands;
public class CleanCommand : IConsoleCommand, ITransientDependency
{
public const string Name = "clean";
public ILogger<CleanCommand> Logger { get; set; }
public CleanCommand()
{
Logger = NullLogger<CleanCommand>.Instance;
}
public Task ExecuteAsync(CommandLineArgs commandLineArgs)
{
var binEntries = Directory.EnumerateDirectories(Directory.GetCurrentDirectory(), "bin", SearchOption.AllDirectories);
var objEntries = Directory.EnumerateDirectories(Directory.GetCurrentDirectory(), "obj", SearchOption.AllDirectories);
foreach (var path in binEntries.Concat(objEntries))
{
if (path.IndexOf("node_modules", StringComparison.OrdinalIgnoreCase) > 0)
{
Logger.LogInformation($"Skipping: {path}");
}
else
{
Logger.LogInformation($"Deleting: {path}");
Directory.Delete(path, true);
}
}
Logger.LogInformation($"BIN and OBJ folders have been successfully deleted!");
return Task.CompletedTask;
}
public string GetUsageInfo()
{
var sb = new StringBuilder();
sb.AppendLine("");
sb.AppendLine("Usage:");
sb.AppendLine(" abp clean");
sb.AppendLine("");
sb.AppendLine("See the documentation for more info: https://docs.abp.io/en/abp/latest/CLI");
return sb.ToString();
}
public string GetShortDescription()
{
return "Delete all BIN and OBJ folders in current folder.";
}
}
Loading…
Cancel
Save