From f09e0ce8f7d2b2bca377e90d23b3c2356633d9d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Thu, 14 Jan 2021 11:28:48 +0100 Subject: [PATCH] :books: Document compound arguments --- docs/README.adoc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/README.adoc b/docs/README.adoc index d2cc5613..a9f661c7 100644 --- a/docs/README.adoc +++ b/docs/README.adoc @@ -255,6 +255,35 @@ non-liberal:: Accepts only "true" and "false" ===== compound arguments +Compound arguments are a special type of arguments that consists of multiple other arguments. +By default, 2 or 3 arguments may be used in a compound argument. + +The methods for creating compounds arguments can be found in CommandManager, or in the +https://javadoc.commandframework.cloud/cloud/commandframework/arguments/compound/ArgumentPair.html[ArgumentPair] +or +https://javadoc.commandframework.cloud/cloud/commandframework/arguments/compound/ArgumentTriplet.html[ArgumentTriplet] +classes. + +In general, they need a tuple of names, and a tuple of argument types. They can also +take in a mapping function which maps the value to a more user-friendly type. + +[title="Argument triplet mapping to a vector"] +==== +[source,java] +---- +commandBuilder.argumentTriplet( + "coords", + TypeToken.get(Vector.class), + Triplet.of("x", "y", "z"), + Triplet.of(Integer.class, Integer.class, Integer.class), + (sender, triplet) -> new Vector(triplet.getFirst(), triplet.getSecond(), + triplet.getThird() + ), + Description.of("Coordinates") +) +---- +==== + ==== Custom ==== Flags