Parses command-line and directs to sub-commands.

@param args Command-line input
@throws Exception
423480
public static void executeCommand(String[] args) throws Exception {
        String subCmd = (args.length > 0) ? args[0] : "";
        args = AdminToolUtils.copyArrayCutFirst(args);
        if(subCmd.equals("fetch-entries")) {
            SubCommandStreamFetchEntries.executeCommand(args);
        } else if(subCmd.equals("fetch-keys")) {
            SubCommandStreamFetchKeys.executeCommand(args);
        } else if(subCmd.equals("mirror")) {
            SubCommandStreamMirror.executeCommand(args);
        } else if(subCmd.equals("update-entries")) {
            SubCommandStreamUpdateEntries.executeCommand(args);
        } else {
            printHelp(System.out);
        }
    }
230128
private void doit(String[] args)
    {
        try
        {
            // load parameters from the commandline
            loadParameters(args);

            // Try to load the private key
            importKeyPair();
        }
        catch (Exception e)
        {
            System.out.println("Exception: " + e.getMessage());
            e.printStackTrace();
            
            System.exit(23);
        }
    }
931855
public static void main(String[] args) throws Exception {
    int exitCode =  new Submitter().run(args);
    System.exit(exitCode);
  }
50667
private void parseCommandLineArgs(String[] args) throws ConfigurationException {
        if (args == null || args.length == 0) {
            return;
        }
        logger.info("Parsing command line arguments");
        m_commandLineArgs = args;
        
        try {
            for (int inx = 0; inx < args.length; inx++) {
                String arg = args[inx];
                if (arg.equals("-?") || arg.equalsIgnoreCase("-h") || arg.equalsIgnoreCase("-help")) {
                    System.out.println("See documentation and doradus.yaml for help.");
                    System.exit(0);
                }
                Utils.require(arg.charAt(0) == '-', "Unrecognized argument: %s", arg);
                Utils.require(inx + 1 < args.length, "A value is expected after: %s", arg);
                String name = arg.substring(1);
                String value = args[++inx];
                setCommandLineParam(name, value);
            }
        } catch (Exception e) {
            logger.error("Failed to parse command line arguments", e);
            throw new ConfigurationException("Failed to parse command line arguments", e);
        }
    }
765648
public static void main(String args[]) throws Exception {
        LaunchAppropriateUI launcher = new LaunchAppropriateUI(args);
        launcher.launch();
    }
390030
public static void main(String[] args) {
        try {
            ParsedCommandLine pcl = new ParsedCommandLine(args);
            Callable<String> command = pcl.getCommand();
            if (command == null) {
                System.out.println(pcl.getHelpText());
            } else {
                System.out.println(command.call());
            }
        } catch (Exception ex) {
            System.err.println("ERROR: " + ex.getMessage());
        }
    }
1368589
public static void main(final String[] args) throws Exception {
		// Set the logger to use the text area logger
		System.setProperty("org.apache.commons.logging.Log",
				"com.github.bordertech.wcomponents.lde.StandaloneLauncher$TextAreaLogger");

		// Set the port number to a random port
		Configuration internalWComponentConfig = Config.getInstance();
		CompositeConfiguration config = new CompositeConfiguration(new MapConfiguration(
				new HashMap<String, Object>()));
		config.addConfiguration(internalWComponentConfig); // Internal WComponent config next
		config.setProperty(ConfigurationProperties.LDE_SERVER_PORT, 0);
		Config.setConfiguration(config);

		getInstance().launcher.run();
		getInstance().log("LDE now running on " + getInstance().launcher.getUrl() + '\n');
	}
1304465
@VisibleForTesting
    public static void runMain(final String[] args) throws Exception {
        final CliHelpDefinition helpCli = new CliHelpDefinition();

        try {
            Args.parse(helpCli, args);
            if (helpCli.help) {
                printUsage(0);
                return;
            }
        } catch (IllegalArgumentException invalidOption) {
            // Ignore because it is probably one of the non-help options.
        }

        final CliDefinition cli = new CliDefinition();
        try {
            List<String> unusedArguments = Args.parse(cli, args);

            if (!unusedArguments.isEmpty()) {
                System.out.println("\n\nThe following arguments are not recognized: " + unusedArguments);
                printUsage(1);
                return;
            }
        } catch (IllegalArgumentException invalidOption) {
            System.out.println("\n\n" + invalidOption.getMessage());
            printUsage(1);
            return;
        }
        configureLogs(cli.verbose);

        AbstractXmlApplicationContext context = new ClassPathXmlApplicationContext(DEFAULT_SPRING_CONTEXT);

        if (cli.springConfig != null) {
            context = new ClassPathXmlApplicationContext(DEFAULT_SPRING_CONTEXT, cli.springConfig);
        }
        try {
            context.getBean(Main.class).run(cli);
        } finally {
            context.close();
        }
    }
