Class InputTokenizer

java.lang.Object
com.github.alex1304.ultimategdbot.api.utils.InputTokenizer

public class InputTokenizer
extends Object
Utility methods to split an input into tokens and recognize which are flags and which are arguments.
  • Method Details

    • tokenize

      public static reactor.util.function.Tuple2<FlagSet,​List<String>> tokenize​(String flagPrefix, String input)
      Splits the input into tokens. A token is delimited by double quotes or by whitespaces if there are none. A whitespace character can be escaped using a backslash to indicate that it should not delimit a token, and a double quote can be escaped the same way to indicate that it is intended to be a litteral character and not a token delimiter. Once tokens are extracted, they are separated into flags and arguments. A token starting with "--" followed by at least 1 character is treated as a flag, the rest are arguments.
      Parameters:
      flagPrefix - the prefix used to introduce command flags
      input - the input to tokenize
      Returns:
      a Tuple2 which first value is a FlagSet that contains the tokens that are flags, and second value is a List containing the tokens that are arguments