001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package gov.nist.secauto.metaschema.cli.processor.command; 007 008import gov.nist.secauto.metaschema.cli.processor.command.impl.DefaultExtraArgument; 009 010import edu.umd.cs.findbugs.annotations.NonNull; 011 012/** 013 * A representation of an extra, non-option command line argument. 014 */ 015public interface ExtraArgument { 016 /** 017 * Create a new extra argument instance. 018 * 019 * @param name 020 * the argument name 021 * @param required 022 * {@code true} if the argument is required, or {@code false} otherwise 023 * @return the instance 024 */ 025 @NonNull 026 static ExtraArgument newInstance(@NonNull String name, boolean required) { 027 if (name.isBlank()) { 028 throw new IllegalArgumentException("name cannot be empty or blank"); 029 } 030 return new DefaultExtraArgument(name, required); 031 } 032 033 /** 034 * Get the argument name. 035 * 036 * @return the name 037 */ 038 String getName(); 039 040 /** 041 * Get if the argument is required. 042 * 043 * @return {@code true} if the argument is required, or {@code false} otherwise 044 */ 045 boolean isRequired(); 046 047 /** 048 * Get the allow number of arguments of this type. 049 * 050 * @return the allowed number of arguments as a positive number or {@code -1} 051 * for unlimited 052 */ 053 default int getNumber() { 054 return 1; 055 } 056}