Parses command-line input and prints help menu.

@throws Exception
553903
public static void executeHelp(String[] args, PrintStream stream) throws Exception {
        String subCmd = (args.length > 0) ? args[0] : "";
        args = CoordinatorAdminUtils.copyArrayCutFirst(args);
        if(subCmd.equals("get")) {
            SubCommandGet.printHelp(stream);
        } else if(subCmd.equals("put")) {
            SubCommandPut.printHelp(stream);
        } else if(subCmd.equals("delete")) {
            SubCommandDelete.printHelp(stream);
        } else {
            args = CoordinatorAdminUtils.copyArrayAddFirst(args, subCmd);
            printHelp(stream);
        }
    }
377090
public void handleCommand() throws IOException {
        this.currentLine = this.reader.readLine();

        if (this.currentLine == null) {
            LOGGER.severe("Current line is null!");
            this.exit();
            return;
        }

        final StringTokenizer st = new StringTokenizer(this.currentLine, " ");
        final String commandName = st.nextToken().toUpperCase();
        final String arg = st.hasMoreTokens() ? st.nextToken() : null;
        if (commandName == null) {
            LOGGER.severe("Command name is empty!");
            this.exit();
            return;
        }

        if (commandName.equals("STAT")) {
            this.stat();
        } else if (commandName.equals("LIST")) {
            this.list();
        } else if (commandName.equals("RETR")) {
            this.retr(arg);
        } else if (commandName.equals("DELE")) {
            this.dele();
        } else if (commandName.equals("NOOP")) {
            this.noop();
        } else if (commandName.equals("RSET")) {
            this.rset();
        } else if (commandName.equals("QUIT")) {
            this.quit();
        } else if (commandName.equals("TOP")) {
            this.top(arg);
        } else if (commandName.equals("UIDL")) {
            this.uidl();
        } else if (commandName.equals("USER")) {
            this.user();
        } else if (commandName.equals("PASS")) {
            this.pass();
        } else if (commandName.equals("CAPA")) {
            this.println("-ERR CAPA not supported");
        } else {
            LOGGER.log(Level.SEVERE, "ERROR command unknown: {0}", commandName);
            this.println("-ERR unknown command");
        }
    }
902909
public static void mainInternal(String[] args) throws Exception {

        Options options = new Options();
        CmdLineParser parser = new CmdLineParser(options);
        try {
            parser.parseArgument(args);
        } catch (CmdLineException e) {
            helpScreen(parser);
            return;
        }

        try {
            List<String> configs = new ArrayList<>();
            if (options.configs != null) {
                configs.addAll(Arrays.asList(options.configs.split(",")));
            }
            ConfigSupport.applyConfigChange(ConfigSupport.getJBossHome(), configs, options.enable);
        } catch (ConfigException ex) {
            ConfigLogger.error(ex);
            throw ex;
        } catch (Throwable th) {
            ConfigLogger.error(th);
            throw th;
        }
    }
315517
public static void executeHelp(String[] args, PrintStream stream) throws Exception {
        String subCmd = (args.length > 0) ? args[0] : "";
        if(subCmd.equals("query-keys")) {
            SubCommandDebugQueryKeys.printHelp(stream);
        } else if(subCmd.equals("route")) {
            SubCommandDebugRoute.printHelp(stream);
        } else {
            printHelp(stream);
        }
    }
998046
public void ls() throws Exception {

        String folder = CmsResource.getFolderPath(m_cms.getRequestContext().getUri());
        List<CmsResource> resources = m_cms.getResourcesInFolder(folder, CmsResourceFilter.IGNORE_EXPIRATION);
        m_shell.getOut().println(
            "\n" + getMessages().key(Messages.GUI_SHELL_LS_2, folder, new Integer(resources.size())));
        Iterator<CmsResource> i = resources.iterator();
        while (i.hasNext()) {
            CmsResource r = i.next();
            m_shell.getOut().println(m_cms.getSitePath(r));
        }
        m_shell.getOut().println();
    }
