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); } } }
public static void configureArguments(ArgumentParser parser, boolean required) { MutuallyExclusiveGroup group = parser.addMutuallyExclusiveGroup("input data") .description("Specify the input data for the command.") .required(required); ArgumentGroup options = parser.addArgumentGroup("input options") .description("Additional options for input data."); group.addArgument("--csv-file") .type(File.class) .metavar("FILE") .help("read from comma-separated FILE"); group.addArgument("--tsv-file") .type(File.class) .metavar("FILE") .help("read from tab-separated FILE"); group.addArgument("--ratings-file") .type(File.class) .metavar("FILE") .help("read from delimited text FILE"); group.addArgument("--entities-file") .type(File.class) .metavar("FILE") .metavar("FILE") .help("Read item names from CSV file FILE"); group.addArgument("--data-source") .type(File.class) .metavar("FILE")
@Override public void attachToSubparser(final Subparser subparser) { subparser.addArgument("number") .help("Specify the phone number, for which to set the trust.") .required(true); MutuallyExclusiveGroup mutTrust = subparser.addMutuallyExclusiveGroup(); mutTrust.addArgument("-a", "--trust-all-known-keys") .help("Trust all known keys of this user, only use this for testing.") .action(Arguments.storeTrue()); mutTrust.addArgument("-v", "--verified-fingerprint") .help("Specify the fingerprint of the key, only use this option if you have verified the fingerprint."); }
.description("Partitioning mode for the crossfolder."); mode.addArgument("--partition-users") .dest("crossfold_mode") .action(Arguments.storeConst()) .setConst("partition-users") .help("Partition users into K partitions (the default)"); mode.addArgument("--partition-entities") .dest("crossfold_mode") .action(Arguments.storeConst()) .setConst("partition-entities") .help("Partition entities into K partitions"); mode.addArgument("--partition-ratings") .dest("crossfold_mode") .action(Arguments.storeConst()) .setConst("partition-ratings") .help("Partition ratings into K partitions"); mode.addArgument("--sample-entities") .dest("crossfold_mode") .action(Arguments.storeConst()) .setConst("sample-entities") .help("Create K samples of entities"); mode.addArgument("--sample-users") .dest("crossfold_mode") .action(Arguments.storeConst()) .setConst("sample-users") .help("Generate K samples of users"); mode.addArgument("--partition-items") .dest("crossfold_mode") .action(Arguments.storeConst())
mut.addArgument("-u", "--username") .help("Specify your phone number, that will be used for verification."); mut.addArgument("--dbus") .help("Make request via user dbus.") .action(Arguments.storeTrue()); mut.addArgument("--dbus-system") .help("Make request via system dbus.") .action(Arguments.storeTrue());
public static void main(String... args) throws Exception { ArgumentParser parser = ArgumentParsers.newFor("SynthesizeText") .build() .defaultHelp(true) .description("Synthesize a text or ssml."); 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) { synthesizeText(namespace.getString("text")); } else { synthesizeSsml(namespace.getString("ssml")); } } catch (ArgumentParserException e) { parser.handleError(e); } } }
contentTypes.addArgument("-C", "--content-type").help("Content type to send in the Content-Type request header"); contentTypes.addArgument("-J", "--json").dest("content_type").setConst("application/json").action(storeConst()).help("Specifies application/json in the Content-Type request header");
.description("Takes FullConfig xml file and resolves expressions inside using global config file - used mainly for TED instances"); argParser.addArgument("-fullconfig").type(String.class).required(true).help("Path to fullconfig that should be resolved."); MutuallyExclusiveGroup addMutuallyExclusiveGroup = argParser.addMutuallyExclusiveGroup().required(true); addMutuallyExclusiveGroup.addArgument("-fullconfigout").type(String.class).help("Path to output file with resolved full config."); EmptyArgumentAction onlyValidateAction = new EmptyArgumentAction(); EmptyArgumentAction strictAction = new EmptyArgumentAction(); EmptyArgumentAction verboseAction = new EmptyArgumentAction(); addMutuallyExclusiveGroup.addArgument("-onlyvalidate").action(onlyValidateAction).setDefault(Arguments.SUPPRESS).help("Sets mode to validation only."); argParser.addArgument("-strict").action(strictAction).setDefault(Arguments.SUPPRESS).help("Sets error expression handling to strict mode - exception on error.");
failGroup.addArgument("--fail-fast") .help("exit and report failure on first error when reading from file (this is the default behavior)") .dest("fail-behavior") .setConst(FAIL_FAST) .action(new StoreConstArgumentAction()); failGroup.addArgument("--fail-at-end") .help("exit and report failures at end of input when reading from file") .dest("fail-behavior")
.required(false); .action(new HelpArgumentAction()); mutexParser.addArgument("-config") .type(new ConfigFolderArgumentType()) .metavar("PATH") + "If not provided, the config files will be obtained from the current working directory."); mutexParser.addArgument("-repo", "-repos") .nargs("+") .dest("repos")