Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/en/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Here, is the list of all available commands before explaining their details:
* **`new-package`**: Generates a new package based on the given template.
* **`update`**: Automatically updates all ABP related NuGet and NPM packages in a solution.
* **`clean`**: Deletes all `BIN` and `OBJ` folders in the current folder.
* **`clean-logs`**: Delete all `*logs.txt` files in the current folder and its subfolders.
* **`add-package`**: Adds an ABP package to a project.
* **`add-package-ref`**: Adds package to given project.
* **`install-module`**: Adds a [multi-package application module](../modules/index.md) to a given module.
Expand Down Expand Up @@ -353,6 +354,15 @@ Usage:
````bash
abp clean
````
### clean-logs

Delete all `*logs.txt` files in the current folder and its subfolders.

Usage:

````bash
abp clean-logs
````


### add-package
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Text;
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Cli.Commands;
using Volo.Abp.Cli.Commands.Internal;
Expand Down Expand Up @@ -67,6 +67,7 @@ public override void ConfigureServices(ServiceConfigurationContext context)
options.Commands[CreateMigrationAndRunMigratorCommand.Name] = typeof(CreateMigrationAndRunMigratorCommand);
options.Commands[InstallLibsCommand.Name] = typeof(InstallLibsCommand);
options.Commands[CleanCommand.Name] = typeof(CleanCommand);
options.Commands[CleanLogsCommand.Name] = typeof(CleanLogsCommand);
options.Commands[CliCommand.Name] = typeof(CliCommand);
options.Commands[ClearDownloadCacheCommand.Name] = typeof(ClearDownloadCacheCommand);
options.Commands[RecreateInitialMigrationCommand.Name] = typeof(RecreateInitialMigrationCommand);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Volo.Abp.Cli.Args;
using Volo.Abp.DependencyInjection;

namespace Volo.Abp.Cli.Commands;

public class CleanLogsCommand : IConsoleCommand, ITransientDependency
{
public const string Name = "clean-logs";

public ILogger<CleanCommand> Logger { get; set; }

public CleanLogsCommand(ILogger<CleanCommand> logger)
{
Logger = logger;
}

public Task ExecuteAsync(CommandLineArgs commandLineArgs)
{
var logsEntries = Directory.EnumerateDirectories(Directory.GetCurrentDirectory(), "Logs", SearchOption.AllDirectories);

Logger.LogInformation($"Removing 'Logs' files...");
foreach (var path in logsEntries)
{
var files = Directory.GetFiles(path, "*logs.txt");

foreach (var file in files)
{
Logger.LogInformation($"Deleting: {file}");
File.Delete(file);
}
}
Logger.LogInformation("Logs cleaned successfully!");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger.LogInformation($"'Logs' files removed successfully!");
Logger.LogInformation("Logs cleaned successfully!");

It seems like a duplicate logging.

return Task.CompletedTask;
}

public string GetUsageInfo()
{
var sb = new StringBuilder();

sb.AppendLine("");
sb.AppendLine("Usage:");
sb.AppendLine(" abp clean-logs");
sb.AppendLine("");
sb.AppendLine("See the documentation for more info: https://abp.io/docs/latest/cli");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command should be documented as well.


return sb.ToString();
}

public static string GetShortDescription()
{
return "Delete all *logs.txt files in the current folder and its subfolders.";
}
}