private void processArguments( final String[] args )
			throws CommandException {
		log.debug( "processing arguments: " + Strings.join( args, "," ) );

		if ( args.length == 0 ) {
			throw new CommandException( "Command requires arguments" );
		}

		String sopts = "-:cf:";
		LongOpt[] lopts =
				{
						new LongOpt( "count", LongOpt.NO_ARGUMENT, null, 'c' ),
						new LongOpt( "filter", LongOpt.REQUIRED_ARGUMENT, null, 'f' ),
				};

		Getopt getopt = new Getopt( null, args, sopts, lopts );
		getopt.setOpterr( false );

		int code;
		int argidx = 0;

		while ( ( code = getopt.getopt() ) != -1 ) {
			switch ( code ) {
				case ':':
					throw new CommandException
							( "Option requires an argument: " + args[getopt.getOptind() - 1] );

				case '?':
					throw new CommandException
							( "Invalid (or ambiguous) option: " + args[getopt.getOptind() - 1] );

					// non-option arguments
				case 1: {
					String arg = getopt.getOptarg();

					switch ( argidx++ ) {
						case 0:
							query = arg;
							log.debug( "query: " + query );
							break;

						default:
							throw new CommandException( "Unused argument: " + arg );
					}
					break;
				}

				// Show count
				case 'c':
					displayCount = true;
					break;

				case 'f':
					filter = getopt.getOptarg();
					log.debug( "filter: " + filter );
					break;
			}
		}
	}