Skip to content
Merged
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
15 changes: 7 additions & 8 deletions WillSoss.DbDeploy/Cli/CliCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.CommandLine;
using System.Xml.Linq;

namespace WillSoss.DbDeploy.Cli
{
Expand All @@ -16,7 +15,7 @@ internal static Command Drop(HostBuilderContext context, IServiceCollection serv

command.SetHandler((cs, name, @unsafe) => services.AddTransient<ICliCommand>(s => new DeployCommand(
s.GetRequiredService<DatabaseBuilder>(),
cs ?? GetConnectionString(context, name),
!string.IsNullOrWhiteSpace(cs) ? cs : GetConnectionString(context, name),
null,
true,
@unsafe,
Expand All @@ -39,7 +38,7 @@ internal static Command Create(HostBuilderContext context, IServiceCollection se

command.SetHandler((cs, name, drop, @unsafe) => services.AddTransient<ICliCommand>(s => new DeployCommand(
s.GetRequiredService<DatabaseBuilder>(),
cs ?? GetConnectionString(context, name),
!string.IsNullOrWhiteSpace(cs) ? cs : GetConnectionString(context, name),
null,
drop,
@unsafe,
Expand All @@ -64,7 +63,7 @@ internal static Command Migrate(HostBuilderContext context, IServiceCollection s

command.SetHandler((cs, name, version, applyMissing, pre, post) => services.AddTransient<ICliCommand>(s => new DeployCommand(
s.GetRequiredService<DatabaseBuilder>(),
cs ?? GetConnectionString(context, name),
!string.IsNullOrWhiteSpace(cs) ? cs : GetConnectionString(context, name),
version,
false,
false,
Expand All @@ -91,7 +90,7 @@ internal static Command Deploy(HostBuilderContext context, IServiceCollection se

command.SetHandler((cs, name, version, drop, @unsafe, applyMissing, pre, post) => services.AddTransient<ICliCommand>(s => new DeployCommand(
s.GetRequiredService<DatabaseBuilder>(),
cs ?? GetConnectionString(context, name),
!string.IsNullOrWhiteSpace(cs) ? cs : GetConnectionString(context, name),
version,
drop,
@unsafe,
Expand All @@ -111,7 +110,7 @@ internal static Command Status(HostBuilderContext context, IServiceCollection se

command.SetHandler((cs, name) => services.AddTransient<ICliCommand>(s => new StatusCommand(
s.GetRequiredService<DatabaseBuilder>(),
cs ?? GetConnectionString(context, name)
!string.IsNullOrWhiteSpace(cs) ? cs : GetConnectionString(context, name)
)), CliOptions.ConnectionString, CliOptions.ConnectionStringName);

return command;
Expand All @@ -130,7 +129,7 @@ internal static Command Run(HostBuilderContext context, IServiceCollection servi

command.SetHandler((cs, name, action) => services.AddTransient<ICliCommand>(s => new RunCommand(
s.GetRequiredService<DatabaseBuilder>(),
cs ?? GetConnectionString(context, name),
!string.IsNullOrWhiteSpace(cs) ? cs : GetConnectionString(context, name),
action
)), CliOptions.ConnectionString, CliOptions.ConnectionStringName, arg);

Expand All @@ -145,7 +144,7 @@ internal static Command Reset(HostBuilderContext context, IServiceCollection ser

command.SetHandler((cs, name, @unsafe) => services.AddTransient<ICliCommand>(s => new ResetCommand(
s.GetRequiredService<DatabaseBuilder>(),
cs ?? GetConnectionString(context, name),
!string.IsNullOrWhiteSpace(cs) ? cs : GetConnectionString(context, name),
@unsafe
)), CliOptions.ConnectionString, CliOptions.ConnectionStringName, CliOptions.Unsafe);

Expand Down
Loading