java.lang.Object
com.clumd.projects.java_common_utils.arg_parser.JavaArgParser
All Implemented Interfaces:
CLIArgParser

public class JavaArgParser extends Object implements CLIArgParser
A useful implementation of CLIArgParser with all basic features supported.
  • Constructor Details

    • JavaArgParser

      public JavaArgParser()
  • Method Details

    • parseFromCLI

      public Collection<Argument<Object>> parseFromCLI(@NonNull @NonNull Collection<Argument<?>> possibleArguments, @NonNull @NonNull String[] args) throws ParseException
      Description copied from interface: CLIArgParser
      As CLIArgParser.parseFromCLI(Collection, String[], boolean, boolean), but defaulting to false for ignoreUnknownCLIArgs and returnArgsWithDefaultButNotOnCLI
      Specified by:
      parseFromCLI in interface CLIArgParser
      Throws:
      ParseException
    • parseFromCLI

      public Collection<Argument<Object>> parseFromCLI(@NonNull @NonNull Collection<Argument<?>> possibleArguments, @NonNull @NonNull String[] args, boolean ignoreUnknownCLIArgs, boolean returnArgsWithDefaultButNotOnCLI) throws ParseException
      Description copied from interface: CLIArgParser
      Used to execute the parsing process of Command line arguments into validated program input.
      Specified by:
      parseFromCLI in interface CLIArgParser
      Parameters:
      possibleArguments - The collection of all possible Command Line Arguments this process MAY receive.
      args - The CLI Args provided to the JVM for this process
      ignoreUnknownCLIArgs - 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 the Arguments failed to parse.
    • setBoilerplate

      public void setBoilerplate(@NonNull @NonNull String name, @NonNull @NonNull String usageSyntax, @NonNull @NonNull String synopsis, @NonNull @NonNull String author, @NonNull @NonNull String bugs)
      Description copied from interface: CLIArgParser
      Used to set all the Strings which should be used if printing help text.
      Specified by:
      setBoilerplate in interface CLIArgParser
      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

      public String getBoilerplate(@NonNull @NonNull Collection<Argument<?>> forArguments) throws ParseException
      Description copied from interface: CLIArgParser
      Used to get the boilerplate message that can be used to print to the CLI with the relevant argument options and their usage descriptions.
      Specified by:
      getBoilerplate in interface CLIArgParser
      Parameters:
      forArguments - The collection of arguments the boilerplate should display in the message
      Returns:
      The fully formed String description of this Application
      Throws:
      ParseException