900068
static public void main(String ... args) throws Exception {
        FileInputStream fin = new FileInputStream(args[0]);
        XMLReader<Sample> reader = new XMLReader<Sample>();
        
        for( Map<String,Object> map : reader.read(fin, Sample.class) ) {
            System.out.println("Next...");
            for( Map.Entry<String,Object> entry : map.entrySet() ) {
                System.out.println("\t" + entry.getKey() + " (" + (entry.getValue() != null ? entry.getValue().getClass().getName() : "") + "): " + entry.getValue());
            }
        }
    }
516745
public static void executeHelp(String[] args, PrintStream stream) throws Exception {
        String subCmd = (args.length > 0) ? args[0] : "";
        if(subCmd.equals("fetch-entries")) {
            SubCommandStreamFetchEntries.printHelp(stream);
        } else if(subCmd.equals("fetch-keys")) {
            SubCommandStreamFetchKeys.printHelp(stream);
        } else if(subCmd.equals("mirror")) {
            SubCommandStreamMirror.printHelp(stream);
        } else if(subCmd.equals("update-entries")) {
            SubCommandStreamUpdateEntries.printHelp(stream);
        } else {
            printHelp(stream);
        }
    }
662507
public void start(String[] args) throws Exception {
        OptionParserCommandLine commandLineArgs = new OptionParserCommandLine();
        options = commandLineArgs.parse(args);
        if (options == null) {
            // Abort
            return;
        }
        startup = commandLineArgs.startup();
        // initialize editor settings
        configEditor();
        // initialize JShell instance
        try {
            resetState();
        } catch (IllegalStateException ex) {
            // Display just the cause (not a exception backtrace)
            cmderr.println(ex.getMessage());
            //abort
            return;
        }
        // Read replay history from last jshell session into previous history
        replayableHistoryPrevious = ReplayableHistory.fromPrevious(prefs);
        // load snippet/command files given on command-line
        for (String loadFile : commandLineArgs.nonOptions()) {
            runFile(loadFile, "jshell");
        }
        // if we survived that...
        if (regenerateOnDeath) {
            // initialize the predefined feedback modes
            initFeedback(commandLineArgs.feedbackMode());
        }
        // check again, as feedback setting could have failed
        if (regenerateOnDeath) {
            // if we haven't died, and the feedback mode wants fluff, print welcome
            if (feedback.shouldDisplayCommandFluff()) {
                hardmsg("jshell.msg.welcome", version());
            }
            // Be sure history is always saved so that user code isn't lost
            Thread shutdownHook = new Thread() {
                @Override
                public void run() {
                    replayableHistory.storeHistory(prefs);
                }
            };
            Runtime.getRuntime().addShutdownHook(shutdownHook);
            // execute from user input
            try (IOContext in = new ConsoleIOContext(this, cmdin, console)) {
                while (regenerateOnDeath) {
                    if (!live) {
                        resetState();
                    }
                    run(in);
                }
            } finally {
                replayableHistory.storeHistory(prefs);
                closeState();
                try {
                    Runtime.getRuntime().removeShutdownHook(shutdownHook);
                } catch (Exception ex) {
                    // ignore, this probably caused by VM aready being shutdown
                    // and this is the last act anyhow
                }
            }
        }
        closeState();
    }
148838
public static void main(String[] args) throws Exception {

		final ParameterTool params = ParameterTool.fromArgs(args);

		// set up the execution environment
		final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

		// get input data
		DataStream<String> text;
		if (params.has("input")) {
			// read the text file from given input path
			text = env.readTextFile(params.get("input"));
		} else {
			System.out.println("Executing WindowWordCount example with default input data set.");
			System.out.println("Use --input to specify file input.");
			// get default test text data
			text = env.fromElements(WordCountData.WORDS);
		}

		// make parameters available in the web interface
		env.getConfig().setGlobalJobParameters(params);

		final int windowSize = params.getInt("window", 10);
		final int slideSize = params.getInt("slide", 5);

		DataStream<Tuple2<String, Integer>> counts =
		// split up the lines in pairs (2-tuples) containing: (word,1)
		text.flatMap(new WordCount.Tokenizer())
				// create windows of windowSize records slided every slideSize records
				.keyBy(0)
				.countWindow(windowSize, slideSize)
				// group by the tuple field "0" and sum up tuple field "1"
				.sum(1);

		// emit result
		if (params.has("output")) {
			counts.writeAsText(params.get("output"));
		} else {
			System.out.println("Printing result to stdout. Use --output to specify output path.");
			counts.print();
		}

		// execute program
		env.execute("WindowWordCount");
	}
