Lanat Help

Tuples

Tuples are characters that basically define delimiters for a group of values. They usually help to make the values to forward to the argument both more readable, and explicit.

$ my-program --values [5 2 3]

In this example, the values 5, 2, and 3 are grouped together by the square brackets [ and ]. The square brackets are the tuple characters.

Changing the tuple characters

  1. Before parsing the arguments, you can change the tuple characters to use by setting the TupleChar#current property.

    TupleChar.current = TupleChar.PARENTHESIS;
  2. Now, the tuple characters are set to the parenthesis characters (( and )):

    $ my-program --values (5 2 3)

Uses of tuples

Sometimes Lanat cannot tell exactly if some token is a value or another kind of token, like a sub-command (if the names happen to match). Lanat will always prioritize (if possible) to assume that the token is any other kind of token than a value. This is where tuples can help.

Tuples also improve the readability of the input, making it easier to understand which values is each argument receiving.

Case

  • Assume there is a values argument that can take from 2 to 5 strings. There is also a sub-command with the name example:

    $ my-program --values 5 2 3 example

    In this case, Lanat will assume that 5, 2 and 3 are values, and example a sub-command, since values is already satisfied with 3 values.

    In order for example to be considered a value, you can use tuples:

    $ my-program --values [5 2 3 example]
Last modified: 03 October 2024