From f4ad9b9eab9086649a3b13503fab9182efa0f81f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 27 Aug 2020 16:22:23 +0300 Subject: [PATCH] Add prompt parameter to the GenerateProxyCommand --- .../Abp/Cli/Commands/GenerateProxyCommand.cs | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs index fa605bdce7..5e88417b4a 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs @@ -16,11 +16,31 @@ namespace Volo.Abp.Cli.Commands CheckAngularJsonFile(); CheckNgSchematics(); - var module = commandLineArgs.Options.GetOrNull(Options.Module.Short, Options.Module.Long) ?? "__default"; - var source = commandLineArgs.Options.GetOrNull(Options.Source.Short, Options.Source.Long) ?? "__default"; - var target = commandLineArgs.Options.GetOrNull(Options.Target.Short, Options.Target.Long) ?? "__default"; + var prompt = commandLineArgs.Options.ContainsKey("p") || commandLineArgs.Options.ContainsKey("prompt"); + var defaultValue = prompt ? null : "__default"; - CmdHelper.RunCmd($"npx ng g @abp/ng.schematics:proxy --module {module} --source {source} --target {target}"); + var module = commandLineArgs.Options.GetOrNull(Options.Module.Short, Options.Module.Long) ?? defaultValue; + var source = commandLineArgs.Options.GetOrNull(Options.Source.Short, Options.Source.Long) ?? defaultValue; + var target = commandLineArgs.Options.GetOrNull(Options.Target.Short, Options.Target.Long) ?? defaultValue; + + var commandBuilder = new StringBuilder("npx ng g @abp/ng.schematics:proxy"); + + if (module != null) + { + commandBuilder.Append($" --module {module}"); + } + + if (source != null) + { + commandBuilder.Append($" --source {source}"); + } + + if (target != null) + { + commandBuilder.Append($" --target {target}"); + } + + CmdHelper.RunCmd(commandBuilder.ToString()); return Task.CompletedTask; } @@ -73,9 +93,12 @@ namespace Volo.Abp.Cli.Commands sb.AppendLine(""); sb.AppendLine(" abp generate-proxy"); sb.AppendLine(""); - sb.AppendLine("Examples:"); + sb.AppendLine("Options:"); sb.AppendLine(""); - sb.AppendLine(" abp generate-proxy"); + sb.AppendLine("-m|--module (default: 'app') The name of the backend module you wish to generate proxies for."); + sb.AppendLine("-s|--source (default: 'defaultProject') Angular project name to resolve the root namespace & API definition URL from."); + sb.AppendLine("-t|--target (default: 'defaultProject') Angular project name to place generated code in."); + sb.AppendLine("-p|--prompt Asks the options from the command line prompt (for the missing options)"); sb.AppendLine(""); sb.AppendLine("See the documentation for more info: https://docs.abp.io/en/abp/latest/CLI"); @@ -106,6 +129,12 @@ namespace Volo.Abp.Cli.Commands public const string Short = "t"; public const string Long = "target"; } + + public static class Prompt + { + public const string Short = "p"; + public const string Long = "prompt"; + } } } }