/** * Handles an unknown token. If the token starts with a dash an * UnrecognizedOptionException is thrown. Otherwise the token is added * to the arguments of the command line. If the stopAtNonOption flag * is set, this stops the parsing and the remaining tokens are added * as-is in the arguments of the command line. * * @param token the command line token to handle */ private void handleUnknownToken(String token) throws ParseException { if (token.startsWith("-") && token.length() > 1 && !stopAtNonOption) { throw new UnrecognizedOptionException("Unrecognized option: " + token, token); } cmd.addArg(token); if (stopAtNonOption) { skipParsing = true; } }
if (opt == null) throw new UnrecognizedOptionException("Default option wasn't defined", option);
if (opt == null) throw new UnrecognizedOptionException("Default option wasn't defined", option);
throw new UnrecognizedOptionException("Unrecognized option: " + arg, arg);
@Override public void execute(CommandLine options) throws Exception { String[] args = options.getArgs(); if (args.length < min) { throw new MissingArgumentException("missing required arguments"); } if (args.length > max) { throw new UnrecognizedOptionException("unknown extra argument \"" + args[max] + "\""); } } }
private ReservationACL getReservationACLFromAuditConstant( String auditConstant) throws YarnException{ if (auditConstant.equals(AuditConstants.SUBMIT_RESERVATION_REQUEST)) { return ReservationACL.SUBMIT_RESERVATIONS; } else if (auditConstant.equals(AuditConstants.LIST_RESERVATION_REQUEST)) { return ReservationACL.LIST_RESERVATIONS; } else if (auditConstant.equals(AuditConstants.DELETE_RESERVATION_REQUEST) || auditConstant.equals(AuditConstants.UPDATE_RESERVATION_REQUEST)) { return ReservationACL.ADMINISTER_RESERVATIONS; } else { String error = "Audit Constant " + auditConstant + " is not recognized."; LOG.error(error); throw RPCUtil.getRemoteException(new UnrecognizedOptionException(error)); } }
/** * Handles an unknown token. If the token starts with a dash an * UnrecognizedOptionException is thrown. Otherwise the token is added * to the arguments of the command line. If the stopAtNonOption flag * is set, this stops the parsing and the remaining tokens are added * as-is in the arguments of the command line. * * @param token the command line token to handle */ private void handleUnknownToken(String token) throws ParseException { if (token.startsWith("-") && token.length() > 1 && !stopAtNonOption) { throw new UnrecognizedOptionException("Unrecognized option: " + token, token); } cmd.addArg(token); if (stopAtNonOption) { skipParsing = true; } }
/** * Verifies that the properties don't contain undefined options which will * cause the base parser to blowup. * * @param options the options config * @param properties overriding properties * @throws UnrecognizedOptionException if a property exists that isn't * configured in the options. */ protected void validateProperties(Options options, Properties properties) throws UnrecognizedOptionException { if (properties != null) { for (Entry<Object, Object> e : properties.entrySet()) { String arg = (String) e.getKey(); boolean hasOption = options.hasOption(arg); if (!hasOption) { throw new UnrecognizedOptionException( "Unrecognized option: " + arg, arg); } } } }
if (!token.startsWith("--") && !token.startsWith("-")) { if (stopAtNonOption) { throw new UnrecognizedOptionException("Unrecognized option: " + token +". Every option must start with '--' or '-'", token);
if (opt == null) throw new UnrecognizedOptionException("Default option wasn't defined", option);
cmd = parser.parse(options, args); if (cmd.getArgs().length > 0) { throw new UnrecognizedOptionException( "Extra arguments were provided in " + Arrays.asList(args));
cmd = parser.parse(options, args); if (cmd.getArgs().length > 0) { throw new UnrecognizedOptionException( "Extra arguments were provided in " + Arrays.asList(args));
if (opt == null) throw new UnrecognizedOptionException("Default option wasn't defined", option);
String msg = "Unrecognized command or option: " + first; System.out.println(msg); throw new UnrecognizedOptionException(msg);
throw new UnrecognizedOptionException("Unrecognized option '" + shortName + "'", shortName);
throw new UnrecognizedOptionException("Unrecognized option: " + arg);
throw new UnrecognizedOptionException("Unrecognized option: " + arg);
throw new UnrecognizedOptionException("Unrecognized option: " + arg, arg);
throw new UnrecognizedOptionException("Unrecognized option: " + arg, arg);
throw new UnrecognizedOptionException("Unrecognized option: " + arg, arg);