Refine search
final String inputSource = cli.getOptionValue(CommandOption.INPUT_SOURCE.getLongName()); if (StringUtils.isBlank(inputSource)) { throw new MissingOptionException("Missing required option --" + CommandOption.INPUT_SOURCE.getLongName());
@Test public void testMissingOptionException() throws ParseException { Options options = new Options(); options.addOption(OptionBuilder.isRequired().create("f")); try { new PosixParser().parse(options, new String[0]); fail("Expected MissingOptionException to be thrown"); } catch (MissingOptionException e) { assertEquals("Missing required option: f", e.getMessage()); } }
/** * Constructs a new <code>MissingSelectedException</code> with the * specified list of missing options. * * @param missingOptions the list of missing options and groups * @since 1.2 */ public MissingOptionException(List missingOptions) { this(createMessage(missingOptions)); this.missingOptions = missingOptions; }
@Test public void testMissingRequiredOption() { String[] args = new String[] { "-a" }; Options options = new Options(); options.addOption("a", "enable-a", false, null); options.addOption(OptionBuilder.withLongOpt("bfile").hasArg().isRequired().create('b')); try { parser.parse(options,args); fail("exception should have been thrown"); } catch (MissingOptionException e) { assertEquals( "Incorrect exception message", "Missing required option: b", e.getMessage() ); assertTrue(e.getMissingOptions().contains("b")); } catch (ParseException e) { fail("expected to catch MissingOptionException"); } }
public static String outputFileOf(CommandLine cl) throws MissingOptionException { if (!cl.hasOption("o")) throw new MissingOptionException(rb.getString("missing-o-file")); return cl.getOptionValue("o"); }
commandLine = new DefaultParser().parse(options, args); } catch (MissingOptionException ex) { System.out.println(ex.getMessage()); System.exit(1); return; if (commandLine.hasOption("h")) { new HelpFormatter().printHelp("Perun ldapc-initializer:", options); System.exit(0); if(commandLine.hasOption("f")) { outputFile = commandLine.getOptionValue("f");
final CommandLine cli = parser.parse(this.getOptions(), args); if (cli.hasOption(TARGET_DOMAIN_LONG_OPTION)) { final String targetDomainName = cli.getOptionValue(TARGET_DOMAIN_LONG_OPTION); final String targetContainerHost; if (cli.hasOption(TARGET_HOST_LONG_OPTION)) { targetContainerHost = cli.getOptionValue(TARGET_HOST_LONG_OPTION); } else { throw new CommandMissingArgumentException(this, e.getOption(), e); } catch (final MissingOptionException e) { throw new CommandMissingOptionsException(this, e.getMissingOptions(), e); } catch (final ParseException e) { throw new CommandInvalidException(this, e);
private static void init(CommandLine cl, WadoWS wadoWS) throws Exception { if ((url = cl.getOptionValue("url")) == null) throw new MissingOptionException("Missing url."); if (!cl.hasOption("study") && !cl.hasOption("f")) throw new MissingOptionException("Specify either -f or --study option"); rendered = cl.hasOption("rendered"); service = new ImagingDocumentSource(); rows = cl.getOptionValue("rows"); columns = cl.getOptionValue("columns"); windowWidth = cl.getOptionValue("window-width"); windowCenter = cl.getOptionValue("window-center"); imageQuality = cl.getOptionValue("image-quality"); frameNo = cl.getOptionValue("frame-number"); if (cl.hasOption("tsuid")) tsuids = cl.getOptionValues("tsuid"); if (cl.hasOption("t")) contentTypes = cl.getOptionValues("t"); repositoryUniqueID = cl.hasOption("repositoryUniqueID") ? cl.getOptionValue("repositoryUniqueID") : DEFAULT_REPOSITORY_UNIQUE_ID; if (cl.hasOption("out-dir")) wadoWS.setOutputDirectory(new File(cl.getOptionValue("out-dir"))); kosAttr = cl.hasOption("f") ? new DicomInputStream(new FileInputStream(new File(cl.getOptionValue("f")))).readDataset(-1, -1) : toAttributes(cl.getOptionValue("study")); }
if (cli.hasOption(BULK_SHORT_OPTION)) { if (!this.checkArguments(args, 2, 2)) { throw new CommandTooManyArgumentsException(this, args); final URL bulk = Utils.toURL(cli.getOptionValue(BULK_SHORT_OPTION)); if ("file".equals(bulk.getProtocol())) { final File filePath = new File(bulk.toURI()); artifactAdministration.deployAndStartArtifacts(Utils.getUrls(filePath), cli.hasOption(SKIP_START_SHORT_OPTION)); } else { throw new CommandException(this, throw new CommandMissingArgumentException(this, e.getOption(), e); } catch (final MissingOptionException e) { throw new CommandMissingOptionsException(this, e.getMissingOptions(), e); } catch (final ParseException e) { throw new CommandInvalidException(this, e);
commandLine = new GnuParser().parse( options, args ); } catch ( MissingOptionException e ) { printError( options, e.getMessage() ); return; if ( commandLine.hasOption( HELP_OPTION ) ) { printHelp( options ); return; File destination = new File( commandLine.getOptionValue( OPTION_DESTINATION ) ); if ( !destination.isDirectory() ) { printError( options, "Destination <" + destination.getAbsolutePath() + "> is not a directory" ); String resourceDestValue = commandLine.getOptionValue( OPTION_RESOURCES_DESTINATION ); File resourcesDestination; if ( resourceDestValue == null ) {
options.addOption(outputDirOpt); if (line.hasOption(helpOpt.getLongOpt())) { printHelpAndExit(options); final String baseDir = line.getOptionValue(baseDirOpt.getLongOpt()); final String includes = line.getOptionValue(includeOpt.getLongOpt()); final String excludes = line.getOptionValue(excludeOpt.getLongOpt()); final File outputDir = new File(line.getOptionValue(outputDirOpt.getLongOpt())); System.err.println(e.getMessage()); printHelpAndExit(options); } catch (final UnrecognizedOptionException e) {
final List<Filter<Artifact>> filters = new ArrayList<>(); final CommandLine cli = this.clParser.parse(getOptions(), args); if (cli.getArgs().length > 0) { throw new CommandBadArgumentNumberException(this); if (cli.hasOption(TYPE_SHORT_OPTION)) { filters.add(new TypeFilter(cli.getOptionValue(TYPE_SHORT_OPTION))); if (cli.hasOption(REGEX_IDENTIFIER_SHORT_OPTION)) { throw new CommandMissingArgumentException(this, e.getOption(), e); } catch (final MissingOptionException e) { throw new CommandMissingOptionsException(this, e.getMissingOptions(), e); } catch (final ParseException e) { throw new CommandInvalidException(this, e);
msg = cl.getArgs(); if (msg.length == 0) { throw new ParseException("No message"); printHelp(new PrintWriter(stdout)); exitHandler.failureExit(this, "Bad command line. Missing option: " + moe.getMessage(), null, -2); return; //never reached } catch (ParseException pe) { if (!cl.hasOption("o")) { log = new AdvancedConsoleLogger(AdvancedConsoleLogger.LEVEL_ERROR, false, stderr, stderr); } else { int logLevel = AdvancedConsoleLogger.LEVEL_INFO; if (cl.hasOption('v')) { logLevel = AdvancedConsoleLogger.LEVEL_DEBUG;
if (cli.hasOption(PASSPHRASE_SHORT_OPTION)) { passPhrase = cli.getOptionValue(PASSPHRASE_SHORT_OPTION); } else if (!cli.getArgList().isEmpty()) { throw new CommandBadArgumentNumberException(this); } else { throw new CommandMissingArgumentException(this, e.getOption(), e); } catch (final MissingOptionException e) { throw new CommandMissingOptionsException(this, e.getMissingOptions(), e); } catch (final ParseException e) { throw new CommandInvalidException(this, e);
@SuppressWarnings("unchecked") public static void main(String[] args) { try { CommandLine cl = parseComandLine(args); DcmValidate main = new DcmValidate(); String iodFile = cl.getOptionValue("iod"); if (iodFile == null) throw new MissingOptionException(Arrays.asList("iod")); main.setIOD(IOD.load(iodFile)); List<String> fnames = cl.getArgList(); if (fnames.isEmpty()) throw new ParseException(rb.getString("missing")); for (String fname : fnames) validate(main, new File(fname)); } catch (ParseException e) { System.err.println("DcmValidate: " + e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (IOException e) { System.err.println("DcmValidate: " + e.getMessage()); System.exit(2); } }
try { CommandLine cmd = parser.parse(options, args); if (cmd.getOptions().length == 0 || cmd.hasOption("H")) { help(options); varDict.start(); } catch (MissingOptionException e) { List<?> missingOptions = e.getMissingOptions(); System.err.print("Missing required option(s): "); for (Iterator<?> iterator = missingOptions.iterator(); iterator.hasNext();) {
private static void checkOptions(CommandLine cl) throws ParseException { if (!cl.hasOption("b")) throw new MissingOptionException( CLIUtils.rb.getString("missing-bind-opt")); if (!cl.hasOption("c")) throw new MissingOptionException( CLIUtils.rb.getString("missing-connect-opt")); if (cl.hasOption("mpps") && cl.hasOption("mpps-late")) throw new ParseException(rb.getString("mpps-error")); }
System.out.println(e.getMessage()); printHelpForList(); return 1; boolean running = line.hasOption(RUNNING_OPTION.getOpt()); boolean scheduled = line.hasOption(SCHEDULED_OPTION.getOpt());
interfaceNameRegex); final boolean hasAnOutputFlag = cmd.hasOption(OUTPUT_ENDPOINTS_LONG_OPTION) || cmd.hasOption(OUTPUT_SERVICES_LONG_OPTION) || cmd.hasOption(OUTPUT_INTERFACES_LONG_OPTION); final boolean isOutputEndpoints = cmd.hasOption(OUTPUT_ENDPOINTS_LONG_OPTION) || !hasAnOutputFlag; final boolean isOutputServices = cmd.hasOption(OUTPUT_SERVICES_LONG_OPTION) || !hasAnOutputFlag; throw new CommandMissingArgumentException(this, e.getOption(), e); } catch (final MissingOptionException e) { throw new CommandMissingOptionsException(this, e.getMissingOptions(), e); } catch (final ParseException e) { throw new CommandInvalidException(this, e);
boolean override = false; for (Object tmp : cl.getOptions()) { Opt opt = (Opt)tmp; log.trace("Processing option: {}", opt); log.trace("Remaining arguments: {}", cl.getArgList()); for (final String arg : cl.getArgs()) { log.trace("Processing argument: {}", arg); throw new ProcessingException(Messages.REQUIRED_OPTION_MISSING.format(e.getMissingOptions()));