001/*
002  Licensed to the Apache Software Foundation (ASF) under one or more
003  contributor license agreements.  See the NOTICE file distributed with
004  this work for additional information regarding copyright ownership.
005  The ASF licenses this file to You under the Apache License, Version 2.0
006  (the "License"); you may not use this file except in compliance with
007  the License.  You may obtain a copy of the License at
008
009      http://www.apache.org/licenses/LICENSE-2.0
010
011  Unless required by applicable law or agreed to in writing, software
012  distributed under the License is distributed on an "AS IS" BASIS,
013  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014  See the License for the specific language governing permissions and
015  limitations under the License.
016 */
017package Apache.CLI;
018
019/** Thrown when an option requiring an argument is not provided with an argument. */
020@Torello.JavaDoc.JDHeaderBackgroundImg(EmbedTagFileID="LICENSE")
021public class MissingArgumentException extends ParseException
022{
023    // SVUID
024    private static final long serialVersionUID = 1;
025
026    // The option requiring additional arguments
027    private Option option;
028
029    /**
030     * Constructs a new {@code MissingArgumentException} with the specified detail message.
031     * @param option the option requiring an argument
032     */
033    public MissingArgumentException(final Option option)
034    {
035        this("Missing argument for option: " + option.getKey());
036        this.option = option;
037    }
038
039    /**
040     * Constructs a new {@code MissingArgumentException} with the specified detail message.
041     * @param message the detail message
042     */
043    public MissingArgumentException(final String message)
044    { super(message); }
045
046    /**
047     * Return the option requiring an argument that wasn't provided on the command line.
048     * @return the related option
049     */
050    public Option getOption()
051    { return option; }
052}