net.sourceforge.argparse4j.inf.ArgumentParser Java Examples
The following examples show how to use
net.sourceforge.argparse4j.inf.ArgumentParser.
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: PredictionApi.java From java-docs-samples with Apache License 2.0 | 6 votes |
public static void argsHelper(String[] args, PrintStream out) throws IOException { ArgumentParser parser = ArgumentParsers.newFor("PredictionApi") .build() .defaultHelp(true) .description("Prediction API Operation"); Subparsers subparsers = parser.addSubparsers().dest("command"); Subparser predictParser = subparsers.addParser("predict"); predictParser.addArgument("modelId"); predictParser.addArgument("filePath"); String projectId = System.getenv("PROJECT_ID"); String computeRegion = System.getenv("REGION_NAME"); Namespace ns = null; try { ns = parser.parseArgs(args); if (ns.get("command").equals("predict")) { predict(projectId, computeRegion, ns.getString("modelId"), ns.getString("filePath")); } } catch (ArgumentParserException e) { parser.handleError(e); } }
Example #2
Source File: HiveScriptGenerator.java From emodb with Apache License 2.0 | 6 votes |
protected void doMain(String args[]) { ArgumentParser parser = ArgumentParsers.newArgumentParser(getClass().getSimpleName()); parser.addArgument("--out") .dest("out") .metavar("FILE") .nargs("?") .setDefault("stdout") .help("Writes the script to the output file; default is stdout"); addArguments(parser); Namespace namespace = parser.parseArgsOrFail(args); String file = namespace.getString("out"); try (PrintStream out = file.equals("stdout") ? System.out : new PrintStream(new FileOutputStream(file))) { generateScript(namespace, out); } catch (IOException e) { System.err.println("Script generation failed"); e.printStackTrace(System.err); } }
Example #3
Source File: PrettyPrint.java From graphicsfuzz with Apache License 2.0 | 6 votes |
private static Namespace parse(String[] args) throws ArgumentParserException { ArgumentParser parser = ArgumentParsers.newArgumentParser("PrettyPrint") .defaultHelp(true) .description("Pretty print a shader."); // Required arguments parser.addArgument("shader") .help("Path of shader to be pretty-printed.") .type(File.class); parser.addArgument("output") .help("Target file name.") .type(String.class); parser.addArgument("--add-braces") .help("Add braces even for single-statement code blocks") .action(Arguments.storeTrue()); return parser.parseArgs(args); }
Example #4
Source File: Main.java From graphicsfuzz with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { ArgumentParser parser = ArgumentParsers.newArgumentParser("Fuzzer server") .defaultHelp(true); parser.addArgument("--port") .help("Port on which to listen.") .setDefault(8080) .type(Integer.class); try { Namespace ns = parser.parseArgs(args); new FuzzerServer(ns.get("port")).start(); } catch (ArgumentParserException ex) { ex.getParser().handleError(ex); } }
Example #5
Source File: ImpressionsToInfluxDb.java From seldon-server with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { ArgumentParser parser = ArgumentParsers.newArgumentParser("ImpressionsToInfluxDb") .defaultHelp(true) .description("Read Seldon impressions and send stats to influx db"); parser.addArgument("-t", "--topic").setDefault("impressions").help("Kafka topic to read from"); parser.addArgument("-k", "--kafka").setDefault("localhost:9092").help("Kafka server and port"); parser.addArgument("-z", "--zookeeper").setDefault("localhost:2181").help("Zookeeper server and port"); parser.addArgument("-i", "--influxdb").setDefault("localhost:8086").help("Influxdb server and port"); parser.addArgument("-u", "--influx-user").setDefault("root").help("Influxdb user"); parser.addArgument("-p", "--influx-password").setDefault("root").help("Influxdb password"); parser.addArgument("-d", "--influx-database").setDefault("seldon").help("Influxdb database"); parser.addArgument("--influx-measurement-impressions").setDefault("impressions").help("Influxdb impressions measurement"); parser.addArgument("--influx-measurement-requests").setDefault("requests").help("Influxdb requests measurement"); Namespace ns = null; try { ns = parser.parseArgs(args); ImpressionsToInfluxDb.process(ns); } catch (ArgumentParserException e) { parser.handleError(e); System.exit(1); } }
Example #6
Source File: JobCreateCommandTest.java From helios with Apache License 2.0 | 6 votes |
@Before public void setUp() { // use a real, dummy Subparser impl to avoid having to mock out every single call final ArgumentParser parser = ArgumentParsers.newArgumentParser("test"); final Subparser subparser = parser.addSubparsers().addParser("create"); final Supplier<Map<String, String>> envVarSupplier = new Supplier<Map<String, String>>() { @Override public Map<String, String> get() { return ImmutableMap.copyOf(envVars); } }; command = new JobCreateCommand(subparser, envVarSupplier); when(client.createJob(argThat(matchesName(JOB_NAME)))).thenReturn(immediateFuture( new CreateJobResponse(CreateJobResponse.Status.OK, Collections.<String>emptyList(), "12345") )); }
Example #7
Source File: SynthesizeFile.java From java-docs-samples with Apache License 2.0 | 6 votes |
public static void main(String... args) throws Exception { ArgumentParser parser = ArgumentParsers.newFor("SynthesizeFile") .build() .defaultHelp(true) .description("Synthesize a text file or ssml file."); MutuallyExclusiveGroup group = parser.addMutuallyExclusiveGroup().required(true); group.addArgument("--text").help("The text file from which to synthesize speech."); group.addArgument("--ssml").help("The ssml file from which to synthesize speech."); try { Namespace namespace = parser.parseArgs(args); if (namespace.get("text") != null) { synthesizeTextFile(namespace.getString("text")); } else { synthesizeSsmlFile(namespace.getString("ssml")); } } catch (ArgumentParserException e) { parser.handleError(e); } }
Example #8
Source File: CliMain.java From styx with Apache License 2.0 | 6 votes |
private GlobalOptions(ArgumentParser parser, CliContext cliContext, boolean subCommand) { this.options = parser.addArgumentGroup("global options"); this.host = options.addArgument("-H", "--host") .help("Styx API host (can also be set with environment variable " + ENV_VAR_PREFIX + "_HOST)") .setDefault(subCommand ? FeatureControl.SUPPRESS : null) .setDefault(cliContext.env().get(ENV_VAR_PREFIX + "_HOST")) .action(Arguments.store()); this.json = options.addArgument("--json") .help("json output") .setDefault(subCommand ? FeatureControl.SUPPRESS : null) .action(Arguments.storeTrue()); this.plain = options.addArgument("-p", "--plain") .help("plain output") .setDefault(subCommand ? FeatureControl.SUPPRESS : null) .action(Arguments.storeTrue()); this.debug = options.addArgument("--debug") .help("debug output") .setDefault(subCommand ? FeatureControl.SUPPRESS : null) .action(Arguments.storeTrue()); }
Example #9
Source File: CompareHistograms.java From graphicsfuzz with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws ArgumentParserException, FileNotFoundException { final ArgumentParser parser = ArgumentParsers.newArgumentParser("CompareHistograms") .defaultHelp(true) .description("Print chi-squared distance between the histograms of two given images."); // Required arguments parser.addArgument("image1") .help("Path of first image.") .type(File.class); parser.addArgument("image2") .help("Path of second image.") .type(File.class); final Namespace ns = parser.parseArgs(args); System.out.println(ImageUtil.compareHistograms((File) ns.get("image1"), ns.get("image2"))); }
Example #10
Source File: AbstractBinary.java From rsync4j with GNU General Public License v3.0 | 6 votes |
/** * Sets the commandline options. * * @param options the options to use * @return true if successful * @throws Exception in case of an invalid option */ public boolean setOptions(String[] options) throws Exception { ArgumentParser parser; Namespace ns; parser = getParser(); try { ns = parser.parseArgs(options); } catch (ArgumentParserException e) { parser.handleError(e); return false; } return setOptions(ns); }
Example #11
Source File: ZookeeperReadyCommand.java From common-docker with Apache License 2.0 | 6 votes |
private static ArgumentParser createArgsParser() { ArgumentParser zkReady = ArgumentParsers .newArgumentParser(ZK_READY) .defaultHelp(true) .description("Check if ZK is ready."); zkReady.addArgument("zookeeper_connect") .action(store()) .required(true) .type(String.class) .metavar("ZOOKEEPER_CONNECT") .help("Zookeeper connect string."); zkReady.addArgument("timeout") .action(store()) .required(true) .type(Integer.class) .metavar("TIMEOUT_IN_MS") .help("Time (in ms) to wait for service to be ready."); return zkReady; }
Example #12
Source File: UpgradeShadingLanguageVersion.java From graphicsfuzz with Apache License 2.0 | 6 votes |
private static Namespace parse(String[] args) throws ArgumentParserException { ArgumentParser parser = ArgumentParsers.newArgumentParser("UpgradeShadingLanguageVersion") .defaultHelp(true) .description("Upgrade shading language version."); // Required arguments parser.addArgument("shader") .help("Path of shader to be upgraded.") .type(File.class); parser.addArgument("output") .help("Target file name.") .type(String.class); // Optional arguments parser.addArgument("--norename") .help("Do not rename user-defined variables and functions") .action(Arguments.storeTrue()); return parser.parseArgs(args); }
Example #13
Source File: KryoConsumerExample.java From kafka-examples with Apache License 2.0 | 6 votes |
/** * Get the command-line argument parser. */ private static ArgumentParser argParser() { ArgumentParser parser = ArgumentParsers .newArgumentParser("simple-producer") .defaultHelp(true) .description("This example is to demonstrate kafka producer capabilities"); parser.addArgument("--bootstrap.servers").action(store()) .required(true) .type(String.class) .metavar("BROKER-LIST") .help("comma separated broker list"); parser.addArgument("--topic").action(store()) .required(true) .type(String.class) .metavar("TOPIC") .help("produce messages to this topic"); return parser; }
Example #14
Source File: ImportProductSets.java From java-docs-samples with Apache License 2.0 | 6 votes |
public static void argsHelper(String[] args, PrintStream out) throws Exception { ArgumentParser parser = ArgumentParsers.newFor("Import Product Sets").build(); Subparsers subparsers = parser.addSubparsers().dest("command"); Subparser importProductSetsParser = subparsers.addParser("import_product_sets"); importProductSetsParser.addArgument("gcsUri"); String projectId = System.getenv("PROJECT_ID"); String computeRegion = System.getenv("REGION_NAME"); Namespace ns = null; try { ns = parser.parseArgs(args); if (ns.get("command").equals("import_product_sets")) { importProductSets(projectId, computeRegion, ns.getString("gcsUri")); } } catch (ArgumentParserException e) { parser.handleError(e); } }
Example #15
Source File: MainCli.java From Repeat with Apache License 2.0 | 6 votes |
private ArgumentParser setupParser() { ArgumentParser parser = ArgumentParsers.newFor("Repeat").build() .defaultHelp(true) .description("Execute Repeat operations in the terminal."); parser.addArgument("-s", "--host").type(String.class) .setDefault("localhost") .help("Specify a custom host at which the Repeat server is running."); parser.addArgument("-p", "--port").type(Integer.class) .help("Specify a custom port at which the Repeat server is running." + "If not specified, port value is read from config file."); Subparsers subParsers = parser.addSubparsers().help("Help for each individual command."); for (CliActionProcessor processor : processors.values()) { processor.addArguments(subParsers); } return parser; }
Example #16
Source File: ConsumerRebalancer.java From kafka-examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) { ArgumentParser parser = argParser(); try { Namespace result = parser.parseArgs(args); Properties configs = getConsumerConfigs(result); List<String> topics = Arrays.asList(result.getString("topics").split(",")); RecordProcessor<Serializable, Serializable> processor = getRecordProcessor(result); final ConsumerRebalancer<Serializable, Serializable> consumer = new ConsumerRebalancer<>(configs, topics); consumer.setProcessor(processor); consumer.run(); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { consumer.close(); } })); } catch (ArgumentParserException e) { if(args.length == 0) parser.printHelp(); else parser.handleError(e); System.exit(0); } }
Example #17
Source File: Main.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
/** * @return an ArgumentParser used to perform argument parsing */ private static ArgumentParser getParser() { ArgumentParser parser = ArgumentParsers.newFor(Constants.APPLICATION_NAME).build().defaultHelp(false) .description("RPG Character Generator").version(PCGenPropBundle.getVersionNumber()); parser.addArgument("-v", "--verbose").help("verbose logging").type(Boolean.class).action(Arguments.count()); parser.addArgument("-V", "--version").action(Arguments.version()); MutuallyExclusiveGroup startupMode = parser.addMutuallyExclusiveGroup().description("start up on a specific mode"); startupMode.addArgument("--name-generator").help("run the name generator").type(Boolean.class) .action(Arguments.storeTrue()); startupMode.addArgument("-D", "--tab").nargs(1); parser.addArgument("-s", "--settingsdir").nargs(1) .type(Arguments.fileType().verifyIsDirectory().verifyCanRead().verifyExists()); parser.addArgument("-m", "--campaignmode").nargs(1).type(String.class); parser.addArgument("-E", "--exportsheet").nargs(1) .type(Arguments.fileType().verifyCanRead().verifyExists().verifyIsFile()); parser.addArgument("-o", "--outputfile").nargs(1) .type(Arguments.fileType().verifyCanCreate().verifyCanWrite().verifyNotExists()); parser.addArgument("-c", "--character").nargs(1) .type(Arguments.fileType().verifyCanRead().verifyExists().verifyIsFile()); parser.addArgument("-p", "--party").nargs(1) .type(Arguments.fileType().verifyCanRead().verifyExists().verifyIsFile()); return parser; }
Example #18
Source File: SimpleConsumer.java From kafka-examples with Apache License 2.0 | 5 votes |
/** * Get the command-line argument parser. */ private static ArgumentParser argParser() { ArgumentParser parser = ArgumentParsers .newArgumentParser("simple-consumer") .defaultHelp(true) .description("This example is to demonstrate kafka consumer capabilities"); parser.addArgument("--bootstrap.servers").action(store()) .required(true) .type(String.class) .help("comma separated broker list"); parser.addArgument("--topic.partitions").action(store()) .required(true) .type(String.class) .help("consume messages from partitions. Comma separated list e.g. t1:0,t1:1,t2:0"); parser.addArgument("--clientId").action(store()) .required(true) .type(String.class) .help("client identifier"); parser.addArgument("--auto.offset.reset").action(store()) .required(false) .setDefault("earliest") .type(String.class) .choices("earliest", "latest") .help("What to do when there is no initial offset in Kafka"); parser.addArgument("--max.partition.fetch.bytes").action(store()) .required(false) .setDefault("1024") .type(String.class) .help("The maximum amount of data per-partition the server will return"); return parser; }
Example #19
Source File: ProductInProductSetManagement.java From java-docs-samples with Apache License 2.0 | 5 votes |
public static void argsHelper(String[] args, PrintStream out) throws Exception { ArgumentParser parser = ArgumentParsers.newFor("").build(); Subparsers subparsers = parser.addSubparsers().dest("command"); Subparser addProductParser = subparsers.addParser("add_product_to_product_set"); addProductParser.addArgument("productSetId"); addProductParser.addArgument("productId"); Subparser listProductInProductSetParser = subparsers.addParser("list_products_in_product_set"); listProductInProductSetParser.addArgument("productSetId"); Subparser removeProductFromProductSetParser = subparsers.addParser("remove_product_from_product_set"); removeProductFromProductSetParser.addArgument("productId"); removeProductFromProductSetParser.addArgument("productSetId"); String projectId = System.getenv("PROJECT_ID"); String computeRegion = System.getenv("REGION_NAME"); Namespace ns = null; try { ns = parser.parseArgs(args); if (ns.get("command").equals("add_product_to_product_set")) { addProductToProductSet( projectId, computeRegion, ns.getString("productId"), ns.getString("productSetId")); } if (ns.get("command").equals("list_products_in_product_set")) { listProductsInProductSet(projectId, computeRegion, ns.getString("productSetId")); } if (ns.get("command").equals("remove_product_from_product_set")) { removeProductFromProductSet( projectId, computeRegion, ns.getString("productId"), ns.getString("productSetId")); } } catch (ArgumentParserException e) { parser.handleError(e); } }
Example #20
Source File: PredictionApi.java From java-docs-samples with Apache License 2.0 | 5 votes |
static void argsHelper(String[] args) { ArgumentParser parser = ArgumentParsers.newFor("PredictionApi") .build() .defaultHelp(true) .description("Prediction API Operation"); parser.addArgument("modelId").required(true); parser.addArgument("filePath").required(true); parser.addArgument("scoreThreshold").nargs("?").type(String.class).setDefault(""); String projectId = System.getenv("GOOGLE_CLOUD_PROJECT"); String computeRegion = System.getenv("REGION_NAME"); if (projectId == null || computeRegion == null) { System.out.println("Set `GOOGLE_CLOUD_PROJECT` and `REGION_NAME` as specified in the README"); System.exit(-1); } try { Namespace ns = parser.parseArgs(args); predict( projectId, computeRegion, ns.getString("modelId"), ns.getString("filePath"), ns.getString("scoreThreshold")); } catch (ArgumentParserException e) { parser.handleError(e); } }
Example #21
Source File: ModelApi.java From java-docs-samples with Apache License 2.0 | 5 votes |
static void argsHelper(String[] args) { ArgumentParser parser = ArgumentParsers.newFor("ModelApi") .build() .defaultHelp(true) .description("Model API operations."); Subparsers subparsers = parser.addSubparsers().dest("command"); Subparser createModelParser = subparsers.addParser("create_model"); createModelParser.addArgument("datasetId"); createModelParser.addArgument("modelName"); createModelParser.addArgument("trainBudget"); String projectId = System.getenv("GOOGLE_CLOUD_PROJECT"); String computeRegion = System.getenv("REGION_NAME"); if (projectId == null || computeRegion == null) { System.out.println("Set `GOOGLE_CLOUD_PROJECT` and `REGION_NAME` as specified in the README"); System.exit(-1); } try { Namespace ns = parser.parseArgs(args); if (ns.get("command").equals("create_model")) { createModel( projectId, computeRegion, ns.getString("datasetId"), ns.getString("modelName"), ns.getString("trainBudget")); } } catch (ArgumentParserException e) { parser.handleError(e); } }
Example #22
Source File: JobInspectCommandTest.java From helios with Apache License 2.0 | 5 votes |
@Before public void setUp() { // use a real, dummy Subparser impl to avoid having to mock out every single call final ArgumentParser parser = ArgumentParsers.newArgumentParser("test"); final Subparser subparser = parser.addSubparsers().addParser("inspect"); command = new JobInspectCommand(subparser, TimeZone.getTimeZone("UTC")); when(client.jobs(JOB_NAME_VERSION)).thenReturn(Futures.immediateFuture(jobs)); }
Example #23
Source File: ItemSimilarityProcessor.java From seldon-server with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { ArgumentParser parser = ArgumentParsers.newArgumentParser("ImpressionsToInfluxDb") .defaultHelp(true) .description("Read Seldon impressions and send stats to influx db"); parser.addArgument("-t", "--topic").setDefault("actions").help("Kafka topic to read from"); parser.addArgument("-c", "--client").required(true).help("Client to run item similarity"); parser.addArgument("-o", "--output-topic").required(true).help("Output topic"); parser.addArgument("-k", "--kafka").setDefault("localhost:9092").help("Kafka server and port"); parser.addArgument("-z", "--zookeeper").setDefault("localhost:2181").help("Zookeeper server and port"); parser.addArgument("-w", "--window-secs").type(Integer.class).setDefault(3600*5).help("streaming window size in secs, -1 means ignore"); parser.addArgument("-u", "--window-processed").type(Integer.class).setDefault(-1).help("streaming window size in processed count, -1 means ignore"); parser.addArgument("--output-poll-secs").type(Integer.class).setDefault(60).help("output timer polling period in secs"); parser.addArgument("--hashes").type(Integer.class).setDefault(100).help("number of hashes"); parser.addArgument("-m", "--min-activity").type(Integer.class).setDefault(200).help("min activity"); parser.addArgument("-p", "--parse-date-method").choices("json-time","json-utc","system").setDefault("json-time").help("min activity"); Namespace ns = null; try { ns = parser.parseArgs(args); ItemSimilarityProcessor processor = new ItemSimilarityProcessor(ns); processor.process(ns); } catch (ArgumentParserException e) { parser.handleError(e); System.exit(1); } }
Example #24
Source File: DeploymentGroupInspectCommandTest.java From helios with Apache License 2.0 | 5 votes |
@Before public void setUp() { // use a real, dummy Subparser impl to avoid having to mock out every single call final ArgumentParser parser = ArgumentParsers.newArgumentParser("test"); final Subparser subparser = parser.addSubparsers().addParser("inspect"); command = new DeploymentGroupInspectCommand(subparser); when(client.deploymentGroup(NAME)).thenReturn(Futures.immediateFuture(DEPLOYMENT_GROUP)); final ListenableFuture<DeploymentGroup> nullFuture = Futures.immediateFuture(null); when(client.deploymentGroup(NON_EXISTENT_NAME)).thenReturn(nullFuture); }
Example #25
Source File: BmpMockArguments.java From bgpcep with Eclipse Public License 1.0 | 5 votes |
private static ArgumentParser initializeArgumentParser() { final ArgumentParser parser = ArgumentParsers.newArgumentParser(PROGRAM_NAME); parser.addArgument(toArgName(ROUTERS_COUNT_DST)) .type(Integer.class) .setDefault(1); parser.addArgument(toArgName(PEERS_COUNT_DST)) .type(Integer.class) .setDefault(0); parser.addArgument(toArgName(PRE_POLICY_ROUTES_COUNT_DST)) .type(Integer.class) .setDefault(0); parser.addArgument(toArgName(POST_POLICY_ROUTES_COUNT_DST)) .type(Integer.class).setDefault(0); parser.addArgument(toArgName(PASSIVE_MODE_DST)) .action(Arguments.storeTrue()); parser.addArgument(toArgName(LOCAL_ADDRESS_DST)) .type((parser13, arg, value) -> getInetSocketAddress(value, DEFAULT_LOCAL_PORT)) .setDefault(LOCAL_ADDRESS); parser.addArgument("-ra", toArgName(REMOTE_ADDRESS_DST)) .type((ArgumentTypeTool<List<InetSocketAddress>>) input -> InetSocketAddressUtil.parseAddresses(input, DEFAULT_REMOTE_PORT)) .setDefault(Collections.singletonList(REMOTE_ADDRESS)); parser.addArgument(toArgName(LOG_LEVEL_DST)) .type((parser1, arg, value) -> Level.toLevel(value)) .setDefault(Level.INFO); return parser; }
Example #26
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 #27
Source File: IdentityDatasetArgumentResolver.java From verify-service-provider with MIT License | 5 votes |
@Override public MatchingDataset convert(ArgumentParser parser, Argument arg, String value) throws ArgumentParserException { try { return resolveMatchingDataset(value); } catch (IOException | MatchingDatasetArgumentValidationError e) { throw new ArgumentParserException(e.getMessage(), e, parser); } }
Example #28
Source File: TopicEnsureCommand.java From common-docker with Apache License 2.0 | 5 votes |
private static ArgumentParser createArgsParser() { ArgumentParser topicEnsure = ArgumentParsers .newArgumentParser(TOPIC_ENSURE) .defaultHelp(true) .description("Check if topic exists and is valid."); topicEnsure.addArgument("--timeout", "-t") .action(store()) .required(true) .type(Integer.class) .metavar("TIMEOUT_IN_MS") .help("Time (in ms) to wait for service to be ready."); topicEnsure.addArgument("--config", "-c") .action(store()) .type(String.class) .metavar("CONFIG") .required(true) .help("Client config."); topicEnsure.addArgument("--file", "-f") .action(store()) .type(String.class) .metavar("FILE_CONFIG") .required(true) .help("Topic config file."); topicEnsure.addArgument("--create-if-not-exists") .action(store()) .type(Boolean.class) .setDefault(false) .help("Create topic if it does not exist."); return topicEnsure; }
Example #29
Source File: ZoneIdArgumentType.java From RepoSense with MIT License | 5 votes |
@Override public ZoneId convert(ArgumentParser parser, Argument arg, String value) throws ArgumentParserException { try { return ZoneId.of(value); } catch (DateTimeException dte) { throw new ArgumentParserException(MESSAGE_TIMEZONE_INVALID, parser); } }
Example #30
Source File: ConfigFolderArgumentType.java From RepoSense with MIT License | 5 votes |
@Override public Path convert(ArgumentParser parser, Argument arg, String value) throws ArgumentParserException { // Piggyback on library methods to do file existence checks Arguments.fileType().verifyExists().verifyIsDirectory().verifyCanRead().convert(parser, arg, value); if (Files.exists(Paths.get(value).resolve(RepoConfigCsvParser.REPO_CONFIG_FILENAME))) { return Paths.get(value); } throw new ArgumentParserException(String.format(PARSE_EXCEPTION_MESSAGE_MISSING_REQUIRED_CONFIG_FILES, RepoConfigCsvParser.REPO_CONFIG_FILENAME), parser); }