1 /*
2 * SPDX-FileCopyrightText: none
3 * SPDX-License-Identifier: CC0-1.0
4 */
5
6 package gov.nist.secauto.metaschema.cli.processor.command;
7
8 import gov.nist.secauto.metaschema.cli.processor.command.impl.DefaultExtraArgument;
9
10 import edu.umd.cs.findbugs.annotations.NonNull;
11
12 /**
13 * A representation of an extra, non-option command line argument.
14 */
15 public interface ExtraArgument {
16 /**
17 * Create a new extra argument instance.
18 *
19 * @param name
20 * the argument name
21 * @param required
22 * {@code true} if the argument is required, or {@code false} otherwise
23 * @return the instance
24 */
25 @NonNull
26 static ExtraArgument newInstance(@NonNull String name, boolean required) {
27 if (name.isBlank()) {
28 throw new IllegalArgumentException("name cannot be empty or blank");
29 }
30 return new DefaultExtraArgument(name, required);
31 }
32
33 /**
34 * Get the argument name.
35 *
36 * @return the name
37 */
38 String getName();
39
40 /**
41 * Get if the argument is required.
42 *
43 * @return {@code true} if the argument is required, or {@code false} otherwise
44 */
45 boolean isRequired();
46
47 /**
48 * Get the allow number of arguments of this type.
49 *
50 * @return the allowed number of arguments as a positive number or {@code -1}
51 * for unlimited
52 */
53 default int getNumber() {
54 return 1;
55 }
56 }