1099703
public void run() throws Exception {

        Registry registry = LocateRegistry.getRegistry(m_registryPort);
        I_CmsRemoteShellProvider provider = (I_CmsRemoteShellProvider)(registry.lookup(
            CmsRemoteShellConstants.PROVIDER));
        m_remoteShell = provider.createShell(m_additionalCommands);
        m_prompt = m_remoteShell.getPrompt();
        m_out = new PrintStream(System.out);
        try {
            LineNumberReader lnr = new LineNumberReader(new InputStreamReader(m_input, "UTF-8"));
            while (!exitCalled()) {
                if (m_interactive || isEcho()) {
                    // print the prompt in front of the commands to process only when 'interactive'
                    printPrompt();
                }
                String line = lnr.readLine();
                if (line == null) {
                    break;
                }
                if (line.trim().startsWith("#")) {
                    m_out.println(line);
                    continue;
                }
                StringReader lineReader = new StringReader(line);
                StreamTokenizer st = new StreamTokenizer(lineReader);
                st.eolIsSignificant(true);
                st.wordChars('*', '*');
                // put all tokens into a List
                List<String> parameters = new ArrayList<String>();
                while (st.nextToken() != StreamTokenizer.TT_EOF) {
                    if (st.ttype == StreamTokenizer.TT_NUMBER) {
                        parameters.add(Integer.toString(new Double(st.nval).intValue()));
                    } else {
                        parameters.add(st.sval);
                    }
                }
                lineReader.close();

                if (parameters.size() == 0) {
                    // empty line, just need to check if echo is on
                    if (isEcho()) {
                        m_out.println();
                    }
                    continue;
                }

                // extract command and arguments
                String command = parameters.get(0);
                List<String> arguments = new ArrayList<String>(parameters.subList(1, parameters.size()));

                // execute the command with the given arguments
                executeCommand(command, arguments);

            }
            exit(0);
        } catch (Throwable t) {
            t.printStackTrace();
            if (m_errorCode != -1) {
                exit(m_errorCode);
            }
        }
    }
458896
boolean parseCmdLineArgs(String[] args) throws IllegalArgumentException {
        for (int i = 0; i < args.length; i++) {
            if (args[i].toLowerCase().contains("help") || args[i].toLowerCase().contains("usage")) {
                // print the usage information and exit.
                printUsage();
                return true;
            }
            boolean accepted = false;
            for (Option option : options) {
                if (args[i].equalsIgnoreCase(option.name)) {
                    if (i + option.nargs < args.length) {
                        i += option.accept(args, i + 1);
                    } else {
                        throw new IllegalArgumentException(getLocalizedParmString("CWTRA0022E",
                                                                                  new Object[] { option.name, option.nargs }));
                    }
                    accepted = true;
                    break;
                }
            }
            if (!accepted) {
                throw new IllegalArgumentException(getLocalizedParmString("CWTRA0023E", new Object[] { args[i] }));
            }
        }
        return false;
    }
