Class InputTokenizer
java.lang.Object
com.github.alex1304.ultimategdbot.api.utils.InputTokenizer
public class InputTokenizer
extends java.lang.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,java.util.List<java.lang.String>> tokenize(java.lang.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:
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
-