Coverage Report - joptsimple.OptionDeclarer
 
Classes in this File Line Coverage Branch Coverage Complexity
OptionDeclarer
N/A
N/A
1
 
 1  
 package joptsimple;
 2  
 
 3  
 import java.util.List;
 4  
 
 5  
 /**
 6  
  * Trains the option parser. This interface aids integration that disposes declaration of options but not actual
 7  
  * command-line parsing.
 8  
  *
 9  
  * Typical use is for another class to implement {@code OptionDeclarer} as a facade, forwarding calls to an
 10  
  * {@code OptionParser} instance.
 11  
  *
 12  
  * Note that although this is an interface, the returned values of calls are concrete jopt-simple classes.
 13  
  *
 14  
  * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
 15  
  * @see OptionParser
 16  
  * @since 4.6
 17  
  */
 18  
 public interface OptionDeclarer {
 19  
     /**
 20  
      * Tells the parser to recognize the given option.
 21  
      *
 22  
      * <p>This method returns an instance of {@link OptionSpecBuilder} to allow the formation of parser directives
 23  
      * as sentences in a fluent interface language. For example:</p>
 24  
      *
 25  
      * <pre><code>
 26  
      *   OptionDeclarer parser = new OptionParser();
 27  
      *   parser.<strong>accepts( "c" )</strong>.withRequiredArg().ofType( Integer.class );
 28  
      * </code></pre>
 29  
      *
 30  
      * <p>If no methods are invoked on the returned {@link OptionSpecBuilder}, then the parser treats the option as
 31  
      * accepting no argument.</p>
 32  
      *
 33  
      * @param option the option to recognize
 34  
      * @return an object that can be used to flesh out more detail about the option
 35  
      * @throws OptionException if the option contains illegal characters
 36  
      * @throws NullPointerException if the option is {@code null}
 37  
      */
 38  
     OptionSpecBuilder accepts( String option );
 39  
 
 40  
     /**
 41  
      * Tells the parser to recognize the given option.
 42  
      *
 43  
      * @see #accepts(String)
 44  
      * @param option the option to recognize
 45  
      * @param description a string that describes the purpose of the option. This is used when generating help
 46  
      * information about the parser.
 47  
      * @return an object that can be used to flesh out more detail about the option
 48  
      * @throws OptionException if the option contains illegal characters
 49  
      * @throws NullPointerException if the option is {@code null}
 50  
      */
 51  
     OptionSpecBuilder accepts( String option, String description );
 52  
 
 53  
     /**
 54  
      * Tells the parser to recognize the given options, and treat them as synonymous.
 55  
      *
 56  
      * @see #accepts(String)
 57  
      * @param options the options to recognize and treat as synonymous
 58  
      * @return an object that can be used to flesh out more detail about the options
 59  
      * @throws OptionException if any of the options contain illegal characters
 60  
      * @throws NullPointerException if the option list or any of its elements are {@code null}
 61  
      */
 62  
     OptionSpecBuilder acceptsAll( List<String> options );
 63  
 
 64  
     /**
 65  
      * Tells the parser to recognize the given options, and treat them as synonymous.
 66  
      *
 67  
      * @see #acceptsAll(List)
 68  
      * @param options the options to recognize and treat as synonymous
 69  
      * @param description a string that describes the purpose of the option.  This is used when generating help
 70  
      * information about the parser.
 71  
      * @return an object that can be used to flesh out more detail about the options
 72  
      * @throws OptionException if any of the options contain illegal characters
 73  
      * @throws NullPointerException if the option list or any of its elements are {@code null}
 74  
      * @throws IllegalArgumentException if the option list is empty
 75  
      */
 76  
     OptionSpecBuilder acceptsAll( List<String> options, String description );
 77  
 
 78  
     /**
 79  
      * Gives an object that represents an access point for non-option arguments on a command line.
 80  
      *
 81  
      * @return an object that can be used to flesh out more detail about the non-option arguments
 82  
      */
 83  
     NonOptionArgumentSpec<String> nonOptions();
 84  
 
 85  
     /**
 86  
      * Gives an object that represents an access point for non-option arguments on a command line.
 87  
      *
 88  
      * @see #nonOptions()
 89  
      * @param description a string that describes the purpose of the non-option arguments. This is used when generating
 90  
      * help information about the parser.
 91  
      * @return an object that can be used to flesh out more detail about the non-option arguments
 92  
      */
 93  
     NonOptionArgumentSpec<String> nonOptions( String description );
 94  
 
 95  
     /**
 96  
      * Tells the parser whether or not to behave "POSIX-ly correct"-ly.
 97  
      *
 98  
      * @param setting {@code true} if the parser should behave "POSIX-ly correct"-ly
 99  
      */
 100  
     void posixlyCorrect( boolean setting );
 101  
 
 102  
     /**
 103  
      * <p>Tells the parser to treat unrecognized options as non-option arguments.</p>
 104  
      *
 105  
      * <p>If not called, then the parser raises an {@link OptionException} when it encounters an unrecognized
 106  
      * option.</p>
 107  
      */
 108  
     void allowsUnrecognizedOptions();
 109  
 
 110  
     /**
 111  
      * Tells the parser either to recognize or ignore <kbd>"-W"</kbd>-style long options.
 112  
      *
 113  
      * @param recognize {@code true} if the parser is to recognize the special style of long options
 114  
      */
 115  
     void recognizeAlternativeLongOptions( boolean recognize );
 116  
 }