Interface CLIArgParser
- All Known Implementing Classes:
JavaArgParser
public interface CLIArgParser
This represents the implementation of a class capable of parsing
Arguments from the command line.-
Method Summary
Modifier and TypeMethodDescriptiongetBoilerplate(@NonNull Collection<Argument<?>> forArguments) Used to get the boilerplate message that can be used to print to the CLI with the relevant argument options and their usage descriptions.parseFromCLI(@NonNull Collection<Argument<?>> possibleArguments, @NonNull String[] args) AsparseFromCLI(Collection, String[], boolean, boolean), but defaulting to false forignoreUnknownCLIArgsandreturnArgsWithDefaultButNotOnCLIparseFromCLI(@NonNull Collection<Argument<?>> possibleArguments, @NonNull String[] args, boolean ignoreUnknownCLIArgs, boolean returnArgsWithDefaultButNotOnCLI) Used to execute the parsing process of Command line arguments into validated program input.voidsetBoilerplate(@NonNull String name, @NonNull String usageSyntax, @NonNull String synopsis, @NonNull String author, @NonNull String bugs) Used to set all the Strings which should be used if printing help text.
-
Method Details
-
parseFromCLI
Map<String,Argument<Object>> parseFromCLI(@NonNull @NonNull Collection<Argument<?>> possibleArguments, @NonNull @NonNull String[] args, boolean ignoreUnknownCLIArgs, boolean returnArgsWithDefaultButNotOnCLI) throws ParseException Used to execute the parsing process of Command line arguments into validated program input.- Parameters:
possibleArguments- The collection of all possible Command Line Arguments this process MAY receive.args- The CLI Args provided to the JVM for this processignoreUnknownCLIArgs- Used to determine whether we should ignore parts of the provided CLI args which we were not expecting, or throw a preventative exception.returnArgsWithDefaultButNotOnCLI- Used to determine whether the returned collection of Args, should INCLUDE args which are marked as having default values, but which were not provided on the CLI- Returns:
- The collection of Arguments which IS present on the CLI, along with parsed values to the options, if relevant and present.
- Throws:
ParseException- Thrown if any of theArguments failed to parse.
-
parseFromCLI
Map<String,Argument<Object>> parseFromCLI(@NonNull @NonNull Collection<Argument<?>> possibleArguments, @NonNull @NonNull String[] args) throws ParseException AsparseFromCLI(Collection, String[], boolean, boolean), but defaulting to false forignoreUnknownCLIArgsandreturnArgsWithDefaultButNotOnCLI- Throws:
ParseException
-
setBoilerplate
void setBoilerplate(@NonNull @NonNull String name, @NonNull @NonNull String usageSyntax, @NonNull @NonNull String synopsis, @NonNull @NonNull String author, @NonNull @NonNull String bugs) Used to set all the Strings which should be used if printing help text.- Parameters:
name- The Name of the running application.usageSyntax- The acceptable syntax which should be used to invoke an instance of this program.synopsis- A short description to explain what the running application does.author- Who wrote the primary running application.bugs- Where anyone using your software should report their bugs to.
-
getBoilerplate
Used to get the boilerplate message that can be used to print to the CLI with the relevant argument options and their usage descriptions.- Parameters:
forArguments- The collection of arguments the boilerplate should display in the message- Returns:
- The fully formed String description of this Application
- Throws:
ParseException
-