示例#1
0
        public static void Configure(CommandLineApplication app)
        {
            app.Name = "dbtool";
            app.HelpOption("-?|-h|--help");

            var options = new GlobalOptions();

            options.LocalConfigFilePathOption =
                app.Option("--config|-c",
                           "Config file path",
                           CommandOptionType.SingleValue)
                .Accepts(configure => configure.ExistingFile("Configuration file does not exist"));

            options.FormatOption = app.Option("--format|-f",
                                              "Exporting/importing format (xml | json)",
                                              CommandOptionType.SingleValue)
                                   .Accepts(config => config.Values(true, "xml", "json"));


            // Internal commands
            app.Command("actualize", c => ActualizeCommand.Configure(c, options));

            // Register commands
            app.Command("export", c => ExportCommand.Configure(c, options));
            app.Command("import", c => ImportCommand.Configure(c, options));
            app.Command("connections", c => ConnectionsCommand.Configure(c, options));
            app.Command("filter-tables", c => FilterTablesCommand.Configure(c, options));

            Func <int> runCommandFunc = new RootCommand(app, options).Run;

            app.OnExecute(runCommandFunc);
        }
示例#2
0
        public static void Configure(CommandLineApplication command, GlobalOptions options)
        {
            command.Description = "This command can help you to actualize date/time values in some DB. " +
                                  "It's very usuful when you need to update some testing/demo database and make all dates in it actual (meainig: within this year or close)";
            command.HelpOption("-?|-h|--help");

            // add local config option
            command.Options.Add(options.LocalConfigFilePathOption);

            var connectionIdArg = command.Argument("<connection ID>", "The ID of some previously registered connection")
                                  .IsRequired();

            var columnDateArg = command.Argument("<column>", "The full name of some date/time column to get the DELTA for all other date/time values in this DB. "
                                                 + "The DELTA is calculated as CurrentYear - MAX(<column>).Year. For example: Order.OrderDate")
                                .IsRequired();

            Func <int> runCommandFunc = new ActualizeCommand(connectionIdArg, columnDateArg, options).Run;

            command.OnExecute(runCommandFunc);
        }