722494
public static void main(String[] args) throws Exception {
        setCustomErrStream();

        CommandLine cmdLine = null;
        try {
            cmdLine = new CommandLine(args != null ? Arrays.copyOf(args, args.length) : null);

        } catch (final Exception e) {
        	// Cant use the CommandLine help here as the 
        	// i18n messages wont have been loaded
            System.out.println("Failed due to invalid parameters: " + Arrays.toString(args));
            System.out.println(e.getMessage());
            System.out.println("Use '-h' for more details.");
            System.exit(1);
        }

        ZapBootstrap bootstrap = createZapBootstrap(cmdLine);
        try {
            int rc = bootstrap.start();
            if (rc != 0) {
                System.exit(rc);
            }

        } catch (final Exception e) {
            logger.fatal(e.getMessage(), e);
            System.exit(1);
        }

    }
152866
public void run(String[] args) {
    // Add and parse options.
    OptionParser parser = new OptionParser();
    initializeCommonOptions(parser);
    initializeOptions(parser);

    String errorMessage = null;
    try {
      parsedOptions = parser.parse(args);
    } catch (OptionException e) {
      errorMessage = e.getMessage();
    }

    boolean printHelp = false;
    if (errorMessage != null) {
      // If an error occurs, the options don't parse.
      // Therefore, we must manually check if the help option was
      // given.
      for (int i = 0; i < args.length; i++) {
        if (args[i].equals("--help")) {
          printHelp = true;
        }
      }
    }

    if (errorMessage != null && !printHelp) {
      System.err.println(errorMessage);
      System.err.println("Try --help for more information about options.");
      System.exit(1);
    }

    if (printHelp || parsedOptions.has(helpOpt)) {
      // If a help option is given, print help then quit.
      try {
        parser.printHelpOn(System.err);
      } catch (IOException ioException) {
        throw new RuntimeException(ioException);
      }
      System.exit(0);
    }

    // Log any passed-in options.
    if (!parsedOptions.has(noPrintOptions)) {
      System.out.println("Command-line options:");
      for (OptionSpec<?> optionSpec : parsedOptions.specs()) {
        if (parsedOptions.hasArgument(optionSpec)) {
          System.out.println("--" + Iterables.getFirst(optionSpec.options(), "") + " "
              + Joiner.on(" ").join(parsedOptions.valuesOf(optionSpec)));
        } else {
          System.out.println("--" + Iterables.getFirst(optionSpec.options(), ""));
        }
      }
      System.out.println("");
    }

    // Run the program.
    long startTime = System.currentTimeMillis();
    processOptions(parsedOptions);
    run(parsedOptions);
    long endTime = System.currentTimeMillis();

    if (!parsedOptions.has(noPrintOptions)) {
      System.out.println("Total time elapsed: " + TimeUtils.durationToString(endTime - startTime));
    }

    System.exit(0);
  }
131921
public static void main(final String... args) throws Exception {
        try (ConfigurableApplicationContext context = SpringApplication.run(Application.class, args)) {
            log.info("Arguments: {}", Arrays.asList(args));

            try {
                context.getBean(Application.class).run(context);
            } catch (Exception e) {
                log.error("Exception in command execution", e);
            }
        }
    }
