Java Code Examples for net.sourceforge.argparse4j.inf.ArgumentParser#defaultHelp()
The following examples show how to use
net.sourceforge.argparse4j.inf.ArgumentParser#defaultHelp() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TPCHGenerator.java From flink-perf with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { // Parse and handle arguments ArgumentParser ap = ArgumentParsers.newArgumentParser("Distributed TPCH"); ap.defaultHelp(true); ap.addArgument("-s", "--scale").setDefault(1.0).help("TPC H Scale (final Size in GB)").type(Double.class); ap.addArgument("-p","--parallelism").setDefault(1).help("Parallelism for program").type(Integer.class); ap.addArgument("-e", "--extension").setDefault(".csv").help("File extension for generated files"); ap.addArgument("-o", "--outpath").setDefault("/tmp/").help("Output directory"); Namespace ns = null; try { ns = ap.parseArgs(args); } catch (ArgumentParserException e) { ap.handleError(e); System.exit(1); } final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(ns.getInt("parallelism")); DistributedTPCH gen = new DistributedTPCH(env); gen.setScale(ns.getDouble("scale")); String base = ns.getString("outpath"); String ext = ns.getString("extension"); gen.generateParts().writeAsFormattedText(base + "parts" + ext, new TpchEntityFormatter()); gen.generateLineItems().writeAsFormattedText(base + "lineitems" + ext, new TpchEntityFormatter()); gen.generateOrders().writeAsFormattedText(base + "orders" + ext, new TpchEntityFormatter()); gen.generateSuppliers().writeAsFormattedText(base + "suppliers" + ext, new TpchEntityFormatter()); gen.generatePartSuppliers().writeAsFormattedText(base + "partsuppliers" + ext, new TpchEntityFormatter()); gen.generateRegions().writeAsFormattedText(base + "regions" + ext, new TpchEntityFormatter()); gen.generateNations().writeAsFormattedText(base + "nations" + ext, new TpchEntityFormatter()); gen.generateCustomers().writeAsFormattedText(base + "customers" + ext, new TpchEntityFormatter()); env.execute("Distributed TPCH Generator, Scale = "+gen.getScale()); }
Example 2
Source File: RedosTester.java From ReScue with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { ArgumentParser parser = ArgumentParsers.newFor("ReScue").build(); parser.defaultHelp(true); parser.description("ReScue is a tool to auto detect ReDoS vulnerabilities in regexes. (noSeeding, noIncubating and noPumping are mutex arguments, and only used for testing)"); parser.addArgument("-q", "--quiet").action(Arguments.storeTrue()).help("Quiet mode, hide input tips."); parser.addArgument("-v", "--visual").action(Arguments.storeTrue()).help("Show e-NFA of the input regex."); parser.addArgument("-ml", "--maxLength").setDefault(128).help("Maximum string length."); parser.addArgument("-pz", "--popSize").setDefault(200).help("Maximum population size."); parser.addArgument("-g", "--generation").setDefault(200).help("Maximum generations."); parser.addArgument("-cp", "--crossPossibility").setDefault("10").help("The crossover possibility, default is 10, means 10%."); parser.addArgument("-mp", "--mutatePossibility").setDefault("10").help("The mutation possibility, default is 10, means 10%."); parser.addArgument("-ns", "--noSeeding").action(Arguments.storeTrue()).help("No seeding version of ReScue, only used for evaluation & testing."); parser.addArgument("-ni", "--noIncubating").action(Arguments.storeTrue()).help("No incubating version of ReScue, only used for evaluation & testing."); parser.addArgument("-np", "--noPumping").action(Arguments.storeTrue()).help("No pumping version of ReScue, only used for evaluation & testing."); if (args.length == 0) { parser.printHelp(); return ; } Namespace ns = null; try { ns = parser.parseArgs(args); System.out.println(ns.getBoolean("unittest")); } catch (ArgumentParserException e1) { e1.printStackTrace(); System.exit(-1); } if (ns.getBoolean("visual")){ RedosTester.testView(); } else { // These values are used for test int sl = 64; // The deprecated seed length int ml = 128; int pz = 200; int g = 200; int mp = 10; int cp = 5; // Read input arguments boolean quiet = ns.getBoolean("quiet"); sl = ns.getInt("maxLength"); ml = ns.getInt("maxLength"); pz = ns.getInt("popSize"); g = ns.getInt("generation"); cp = ns.getInt("crossPossibility"); mp = ns.getInt("mutatePossibility"); if (!quiet) System.out.print("Input regex: "); Scanner input = new Scanner(System.in); String regex = input.hasNextLine() ? input.nextLine() : null; input.close(); if (regex == null || regex.length() < 1) { System.out.println("Please check your regex."); return ; } RedosAttacker atk = null; if (ns.getBoolean("noSeeding")) atk = new GeneticAttackerWithoutSeeding(sl, ml, pz, g, (double)mp / (double)100, (double)cp / (double) 100); else if (ns.getBoolean("noIncubating")) atk = new GeneticAttackerWithoutIncubating(sl, ml, pz, g, (double)mp / (double)100, (double)cp / (double) 100); else if (ns.getBoolean("noPumping")) atk = new GeneticAttackerWithoutPumping(sl, ml, pz, g, (double)mp / (double)100, (double)cp / (double) 100); else atk = new GeneticAttacker(sl, ml, pz, g, (double)mp / (double)100, (double)cp / (double) 100); RedosTester rt = new RedosTester(atk, regex); rt.attackAndPrint(); } }