Parameter.java revision 58a4af720c30d8dba072a96e3713577c8d30aeae
1/** 2 * Copyright (C) 2010 the original author or authors. 3 * See the notice.md file distributed with this work for additional 4 * information regarding copyright ownership. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19package com.beust.jcommander; 20 21import static java.lang.annotation.ElementType.FIELD; 22 23import com.beust.jcommander.converters.NoConverter; 24 25import java.lang.annotation.Retention; 26import java.lang.annotation.Target; 27 28@Retention(java.lang.annotation.RetentionPolicy.RUNTIME) 29@Target({ FIELD }) 30public @interface Parameter { 31 32 /** 33 * An array of allowed command line parameters (e.g. "-d", "--outputdir", etc...). 34 * If this attribute is omitted, the field it's annotating will receive all the 35 * unparsed options. There can only be at most one such annotation. 36 */ 37 String[] names() default {}; 38 39 /** 40 * A description of this option. 41 */ 42 String description() default ""; 43 44 /** 45 * Whether this option is required. 46 */ 47 boolean required() default false; 48 49 /** 50 * The key used to find the string in the message bundle. 51 */ 52 String descriptionKey() default ""; 53 54 /** 55 * How many parameter values this parameter will consume. For example, 56 * an arity of 2 will allow "-pair value1 value2". 57 */ 58 int arity() default -1; 59 60 /** 61 * If true, this parameter is a password and it will be prompted on the console 62 * (if available). 63 */ 64 boolean password() default false; 65 66 /** 67 * The string converter to use for this field. 68 */ 69 Class<? extends IStringConverter<?>> converter() default NoConverter.class; 70 71 /** 72 * If true, this parameter won't appear in the usage(). 73 */ 74 boolean hidden() default false; 75} 76