private static OptionSet Initialize(DbDeployConfig config, ConfigFileInfo configFile)
{
var options = new OptionSet();
options
.Add(
"d|dbms=",
"DBMS type ('mssql', 'mysql' or 'ora')",
s => config.Dbms = s)
.Add(
"c|connectionstring=",
"connection string for database",
s => config.ConnectionString = StripQuotes(s))
.Add(
"s|scriptdirectory=",
"directory containing change scripts (default: .)",
s => config.ScriptDirectory = new DirectoryInfo(StripQuotes(s)))
.Add(
"o|outputfile=",
"output file",
s => config.OutputFile = new FileInfo(StripQuotes(s)))
.Add(
"t|changelogtablename=",
"name of change log table to use (default: ChangeLog)",
s => config.ChangeLogTableName = StripQuotes(s))
.Add(
"a|autocreatechangelogtable=",
"automatically creates the change log table if it does not exist (true or false). Defaults to true.",
s => config.AutoCreateChangeLogTable = s.ToLowerInvariant() != "false")
.Add(
"f|forceupdate=",
"forces previously failed scripts to be run again (true or false). Defaults to false.",
s => config.ForceUpdate = s.ToLowerInvariant() == "true")
.Add(
"u|usesqlcmd=",
"runs scripts in SQLCMD mode (true or false). Defaults to false.",
s => config.UseSqlCmd = s.ToLowerInvariant() == "true")
.Add(
"l|lastchangetoapply=",
"sets the last change to apply in the form of folder/scriptnumber (v1.0.0/4).",
s => config.LastChangeToApply = !string.IsNullOrWhiteSpace(s) ? new UniqueChange(s) : null)
.Add(
"e|encoding=",
"encoding for input and output files (default: UTF-8)",
s => config.Encoding = new OutputFileEncoding(StripQuotes(s)).AsEncoding())
.Add(
"templatedirectory=",
"template directory",
s => config.TemplateDirectory = new DirectoryInfo(StripQuotes(s)))
.Add(
"delimiter=",
"delimiter to separate sql statements",
s => config.Delimiter = s)
.Add(
"delimitertype=",
"delimiter type to separate sql statements (row or normal)",
s => config.DelimiterType = Parser.ParseDelimiterType(s))
.Add(
"lineending=",
"line ending to use when applying scripts direct to db (platform, cr, crlf, lf)",
s => config.LineEnding = Parser.ParseLineEnding(s))
.Add(
"config=",
"configuration file to use for all settings.",
s => configFile.FileInfo = !string.IsNullOrWhiteSpace(s) ? new FileInfo(StripQuotes(s)) : null);
return options;
}