1002097
public static void main(String[] args) throws Exception {
        String loopBack = null;
        Socket socket = new Socket(loopBack, Integer.parseInt(args[0]));
        InputStream inStream = socket.getInputStream();
        OutputStream outStream = socket.getOutputStream();
        Map<String, Consumer<OutputStream>> outputs = new HashMap<>();
        outputs.put("out", st -> System.setOut(new PrintStream(st, true)));
        outputs.put("err", st -> System.setErr(new PrintStream(st, true)));
        Map<String, Consumer<InputStream>> input = new HashMap<>();
        input.put("in", System::setIn);
        forwardExecutionControlAndIO(new RemoteExecutionControl(), inStream, outStream, outputs, input);
    }
68985
public static void printUsage(ParseException e, String cmdLine,
			Options options) {
		System.err.println(e.getMessage());
		// automatically generate the help statement
		HelpFormatter formatter = new HelpFormatter();
		PrintWriter pw = new PrintWriter(System.err);
		formatter.printUsage(pw, cmdLine.length() + 7, cmdLine, options);
		pw.flush();
	}
1039965
public function parse() {
        global $argv;

        $options = array();
        $parameters = array();
        $argc = count( $argv );
        $paramCount = count( $this->parameters );
        
        //get parameters
        if( $argc - 1 < $paramCount ) {
            throw new \Exception("The command requires $paramCount parameters.");
        }
        
        //last items are the params
        for( $i = $paramCount - 1; $i >= 0; $i-- ) {
            $this->abstractParameters[$this->parameters[$i]] = $argv[$argc - $i - 1];
        }
        
        //go through each arg
        for( $i = 1; $i < $argc - $paramCount; $i++ ) {
            $arg = $argv[$i];
            
            //cannot start without a switch
            if( !$this->isOption( $arg ) ) {
                throw new \Exception("Invalid argument \"$arg\".");
            }
            
            //check if it's a valid option
            $option = $arg[1];

            if( $this->isParam( $option ) ) {
                //the arg stands on its own, such as -f, not -ffile.txt
                //set next as its value, move $i ahead
                if( $this->isSolitary( $arg ) ) {
                    //last item
                    if( $i == $argc - $paramCount - 1 ) {
                        throw new \Exception("Parameter does not follow the option \"$option\".");
                    }
                    
                    $this->abstractOptions[$option] = $argv[$i+1];
                    $i++;
                } else {
                    $this->abstractOptions[$option] = substr( $arg, 2 );
                }
            } else if( $this->isSwitch( $option ) ) {
                //loop through all switches in the param
                for( $i = 1; $i < strlen( $param ) - 1; $i++ ) {
                    $s = $arg[$i];
                    
                    //not a switch
                    if( !$this->isSwitch( $arg[$i] ) ) {
                        throw new \Exception("An invalid switch \"$s\" was provided.");
                    }
                    
                    $this->abstractOptions[$s] = true;
                }
            }
        }
    }
745668
@Override
    public void handle(CommandContext ctx, String commandLine) {
        // TODO Validate command

        if (commandLine.contains("--help")) {
            this.printHelp(commandLine, ctx);
            return;
        }

        String[] commands = commandLine.split(" ");

        if (commands.length == 1) {
            ctx.connectController(null, -1);
        } else if (commands.length == 2) {
            if (commandLine.contains("--help")) {
                this.printHelp("help/connect.txt", ctx);
                return;
            }
        } else if (commands.length == 3) {
            String host = commands[1];
            try {
                int port = Integer.parseInt(commands[2]);
                ctx.connectController(host, port);
            } catch (NumberFormatException ne) {
                ctx.printLine("Port must be from 1 to 65535");
            }

        } else {
            ctx.printLine("Invalid command.");
        }

    }
