internal static void ParseCommandLineArguments(CommandLineOptions options, CommandLineParser parser, ConnectionStringSettingsCollection connectionStrings, out string connectionString, out string[] excludedTables) { if (parser.Parameters.Length < 1 || // expect at least the target parser.UnhandledSwitches.Length > 0) { throw new InvalidCommandLineArgumentException("Invalid command line arguments. Specify the target." + Environment.NewLine + Environment.NewLine + GetUsageMessage(parser), InvalidArgumentsExitCode); } // connection string string target = parser.Parameters[0]; ConnectionStringSettings settings = connectionStrings[target]; if (settings == null) { throw new InvalidCommandLineArgumentException(string.Format(CultureInfo.CurrentCulture, "Missing target: '{0}'. Could not find entry in the configuration file.", target), InvalidTargetExitCode); } connectionString = settings.ConnectionString; if (connectionString == null) { throw new InvalidCommandLineArgumentException(string.Format(CultureInfo.CurrentCulture, "Empty target: '{0}'. The entry in the configuration file is empty.", target), InvalidTargetExitCode); } // additional parameters excludedTables = (options.Exclude ?? string.Empty).Split(','); }
private static bool DisplayHelp(string commandLine, out CommandLineOptions options, out CommandLineParser parser) { options = new CommandLineOptions(); parser = new CommandLineParser(commandLine, options); parser.Parse(); return options.Help; }
internal static void ParseCommandLineArguments(CommandLineOptions options, CommandLineParser parser, ConnectionStringSettingsCollection connectionStrings, out string connectionString, out string migrationNamespace, out string moduleName, out string versioningTableName, out string versioningTableSchema, out string[] includedSchemas, out string[] excludedTables, out bool includeData) { if (parser.Parameters.Length < 1 || // expect at least the target parser.UnhandledSwitches.Length > 0) { throw new InvalidCommandLineArgumentException("Invalid command line arguments. Specify the target." + Environment.NewLine + Environment.NewLine + GetUsageMessage(parser), InvalidArgumentsExitCode); } // connection string string target = parser.Parameters[0]; ConnectionStringSettings settings = connectionStrings[target]; if (settings == null) { throw new InvalidCommandLineArgumentException(string.Format(CultureInfo.CurrentCulture, "Missing target: '{0}'. Could not find entry in the configuration file.", target), InvalidTargetExitCode); } connectionString = settings.ConnectionString; if (connectionString == null) { throw new InvalidCommandLineArgumentException(string.Format(CultureInfo.CurrentCulture, "Empty target: '{0}'. The entry in the configuration file is empty.", target), InvalidTargetExitCode); } // additional parameters migrationNamespace = options.Namespace; moduleName = options.ModuleName; versioningTableName = options.VersioningTableName; versioningTableSchema = options.VersioningTableSchema; includedSchemas = (options.Schemas ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); excludedTables = (options.Exclude ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); includeData = options.IncludeData; }