From bc891edb18e6a059207bd4d3a1b32446e31b7058 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Thu, 16 May 2019 14:29:58 +0300 Subject: [PATCH] refactor --- .../Volo/Abp/Cli/Commands/AddModuleCommand.cs | 11 ++++++++--- .../DbContextFileBuilderConfigureAdder.cs | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs index f48e2f4542..7925b82aa6 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs @@ -31,7 +31,7 @@ namespace Volo.Abp.Cli.Commands } var skipDbMigrations = Convert.ToBoolean( - commandLineArgs.Options.GetOrNull(Options.Solution.SkipDbMigrations) ?? "false"); + commandLineArgs.Options.GetOrNull(Options.DbMigrations.Skip) ?? "false"); await SolutionModuleAdder.AddAsync( GetSolutionFile(commandLineArgs), @@ -93,11 +93,12 @@ namespace Volo.Abp.Cli.Commands sb.AppendLine(""); sb.AppendLine("Options:"); sb.AppendLine(" -s|--solution Specify the solution file explicitly."); + sb.AppendLine(" --skip-db-migrations Specify if a new migration will be added or not."); sb.AppendLine(""); sb.AppendLine("Examples:"); sb.AppendLine(" abp add-module Volo.Blogging Adds the module to the current soluton."); sb.AppendLine(" abp add-module Volo.Blogging -s Acme.BookStore Adds the module to the given soluton."); - sb.AppendLine(" abp add-module Volo.Blogging -s Acme.BookStore --SkipDbMigrations false Adds the module to the given soluton but doesn't add-migration."); + sb.AppendLine(" abp add-module Volo.Blogging -s Acme.BookStore --skip-db-migrations false Adds the module to the given soluton but doesn't add-migration."); sb.AppendLine(""); return sb.ToString(); @@ -109,7 +110,11 @@ namespace Volo.Abp.Cli.Commands { public const string Short = "s"; public const string Long = "solution"; - public const string SkipDbMigrations = "skip-db-migrations"; + } + + public static class DbMigrations + { + public const string Skip = "skip-db-migrations"; } } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DbContextFileBuilderConfigureAdder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DbContextFileBuilderConfigureAdder.cs index 078a8db9b7..0211a42243 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DbContextFileBuilderConfigureAdder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DbContextFileBuilderConfigureAdder.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.Linq; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.DependencyInjection; @@ -9,9 +8,10 @@ namespace Volo.Abp.Cli.ProjectModification { public class DbContextFileBuilderConfigureAdder : ITransientDependency { - protected UsingStatementAdder UsingStatementAdder { get; } public ILogger Logger { get; set; } + protected UsingStatementAdder UsingStatementAdder { get; } + public DbContextFileBuilderConfigureAdder(UsingStatementAdder usingStatementAdder) { UsingStatementAdder = usingStatementAdder; @@ -73,12 +73,12 @@ namespace Volo.Abp.Cli.ProjectModification protected string GetLineToAdd(string moduleConfiguration) { - return "builder." + moduleConfiguration.Split('.').Last() + "();"; + return "builder." + moduleConfiguration.Split(':')[1] + "();"; } protected string GetNamespace(string moduleConfiguration) { - return string.Join(".", moduleConfiguration.Split('.').Reverse().Skip(2).Reverse()); + return string.Join(".", moduleConfiguration.Split(':')[0]); } } }