678203
public static void main(final String args[])
		throws Exception {
		if (hasParameter(args,"--help") ||
			hasParameter(args,"-h")) {
			showUsage(null);
		}
		String  url				 = getParameter(args, "--url");
		String  outfile			 = getParameter(args, "--out");
		String  fontPath	 	 = getParameter(args, "--fontpath");
		String  password		 = getParameter(args, "--password");
		String  keystorePath     = getParameter(args, "--ks");
		String  keystorePassword = getParameter(args, "--kspassword");
		String  keyPassword		 = getParameter(args, "--keypassword");
		String  cryptReason		 = getParameter(args, "--cryptreason");
		String  cryptLocation    = getParameter(args, "--cryptlocation");
		
		if (outfile == null) {
			showUsage("--out file must exists !");
		} // end if

		try {
			new URL(url);
		} // end try
		catch (final Exception e) {
			showUsage("--url must be a valid URL !");
		} // end catch
		try {
			File fout = new File(outfile);

			List			 headerFooterList = new ArrayList();

			FileOutputStream out = new FileOutputStream(fout);
			System.out.println("before conversion");

			Map properties = new HashMap();

			headerFooterList.add(new IHtmlToPdfTransformer.CHeaderFooter(
					"<table width=\"100%\"><tbody><tr><td align=\"left\">Generated with YaHPConverter.</td><td align=\"right\">Page <pagenumber>/<pagecount></td></tr></tbody></table>",
					IHtmlToPdfTransformer.CHeaderFooter.HEADER));
			headerFooterList.add(new IHtmlToPdfTransformer.CHeaderFooter(
					"© 2011 Quentin Anciaux",
					IHtmlToPdfTransformer.CHeaderFooter.FOOTER));
			
			properties.put(IHtmlToPdfTransformer.PDF_RENDERER_CLASS,
					IHtmlToPdfTransformer.FLYINGSAUCER_PDF_RENDERER);
			if (fontPath != null)
				properties.put(IHtmlToPdfTransformer.FOP_TTF_FONT_PATH, fontPath);

			if (password != null) {
				System.out.println(password);
				properties.put(IHtmlToPdfTransformer.USE_PDF_ENCRYPTION,
					"true");
				properties.put(IHtmlToPdfTransformer.PDF_ALLOW_SCREEN_READERS,
					"true");
				properties.put(IHtmlToPdfTransformer.PDF_ENCRYPTION_PASSWORD,
					password);

				if (keystorePath != null) {
					properties.put(IHtmlToPdfTransformer.USE_PDF_SIGNING,
						"true");
					properties.put(IHtmlToPdfTransformer.PDF_SIGNING_PRIVATE_KEY_FILE,
						keystorePath);
					properties.put(IHtmlToPdfTransformer.PDF_SIGNING_KEYSTORE_PASSWORD,
						keystorePassword);
					properties.put(IHtmlToPdfTransformer.PDF_SIGNING_PRIVATE_KEY_PASSWORD,
						keyPassword);

					if (cryptReason != null) {
						properties.put(IHtmlToPdfTransformer.PDF_SIGNING_REASON,
							cryptReason);
					} // end if

					if (cryptLocation != null) {
						properties.put(IHtmlToPdfTransformer.PDF_SIGNING_LOCATION,
							cryptLocation);
					} // end if
				} // end if
			} // end if

			converter.convertToPdf(new URL(url),
				IHtmlToPdfTransformer.A4P, headerFooterList, out,
				properties);
			System.out.println("after conversion");
			out.flush();
			out.close();
		} // end try
		catch (final Throwable t) {
			t.printStackTrace();
			System.err.println("An error occurs while converting '" +
				url + "' to '" + outfile + "'. Cause : " +
				t.getMessage());
			System.exit(-1);
		} // end catch

		System.exit(0);
	}
110447
private function printHelp()
    {
        $this->writeLn("Usage: pho [options] [files]\n");
        $this->writeLn("Options\n");

        // Loop over availableOptions, building the necessary input for
        // ConsoleFormatter::alignText()
        $options = [];
        foreach ($this->availableOptions as $name => $optionInfo) {
            $row = [$optionInfo[1], $optionInfo[0]];
            $row[] = (isset($optionInfo[3])) ? "<{$optionInfo[3]}>" : '';
            $row[] = $optionInfo[2];

            $options[] = $row;
        }

        $pad = str_repeat(' ', 3);
        foreach ($this->formatter->alignText($options, $pad) as $line) {
            $this->writeLn($pad . $line);
        }
    }