Browse Source

CLI: Create a command to list open-source modules

resolves https://github.com/abpframework/abp/issues/3161
pull/7827/head
Yunus Emre Kalkan 6 years ago
parent
commit
fcd634caf9
  1. 21
      docs/en/CLI.md
  2. 1
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs
  3. 83
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ListModulesCommand.cs

21
docs/en/CLI.md

@ -31,6 +31,7 @@ Here, the list of all available commands before explaining their details:
* **`update`**: Automatically updates all ABP related NuGet and NPM packages in a solution.
* **`add-package`**: Adds an ABP package to a project.
* **`add-module`**: Adds a [multi-package application module](https://docs.abp.io/en/abp/latest/Modules/Index) to a solution.
* **`list-modules`**: Lists names of open-source application modules.
* **`get-source`**: Downloads the source code of a module.
* **`generate-proxy`**: Generates client side proxies to use HTTP API endpoints.
* **`remove-proxy`**: Removes previously generated client side proxies.
@ -202,6 +203,26 @@ abp add-module ProductManagement --new --add-to-solution-file
* `--with-source-code`: Downloads the source code of the module to your solution folder and uses local project references instead of NuGet/NPM packages. This options is always `True` if `--new` is used.
* `--add-to-solution-file`: Adds the downloaded/created module to your solution file, so you will also see the projects of the module when you open the solution on a IDE. (only available when `--with-source-code` is `True`.)
### list-modules
Lists names of open-source application modules.
Usage
````bash
abp list-modules [options]
````
Example:
```bash
abp list-modules
```
#### Options
* `--include-pro-modules`: Includes commercial (pro) modules in the output.
### get-source
Downloads the source code of a module to your computer.

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

@ -34,6 +34,7 @@ namespace Volo.Abp.Cli
options.Commands["update"] = typeof(UpdateCommand);
options.Commands["add-package"] = typeof(AddPackageCommand);
options.Commands["add-module"] = typeof(AddModuleCommand);
options.Commands["list-modules"] = typeof(ListModulesCommand);
options.Commands["login"] = typeof(LoginCommand);
options.Commands["logout"] = typeof(LogoutCommand);
options.Commands[GenerateProxyCommand.Name] = typeof(GenerateProxyCommand);

83
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ListModulesCommand.cs

@ -0,0 +1,83 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using System.Threading.Tasks;
using Volo.Abp.Cli.Args;
using Volo.Abp.Cli.ProjectBuilding;
using Volo.Abp.Cli.ProjectBuilding.Templates.MvcModule;
using Volo.Abp.Cli.ProjectModification;
using Volo.Abp.Cli.Utils;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Cli.Commands
{
public class ListModulesCommand : IConsoleCommand, ITransientDependency
{
public ModuleInfoProvider ModuleInfoProvider { get; }
public ILogger<ListModulesCommand> Logger { get; set; }
public ListModulesCommand(ModuleInfoProvider moduleInfoProvider)
{
ModuleInfoProvider = moduleInfoProvider;
Logger = NullLogger<ListModulesCommand>.Instance;
}
public async Task ExecuteAsync(CommandLineArgs commandLineArgs)
{
var modules = await ModuleInfoProvider.GetModuleListAsync();
var freeModules = modules.Where(m => !m.IsPro).ToList();
var proModules = modules.Where(m => m.IsPro).ToList();
var output = new StringBuilder(Environment.NewLine);
output.AppendLine("Open Source Application Modules");
output.AppendLine();
foreach (var module in freeModules)
{
output.AppendLine($"> {module.DisplayName.PadRight(50)} ({module.Name})");
}
if (commandLineArgs.Options.ContainsKey("include-pro-modules"))
{
output.AppendLine();
output.AppendLine("Commercial (Pro) Application Modules");
output.AppendLine();
foreach (var module in proModules)
{
output.AppendLine($"> {module.DisplayName.PadRight(50)} ({module.Name})");
}
}
Logger.LogInformation(output.ToString());
}
public string GetUsageInfo()
{
var sb = new StringBuilder();
sb.AppendLine("");
sb.AppendLine("'list-modules' command is used for listing open source application modules.");
sb.AppendLine("");
sb.AppendLine("Usage:");
sb.AppendLine(" abp list-modules");
sb.AppendLine(" abp list-modules --include-pro-modules");
sb.AppendLine("");
sb.AppendLine("Options:");
sb.AppendLine(" --include-pro-modules Includes commercial (pro) modules in the output.");
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 "List open source application modules";
}
}
}
Loading…
Cancel
Save