Author: reinhard Date: Fri Nov 12 01:25:47 2004 New Revision: 57509 Added: cocoon/whiteboard/block-deployer/src/client/ cocoon/whiteboard/block-deployer/src/client/org/ cocoon/whiteboard/block-deployer/src/client/org/apache/ cocoon/whiteboard/block-deployer/src/client/org/apache/cocoon/ cocoon/whiteboard/block-deployer/src/client/org/apache/cocoon/blockdeployer/ cocoon/whiteboard/block-deployer/src/client/org/apache/cocoon/blockdeployer/cli/ cocoon/whiteboard/block-deployer/src/client/org/apache/cocoon/blockdeployer/cli/Launcher.java Log: Start with first client implementation (command-line)
Added: cocoon/whiteboard/block-deployer/src/client/org/apache/cocoon/blockdeployer/cli/Launcher.java ============================================================================== --- (empty file) +++ cocoon/whiteboard/block-deployer/src/client/org/apache/cocoon/blockdeployer/cli/Launcher.java Fri Nov 12 01:25:47 2004 @@ -0,0 +1,118 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.cocoon.blockdeployer.cli; + +import java.io.File; + +import org.apache.commons.cli.BasicParser; +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.HelpFormatter; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.Options; + +/** + * @since 0.1 + */ +public class Launcher { + + private static final String OPT_HELP = "help"; + private static final String OPT_FILE = "file"; + private static final String OPT_QUIET = "quiet"; + private static final String OPT_VERBOSE = "verbose"; + private static final String OPT_LOGFILE = "logfile"; + private static final String OPT_DEVMODE = "devmode"; + private static final String DEFAULT_DEPLOYMENT_DESCRIPTOR_FILE = "deploy.xml"; + + /** + * Run the Cocoon Block Deployer from command line. + * + * @param args + */ + public static void main(String[] args) { + // create the parser + CommandLineParser parser = new BasicParser(); + Options options = createOptions(); + CommandLine line = null; + boolean devmode = false; + + String configuration = null; + + try { + if(line.hasOption(OPT_QUIET) && line.hasOption(OPT_VERBOSE)) { + System.err.println("Output can't be extra quiet and verbose at the same time."); + printHelpAndExit(options); + } + // parse the command line arguments + line = parser.parse(options, args); + if(line.hasOption(OPT_HELP)) { + printHelpAndExit(options); + } + if(line.hasOption(OPT_DEVMODE)) { + devmode = true; + } + if(line.hasOption(OPT_FILE)) { + configuration = line.getOptionValue(OPT_FILE); + } else { + configuration = DEFAULT_DEPLOYMENT_DESCRIPTOR_FILE; + } + + } catch (org.apache.commons.cli.ParseException exp) { + System.err.println(exp.getMessage()); + printHelpAndExit(options); + } + + File basedir = new File(""); + + System.out.println("file configuring deployment: " + configuration); + + // parse deployment configuration and setup the configuration object + + // setup logging + + // call the deployment service, either full deploy (block is physically installed) + // or devDeploy (nothing is copied) + + } + + private static void printHelpAndExit(Options options) { + HelpFormatter formatter = new HelpFormatter(); + formatter.printHelp( "cbd", options ); + System.exit(0); + } + + public static Options createOptions() { + Option help = new Option(OPT_HELP, "print this message"); + Option file = OptionBuilder.withArgName(OPT_FILE) + .hasArg() + .withDescription("the COB deployment descriptor (default is \"deploy.xml\")") + .create(OPT_FILE); + Option quiet = new Option(OPT_QUIET, "be extra quiet"); + Option verbose = new Option(OPT_VERBOSE, "be extra verbose"); + + Option devmode = new Option(OPT_DEVMODE, "deploy block in development mode (block content is referenced)"); + + Options options = new Options(); + options.addOption(file); + options.addOption(help); + options.addOption(verbose); + options.addOption(quiet); + + return options; + } + +} \ No newline at end of file