538207
public void run(String[] args) throws Exception {
        if (args.length == 0) {
            usage();
            System.exit(1);
        }
        argOptions.parseOptions(args);
        
        int numArgs = argOptions.numPositionalArgs();
        if (numArgs < 2) {
            throw new IllegalArgumentException("must specify output path");
        }

        verbose = argOptions.hasOption('v') || argOptions.hasOption("verbose");
        // If verbose output is enabled, update all the loggers in the S-Space
        // package logging tree to output at Level.FINE (normally, it is
        // Level.INFO).  This provides a more detailed view of how the execution
        // flow is proceeding.
        if (verbose) 
            LoggerUtil.setLevel(Level.FINE);

        boolean overwrite = true;
        if (argOptions.hasOption("overwrite")) {
            overwrite = argOptions.getBooleanOption("overwrite");
        }
        
        handleExtraOptions();

        Properties props = setupProperties();

        // Initialize the IteratorFactory to tokenize the documents according to
        // the specified configuration (e.g. filtering, compound words)
        if (argOptions.hasOption("tokenFilter")) {
            props.setProperty(IteratorFactory.TOKEN_FILTER_PROPERTY,
                              argOptions.getStringOption("tokenFilter"));            
        }

        // Set any tokenizing options.
        if (argOptions.hasOption("stemmingAlgorithm"))
            props.setProperty(IteratorFactory.STEMMER_PROPERTY,
                              argOptions.getStringOption("stemmingAlgorithm"));

        if (argOptions.hasOption("compoundWords")) {
            props.setProperty(
                IteratorFactory.COMPOUND_TOKENS_FILE_PROPERTY,
                              argOptions.getStringOption("compoundWords"));
        }
        if (argOptions.hasOption("wordLimit"))
            props.setProperty(IteratorFactory.TOKEN_COUNT_LIMIT_PROPERTY,
                              argOptions.getStringOption("wordLimit"));

        
        // use the System properties in case the user specified them as
        // -Dprop=<val> to the JVM directly.

        File outputPath = new File(argOptions.getPositionalArg(numArgs - 1));
        File outputFile = null;
        // If the path is a directory, generate the .sspace file name based on
        // the space's name, taking into account any duplicates
        if (outputPath.isDirectory()) {
            outputFile = (overwrite)
                ? new File(outputPath, "temp-fixme-" + EXT)
                : File.createTempFile("temp-fixme-", EXT, outputPath);

        }
        // Otherwise the user has specified a file name directly, which should
        // be used.
        else {
            if (outputPath.exists() && !overwrite) {
                // Find the file's base name and extension in order to generate
                // a unique file name with the same structure
                String name = outputPath.getName();
                int dotIndex = name.lastIndexOf(".");
                String extension = (dotIndex < 0 && dotIndex+1 < name.length())
                    ? "" : name.substring(dotIndex);
                String baseName = name.substring(0, dotIndex);
                // createTempFile has a restriction that the filename must be at
                // least 3 characters.  If it is less, then we need to pad it
                // with random numbers outselves.
                if (baseName.length() < 3)
                    baseName += Math.abs((Math.random() * Short.MAX_VALUE) *10);
                File outputDir = outputPath.getParentFile();
                // If the parent was null, then the file must be being created
                // in the directory from which this class was invoked.  
                if (outputDir == null)
                    outputDir = new File("");
                System.out.println("base dir: " + outputDir);
                outputFile = File.createTempFile(baseName, extension, outputDir);
            }
            else
                outputFile = outputPath;
        }

        System.out.println("output File: " + outputFile);

        SSpaceFormat format = (argOptions.hasOption("outputFormat"))
            ? SSpaceFormat.valueOf(
                argOptions.getStringOption("outputFormat").toUpperCase())
            : getSpaceFormat();

        SemanticSpaceWriter writer = 
            new SemanticSpaceWriter(outputFile, format);

        Collection<String> inputFiles = new LinkedList<String>();
        for (int arg = 0; arg < numArgs - 1; ++arg)
            inputFiles.add(argOptions.getPositionalArg(arg));

        long startTime = System.currentTimeMillis();
        execute(inputFiles, writer);            
        long endTime = System.currentTimeMillis();

        verbose("Computed space in %.3f seconds",
                ((endTime - startTime) / 1000d));

        postProcessing();
    }
257563
public CommandLine parseArgs(final String[] args) throws CLIToolOptionsException {
        final CommandLine line = super.parseArgs(args);
        if (args.length > 0 && !args[0].startsWith("-")) {
            try {
                action = Actions.valueOf(args[0]);
            } catch (IllegalArgumentException e) {
                throw new CLIToolOptionsException(
                        "Invalid action: " + args[0] + ", must be one of: " + Arrays.toString(
                                Actions.values()
                        )
                );
            }
        }
        if (line.hasOption("h")) {
            help();
            exit(1);
        }
        return line;
    }
243019
public static void main(String[] args) throws Exception {
      Shell shell = new ShellImpl();
      shell.init(args);
      shell.run();
      System.exit(0);
   }
647277
public static void executeHelp(String[] args, PrintStream stream) throws Exception {
        String subCmd = (args.length > 0) ? args[0] : "";
        if(subCmd.equals("orphaned-data")) {
            SubCommandCleanupOrphanedData.printHelp(stream);
        } else if(subCmd.equals("vector-clocks")) {
            SubCommandCleanupVectorClocks.printHelp(stream);
        } else if(subCmd.equals("slops")) {
            SubCommandCleanupSlops.printHelp(stream);
        } else {
            printHelp(stream);
        }
    }
187018
public static void setAllCommandLine(String[] args) {
      if (args != null) {
         CommandLineParser parser = new CommandLineParser();
         parser.parse(args);
         setAllCommandLine(parser);
      }
   }
716493
public static void main(String[] args) {
		try {
			JarRunner runner = new JarRunner(args);
			runner.runIfConfigured();
		} catch (NumberFormatException e) {
			System.err.println("Could not parse number " + e.getMessage());
			System.exit(1);
		} catch (RuntimeException e) {
			System.err.println(e.getMessage());
			System.exit(1);
		}
	}