/** * Cirrus main entry point. * * @param args the command line arguments. */ public static void main(final String[] args) { if (args.length < 1) { LOG.error(MessageCatalog.WRONG_ARGS_SIZE); System.exit(1); } final Command command = COMMAND_REGISTRY.get(args[0]); if (command == null) { LOG.error(MessageCatalog._00001__UNKNOWN_COMMAND, args[0]); System.exit(1); } final CommandLineParser parser = new BasicParser(); try { final CommandLine commandLine = parser.parse(command.getOptions(), args); command.execute(commandLine); } catch (final MissingOptionException exception) { command._log.error(MessageCatalog._00028_CL_PARSER_FAILURE, exception.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("cirrus <command> <options>", command.getOptions()); System.exit(1); } catch (final ParseException exception) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("cirrus <command> <options>", command.getOptions()); System.exit(1); } }
@SuppressWarnings("static-access") public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption( OptionBuilder.withArgName("name") .hasArg() .withDescription("name of the archive") .create(NAME_OPTION)); options.addOption( OptionBuilder.withArgName("path") .hasArg() .withDescription("WARC files location") .create(DIR_OPTION)); options.addOption( OptionBuilder.withArgName("n") .hasArg() .withDescription("Start from the n-th WARC file") .create(START_OPTION)); options.addOption("create", false, "create new table"); options.addOption("append", false, "append to existing table"); CommandLine cmdline = null; CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { System.err.println("Error parsing command line: " + exp.getMessage()); System.exit(-1); } if (!cmdline.hasOption(DIR_OPTION) || !cmdline.hasOption(NAME_OPTION)) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(IngestFiles.class.getCanonicalName(), options); System.exit(-1); } if (!cmdline.hasOption(CREATE_OPTION) && !cmdline.hasOption(APPEND_OPTION)) { System.err.println( String.format("Must specify either -%s or -%s", CREATE_OPTION, APPEND_OPTION)); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(IngestFiles.class.getCanonicalName(), options); System.exit(-1); } String path = cmdline.getOptionValue(DIR_OPTION); File inputFolder = new File(path); int i = 0; if (cmdline.hasOption(START_OPTION)) { i = Integer.parseInt(cmdline.getOptionValue(START_OPTION)); } String name = cmdline.getOptionValue(NAME_OPTION); boolean create = cmdline.hasOption(CREATE_OPTION); IngestFiles load = new IngestFiles(name, create); load.ingestFolder(inputFolder, i); }
private static void usage(CommandLine commandLine) { option(); HelpFormatter formatter = new HelpFormatter(); System.out.println( "ApkPatch v1.0.3 - a tool for build/merge Android Patch file (.apatch).\nCopyright 2015 supern lee <*****@*****.**>\n"); formatter.printHelp( "apkpatch -f <new> -t <old> -o <output> -k <keystore> -p <***> -a <alias> -e <***>", patchOptions); System.out.println(""); formatter.printHelp( "apkpatch -m <apatch_path...> -k <keystore> -p <***> -a <alias> -e <***>", mergeOptions); }
private void run(String[] args) { formOptions(); HelpFormatter formatter = new HelpFormatter(); if (args.length == 0) { formatter.printHelp("NYAppealParse - extract legal information from court cases", options); return; } try { if (!parseOptions(args)) { return; } if (parserType.equals(GATEParser.PARSER_TYPE) || parserType.equalsIgnoreCase(IParser.BOTH)) { if (StringUtils.isEmpty(gateHome)) { formatter.printHelp( "When GATE parser is used, gate-home parameter must be specified", options); return; } } IParser parser = null; cleanupFirst(); if (parserType.equalsIgnoreCase(TextParser.PARSER_TYPE)) { parser = new TextParser(); } else if (parserType.equalsIgnoreCase(GATEParser.PARSER_TYPE)) { parser = new GATEParser(gateHome); } else if (parserType.equalsIgnoreCase(IParser.BOTH)) { IParser textParser = new TextParser(); System.out.println("Using parser " + textParser.getClass().getSimpleName()); parseAll(textParser); System.out.println(textParser.getStats().toString()); IParser gateParser = new GATEParser(gateHome); System.out.println("Using parser " + gateParser.getClass().getSimpleName()); parseAll(gateParser); System.out.println(gateParser.getStats().toString()); } else { logger.info("Unrecognized parser type " + parserType + ", using NYAppealParse."); parser = new TextParser(); } if (!parserType.equalsIgnoreCase(IParser.BOTH)) { System.out.println("Using parser " + parser.getClass().getSimpleName()); parseAll(parser); System.out.println(parser.getStats().toString()); } System.out.println("Input dir: " + inputDir); System.out.println("Output dir: " + new File(outputFile).getParent()); } catch (Exception e) { e.printStackTrace(); } }
public static void main(String[] args) throws Exception { long t0 = System.currentTimeMillis(); final String OPT_JAR_FILE = "aijar"; final String OPT_CLASSNAME = "ainame"; Options options = new Options() .addOption( Option.builder(OPT_JAR_FILE) .hasArg() .argName("jarfile") .required() .desc("The path to the jar file") .build()) .addOption( Option.builder(OPT_CLASSNAME) .hasArg() .argName("classname") .required() .desc("The full classpath of the Ai class") .build()) .addOption(timeOpt); DraughtStateParser.addOptions(options); HelpFormatter formatter = new HelpFormatter(); CommandLine line = new DefaultParser().parse(options, args); DraughtsPlayer player; Integer time; DraughtsState draughtsState; try { File aiJar = new File(line.getOptionValue(OPT_JAR_FILE)); if (!aiJar.canRead() || !aiJar.isFile()) { throw new ParseException("Could not read from aijar"); } String className = line.getOptionValue(OPT_CLASSNAME); player = Main.getFromClass(aiJar, className); time = Integer.parseInt(line.getOptionValue(OPT_TIME)); draughtsState = DraughtStateParser.parseDraughtsState(line); } catch (JSONException e) { formatter.printHelp("java -jar wtcl.jar", options); System.err.println( "JSON Exception on string " + line.getOptionValue(DraughtStateParser.OPT_BOARD)); throw e; } catch (Exception e) { formatter.printHelp("java -jar wtcl.jar", options); throw e; } execute(player, draughtsState, time, t0); }
public int run(String[] args) throws Exception { Options options = new Options(); // automatically generate the help statement HelpFormatter formatter = new HelpFormatter(); // create the parser CommandLineParser parser = new GnuParser(); options.addOption("h", "help", false, "print this message"); options.addOption("i", "input", true, "input file or directory"); options.addOption("o", "output", true, "output Behemoth corpus"); options.addOption("r", "recurse", true, "processes directories recursively (default true)"); options.addOption("u", "unpack", true, "unpack content of archives (default true)"); // parse the command line arguments CommandLine line = null; try { line = parser.parse(options, args); String input = line.getOptionValue("i"); if (line.hasOption("help")) { formatter.printHelp("CorpusGenerator", options); return 0; } if (input == null) { formatter.printHelp("CorpusGenerator", options); return -1; } } catch (ParseException e) { formatter.printHelp("CorpusGenerator", options); } boolean recurse = true; if ("false".equalsIgnoreCase(line.getOptionValue("r"))) recurse = false; boolean unpack = true; if ("false".equalsIgnoreCase(line.getOptionValue("u"))) unpack = false; getConf().setBoolean(unpackParamName, unpack); Path inputDir = new Path(line.getOptionValue("i")); Path output = new Path(line.getOptionValue("o")); setInput(inputDir); setOutput(output); long count = generate(recurse); System.out.println(count + " docs converted"); return 0; }
@SuppressWarnings("static-access") public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption( OptionBuilder.withArgName("path") .hasArg() .withDescription("data file with tweet ids") .create(DATA_OPTION)); options.addOption( OptionBuilder.withArgName("path") .hasArg() .withDescription("output file (*.gz)") .create(OUTPUT_OPTION)); options.addOption(NOFOLLOW_OPTION, NOFOLLOW_OPTION, false, "don't follow 301 redirects"); CommandLine cmdline = null; CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { System.err.println("Error parsing command line: " + exp.getMessage()); System.exit(-1); } if (!cmdline.hasOption(DATA_OPTION) || !cmdline.hasOption(OUTPUT_OPTION)) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(ReadStatuses.class.getName(), options); System.exit(-1); } String data = cmdline.getOptionValue(DATA_OPTION); String output = cmdline.getOptionValue(OUTPUT_OPTION); boolean noFollow = cmdline.hasOption(NOFOLLOW_OPTION); new AsyncEmbeddedJsonStatusBlockCrawler(new File(data), output, noFollow).fetch(); }
protected void usage(ParseException e, boolean showHiddenOptions) { if (e != null) { System.err.println("Error parsing command line arguments: " + e.getMessage()); } Options opts = showHiddenOptions ? getAllOptions() : mOptions; PrintWriter pw = new PrintWriter(System.err, true); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp( pw, formatter.getWidth(), getCommandUsage(), null, opts, formatter.getLeftPadding(), formatter.getDescPadding(), null); pw.flush(); String trailer = getTrailer(); if (trailer != null && trailer.length() > 0) { System.err.println(); System.err.println(trailer); } }
private void printHelp() { final HelpFormatter formatter = new HelpFormatter(); // formatter.setLeftPadding(2); // formatter.setDescPadding(2); // formatter.setWidth(80); formatter.printHelp("aws", m_options); }
private static void printHelp(Options options) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp( "mount.sdfs -m <mount point> " + "-r <path to chunk store routing file> -[v|vc] <volume name to mount | path to volume config file> ", options); }
public static void main(String[] args) { options = createOptions(); CommandLineParser parser = new GnuParser(); try { CommandLine line = parser.parse(options, args); String complexFile = line.getOptionValue("complex"); String pointsFile = line.getOptionValue("points"); String outputFile = null; if (line.hasOption("destination")) { outputFile = line.getOptionValue("destination"); } else { outputFile = FileManager.generateUniqueFileName() + ".pov"; } renderFromFiles(complexFile, pointsFile, outputFile); } catch (ParseException exp) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("plex-viewer", options); } catch (IOException e) { e.printStackTrace(); } }
/** * Parse arguments * * @param args */ private void commandLineParser(String[] args) throws ParseException { options = new Options(); options.addOption("help", false, "print this message"); options.addOption( OPTION_CARBON_PORT, true, "specify port for graphite/carbon events - (" + DEFAULT_PORT_CARBON + " by default)"); options.addOption( OPTION_STATSD_PORT, true, "specify port for statsD events - (" + DEFAULT_PORT_STATSD + " by default)"); options.addOption( OPTION_WEBSERVER_PORT, true, "specify port for http server - (" + DEFAULT_PORT_WEBSERVER + " by default)"); options.addOption( OPTION_CARBON_ONLY, false, "start TCP socket only for graphite/carbon events"); options.addOption(OPTION_STATSD_ONLY, false, "start UDP socket only for statsd events"); options.addOption(OPTION_NO_WEBSERVER, false, "don't start webserver"); options.addOption(OPTION_HAWTIO, false, "start hawtio in webserver"); options.addOption(OPTION_BACKEND, true, "backend implementation available : " + getBackends()); options.addOption(OPTION_WEBSERVER_WEBROOT, true, "HTTP base resource (must be a path)"); CommandLineParser parser = new PosixParser(); cmd = parser.parse(options, args); if (cmd.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar bigloupe-chart.jar [options]", options); System.exit(0); } }
private static void printHelp(Options options) { String header = "Enter some parameters\n\n"; String footer = "\nPlease report issues at [email protected]"; HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.printHelp("aaaJava", header, options, footer, true); }
@Override public int run(String[] args) throws Exception { Options options = new Options(); options.addOption("c", "concurrent", false, "run concurrently with generation"); GnuParser parser = new GnuParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); if (cmd.getArgs().length != 4) { throw new ParseException( "Did not see expected # of arguments, saw " + cmd.getArgs().length); } } catch (ParseException e) { System.err.println("Failed to parse command line " + e.getMessage()); System.err.println(); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(getClass().getSimpleName() + " <output dir> <num reducers>", options); System.exit(-1); } String outputDir = cmd.getArgs()[0]; int numReducers = Integer.parseInt(cmd.getArgs()[1]); String accessKey = cmd.getArgs()[2]; String secretKey = cmd.getArgs()[3]; return run(outputDir, numReducers, cmd.hasOption("c"), accessKey, secretKey); }
private static final void printHelp(PrintStream out, Options options, ParseException e) { if (e != null) { out.println(NAME + ": Command line error - " + e.getMessage()); } HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.printHelp(NAME, options); }
/** Option help. */ private void optionHelp() { System.out.println("option -h. Exit Programm"); final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("movsim", options); System.exit(0); }
public static void main(String[] args) throws ConfigurationException, ParseException { Configuration config = new PropertiesConfiguration("application.properties"); // Options Options options = setUpOptions(); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); // TODO Anatoli: it makes sense to add strict validation for (Option option : cmd.getOptions()) { if (StringUtils.isNotBlank(option.getValue())) { config.addProperty(option.getLongOpt(), option.getValue()); } } if (cmd.hasOption('h')) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(120); formatter.printHelp( "java -Dlogback.configurationFile=logback.xml -jar whatIsOilPriceNow.jar [options]", options); return; } RockNRoller roller = new RockNRoller(config); roller.startMainLoop(); }
public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption("i", "input-file", true, "input data file."); options.addOption("o", "output-file", true, "output file."); options.addOption("h", "help", false, "display help document"); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); String inputFile = null; String outputFile = null; if (cmd.hasOption("i")) { inputFile = cmd.getOptionValue("i"); } if (cmd.hasOption("o")) { outputFile = cmd.getOptionValue("o"); } boolean help = false; if (inputFile == null || outputFile == null) { help = true; } if (cmd.hasOption("h") || help) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("docsim stat", options); return; } // DocSimStatTest test = new DocSimStatTest(""); // test.notestSummary(); DocSimLatticeStatistics stat = BasicStatisticsFormatter.getStatFromFile(inputFile); BasicStatisticsFormatter.avgCalcBySize2File(stat, outputFile); }
@Override protected int run(CommandLine cmd) throws Exception { List args = cmd.getArgList(); if (args.contains(CMD_ACTION_CREATE)) { return create(cmd); } if (args.contains(CMD_ACTION_LIST)) { return list(cmd); } if (args.contains(CMD_ACTION_UPDATE_PASSWORD)) { return updatePassword(cmd); } if (args.contains(CMD_ACTION_DELETE)) { return delete(cmd); } if (args.contains(CMD_ACTION_SET_PRIVILEGES)) { return setPrivileges(cmd); } if (args.contains(CMD_ACTION_SET_AUTHORIZATIONS)) { return setAuthorizations(cmd); } String actions = StringUtils.join(getActions(), " | "); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(UserAdmin.class.getSimpleName() + " < " + actions + " >", getOptions()); return -1; }
public void displayHelp() { System.out.println(); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar cli-jar-name [options]", "\nOptions:", options, "\n"); }
private void processCommandLine(String[] args) throws ParseException { Option certificateFilenameOption; Options commandLineOptions; CommandLineParser clp; CommandLine cl; certificateFilenameOption = null; commandLineOptions = null; clp = null; cl = null; certificateFilenameOption = new Option("f", "file", true, "file name containing certificate to be imported"); certificateFilenameOption.setRequired(true); certificateFilenameOption.setArgs(1); certificateFilenameOption.setOptionalArg(false); certificateFilenameOption.setArgName("filename"); commandLineOptions = new Options(); commandLineOptions.addOption(certificateFilenameOption); clp = new PosixParser(); try { cl = clp.parse(commandLineOptions, args); setCertificateFilename(IMPORT_AREA_DIRECTORY + "/" + cl.getOptionValue('f')); } catch (ParseException pe) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(APPLICATION_NAME, commandLineOptions, true); throw pe; } }
@Override public void run(String... args) throws Exception { CommandLine line = this.commandLineParser.parse(this.options, args); String[] remainingArgs = line.getArgs(); if (remainingArgs.length < 3 && !line.hasOption("file") || remainingArgs.length < 1 && line.hasOption("file")) { helpFormatter.printHelp("xmergel [OPTION] [file1 file2 ...] [result_file]", this.options); System.exit(1); } if (line.hasOption("debug")) { this.isDebug = true; } List<Path> filesToCombine = this.getPathsFromArgs(remainingArgs); if (line.hasOption("file")) { System.out.println("Finding files..."); filesToCombine = this.getPathsFromFile(line.getOptionValue("file"), filesToCombine); } String output = remainingArgs[remainingArgs.length - 1]; System.out.println("Merging files..."); try { this.xmergel.setResultFile(output); this.xmergel.combine(filesToCombine); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); if (this.isDebug) { e.printStackTrace(); } System.exit(1); } File fileOutput = Paths.get(output).toFile(); System.out.println("Files have been merged in '" + fileOutput.getAbsolutePath() + "'."); }
private static boolean setOptions(String[] lcommand) { Options loptions = new Options(); loptions.addOption(new Option("d", "debug", false, "print debug information (highly verbose)")); loptions.addOption(new Option("o", "stdout", false, "print output files to standard output")); loptions.addOption(new Option("w", "warning", false, "print warning messages")); CommandLineParser clparser = new PosixParser(); try { cmd = clparser.parse(loptions, lcommand); } catch (org.apache.commons.cli.ParseException e) { String mytoolcmd = "java -jar stave.jar"; String myoptlist = " <options> <source files>"; String myheader = "Convert JavaParser's AST to OpenJDK's AST"; String myfooter = "More info: https://github.com/pcgomes/javaparser2jctree"; HelpFormatter formatter = new HelpFormatter(); // formatter.printUsage( new PrintWriter(System.out,true), 100, "java -jar synctask.jar", // loptions ); // formatter.printHelp( mytoolcmd + myoptlist, myheader, loptions, myfooter, false); formatter.printHelp(mytoolcmd + myoptlist, loptions, false); return (false); } return (true); }
/** Check command line arguments. */ public void checkComanLineArgs() { options.addOption(COMMANDS_MANAGER_U, COMMANDS_MANAGER_USER, true, USER_DESCRIPTION); options.addOption(COMMANDS_MANAGER_P, COMMANDS_MANAGER_PASSWORD, true, PASSWORD_DESCRIPTION); options.addOption( COMMANDS_MANAGER_FETCH_F, COMMANDS_MANAGER_FETCH_FILE, false, FETCH_FILE_DESCRIPTION); options.addOption(COMMANDS_MANAGER_H, COMMANDS_MANAGER_HELP, false, HELP_DESCRIPTION); CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(options, args); if (cmd.hasOption(COMMANDS_MANAGER_U) && cmd.hasOption(COMMANDS_MANAGER_P) || cmd.hasOption(COMMANDS_MANAGER_USER) && cmd.hasOption(COMMANDS_MANAGER_PASSWORD)) { setName(cmd.getOptionValue(COMMANDS_MANAGER_U)); setPass(cmd.getOptionValue(COMMANDS_MANAGER_P)); } else if (cmd.hasOption(COMMANDS_MANAGER_FETCH_F)) { isGetLink = false; } else if (cmd.hasOption(COMMANDS_MANAGER_H)) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(COMMANDS_MANAGER_H, options); System.exit(0); } } catch (ParseException e) { // e.printStackTrace(); LOGGER.error(e); } }
private static CommandLine parseArguments(String[] args) { HelpFormatter formatter = new HelpFormatter(); CommandLine cLine = null; Options options = new Options(); CommandLineParser parser = new BasicParser(); options.addOption("l", "language", true, "Language of the Wikipedia to use."); options.addOption("y", "year", true, "Year of the dump of Wikipedia to use."); options.addOption("c", "category", true, "Identifier of the category to explore."); options.addOption("v", "vocabulary", true, "File with the domain vocabulary."); options.addOption("t", "top", true, "Percentage of the domain vocabulary to use."); options.addOption("k", "file", true, "File with all the categories found from the category."); options.addOption("s", "score", true, "Minimum score to accept groups of categories."); options.addOption("h", "help", false, "This help"); try { cLine = parser.parse(options, args); } catch (ParseException exp) { logger.error("Unexpected exception:" + exp.getMessage()); } if (cLine == null) { System.err.println("Please, set the required parameters\n"); formatter.printHelp(CategoryExplorer.class.getSimpleName(), options); System.exit(1); } if (cLine.hasOption("h")) { formatter.printHelp(CategoryExplorer.class.getSimpleName(), options); System.exit(0); } boolean wiki = cLine.hasOption("l") && cLine.hasOption("y"); boolean step1 = cLine.hasOption("c") && cLine.hasOption("t") && cLine.hasOption("s"); boolean step2 = cLine.hasOption("c") && cLine.hasOption("t") && cLine.hasOption("s") && cLine.hasOption("v"); boolean step3 = cLine.hasOption("k") && cLine.hasOption("s"); if (!(wiki && (step1 || step2 || step3))) { System.err.println("Please, set the required parameters\n"); formatter.printHelp(CategoryExplorer.class.getSimpleName(), options); System.exit(1); } return cLine; }
public static void main(String[] args) { int threads = 1; int port = 9090; String configFile = ""; boolean kbest = false; CommandLineParser parser = new GnuParser(); Options options = createOptions(); HelpFormatter hformat = new HelpFormatter(); CommandLine line = null; try { line = parser.parse(options, args); } catch (ParseException e) { logger.error(e.getMessage()); hformat.printHelp("java " + StanfordParserServer.class.getName(), options, true); System.exit(1); } if (line.hasOption("help")) { hformat.printHelp("java " + StanfordParserServer.class.getName(), options, true); System.exit(1); } port = Integer.parseInt(line.getOptionValue("port", "9090")); try { threads = Integer.parseInt(line.getOptionValue("threads", "2")); } catch (NumberFormatException e) { logger.warn("Couldn't interpret {} as a number.", line.getOptionValue("threads")); } if (threads < 0) { threads = 1; } else if (threads == 0) { threads = 2; } configFile = line.getOptionValue("config", ""); if (line.hasOption("kbest")) { kbest = true; } MultiParser.Iface handler; if (kbest) { handler = new KBestStanfordParserHandler(configFile); } else { handler = new StanfordParserHandler(configFile); } MultiParser.Processor processor = new MultiParser.Processor(handler); runServer(processor, port, threads); }
public static void main(String[] argv) throws Exception { Options options = new Options(); options.addOption("js", false, "Create f5less.js"); options.addOption("p", "port", true, "ws:reload websocket server port"); options.addOption("h", "host", true, "ws:reload websocket server host"); options.addOption("d", "debounce", true, "debouncing for commands"); CommandLine cmdLine = new PosixParser().parse(options, argv); String[] args = cmdLine.getArgs(); if (cmdLine.hasOption("js")) { Files.copy( TheBuilder.class.getClassLoader().getResourceAsStream("f5less.js"), Paths.get("./f5less.js"), StandardCopyOption.REPLACE_EXISTING); System.out.println( "\n f5less.js created...\n put the following\n" + " <script type=\"text/javascript\" src=\"f5less.js\"></script>\n" + " <script type=\"text/javascript\">f5less.connect()</script>\n" + " in the page for which you want automatic reloading (assuming 'f5less.js' is in the same directory)\n"); } if (args.length < 2) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("f5less [options] path1 cmd1 path2 cmd2 ...", options); System.exit(-1); } final List<String> reloadPaths = new LinkedList<String>(); final int commandsDebounce = Integer.parseInt(cmdLine.getOptionValue("d", "100")); for (int i = 0; i < args.length / 2; i++) { final String path = args[i * 2]; final String rawCmd = args[i * 2 + 1]; if (rawCmd.equals("ws:reload")) reloadPaths.add(path); else Watcher.register(path, new CommandListener(path, rawCmd, commandsDebounce)); } ReloadServer reloadServer = null; if (!reloadPaths.isEmpty()) { reloadServer = new ReloadServer( cmdLine.getOptionValue("h", "localhost"), Integer.parseInt(cmdLine.getOptionValue("p", "9999")), commandsDebounce + 50); reloadServer.monitor(reloadPaths); } System.out.println("Press enter to exit..."); System.in.read(); if (reloadServer != null) reloadServer.stop(); Watcher.stop(); CommandListener.stop(); System.out.println("Bye bye"); }
public void dispatch(String[] args, FTPSession ftp) { CommandLine line = ArgParser.parse(args); if (args.length <= 0 || line == null || line.hasOption('h') || line.hasOption("help")) { // determine whether or not to print usage/help HelpFormatter help = new HelpFormatter(); help.printHelp("FTPClient", ArgParser.options()); } else { // otherwise handle all other options if (line.hasOption('C') || line.hasOption("connect")) { // handle server connection option commands.connect(ftp, line.getOptionValue('C')); } if (line.hasOption("l") || line.hasOption("list")) { if (line.hasOption("L") || line.hasOption("local")) { // handle option to list local files commands.listLocalWorkingDir(ftp); } else { // handle option to list remote files commands.listRemoteWorkingDir(ftp); } } if (line.hasOption('g') || line.hasOption("get")) { // handle getting a file on remote commands.getRemoteFile(ftp, line.getOptionValue('g')); } if (line.hasOption('p') || line.hasOption("put")) { // handle putting a file on remote commands.putRemoteFile(ftp, line.getOptionValues('p')); } if (line.hasOption('i') || line.hasOption("dir")) { // create directory on the ftp server commands.createRemoteDirectory(ftp, line.getOptionValue('i')); } if (line.hasOption('m') || line.hasOption("modify")) { // modify remote file permissions commands.changeRemotePermissions(ftp, line.getOptionValues('m')); } if (line.hasOption('d') || line.hasOption("delete")) { if (line.hasOption('R') || line.hasOption("recursive")) { // TODO: handle delete remote directory } else { // delete file on remote server commands.deleteRemoteFile(ftp, line.getOptionValue('d')); } } commands.exit(ftp); } }
private void printUsage(boolean tsqlMode) { if (!tsqlMode) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("getconf <key> [options]", options); } System.out.println( defaultLeftPad + "key" + defaultDescPad + "gets a specific key from the configuration"); }
public static CommandLine parseCmdLine( final String appName, String[] args, Options options, CommandLineParser parser) { HelpFormatter hf = new HelpFormatter(); hf.setWidth(110); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); if (commandLine.hasOption('h')) { hf.printHelp(appName, options, true); return null; } } catch (ParseException e) { hf.printHelp(appName, options, true); } return commandLine; }