public static void Main(string[] args) { Mode mode = Mode.Create; string packagePath = null; args = CommandLine.ExpandFiles(args); // Figure the mode. foreach (string arg in args) { if (arg.StartsWith("-install:")) { mode = Mode.Install; packagePath = arg.Substring(9); break; } else if (arg.StartsWith("-create")) { mode = Mode.Create; break; } } switch (mode) { case Mode.Create: Create(args); break; case Mode.Install: Install(args, packagePath); break; default: UsageForm.Display(); break; } }
/// <summary> /// Implemnts -create mode. /// </summary> /// <param name="args">The command line arguments.</param> private static void Create(string[] args) { DBPackageBuilder builder; string setupPath = null; string welcomePath = null; string upgradePath = null; string schemaPath = null; string funcsPath = null; string procsPath = null; string outPath = null; foreach (string arg in args) { if (arg.StartsWith("-setup:")) { setupPath = arg.Substring(7); } else if (arg.StartsWith("-welcome:")) { welcomePath = arg.Substring(9); } else if (arg.StartsWith("-upgrade:")) { upgradePath = arg.Substring(9); } else if (arg.StartsWith("-schema:")) { schemaPath = arg.Substring(8); } else if (arg.StartsWith("-funcs:")) { funcsPath = arg.Substring(7); } else if (arg.StartsWith("-procs:")) { procsPath = arg.Substring(7); } else if (arg.StartsWith("-out:")) { outPath = arg.Substring(5); } } if (setupPath == null || schemaPath == null || outPath == null) { UsageForm.Display(); return; } try { builder = new DBPackageBuilder(setupPath); if (welcomePath != null) { builder.AddWelcomeRtf(welcomePath); } foreach (string file in GetFiles(schemaPath, "*.def")) { builder.AddSchemaScript(file); } foreach (string file in GetFiles(schemaPath, "*.sql")) { builder.AddSchemaScript(file); } foreach (string file in GetFiles(upgradePath, "*.sql")) { builder.AddUpgradeScript(file); } foreach (string file in GetFiles(funcsPath, "*.sql")) { builder.AddFuncScript(file); } foreach (string file in GetFiles(procsPath, "*.sql")) { builder.AddProcScript(file); } builder.CloseWrite(outPath); } catch (Exception e) { MessageBox.Show(e.Message, Program.Name, MessageBoxButtons.OK, MessageBoxIcon.Error); } }