Interface Flag
-
public interface Flag
Represents a flag on aCommand
A flag is a parameter is either:
- a single dash, follows by a single character (e.g.
-a
, or - two dashes, followed by multiple characters (e.g.
--all
).
In both cases, a flag may have an execution requirement upon them restricting who may use the flag (typically a permission) and/or an associated
Parameter
that occurs after the flag definition, which may or may not be optional. Flags may be specified more than once in a command string, but may only appear at the beginning of aCommand
. ForParameter.Subcommand
s, this is directly after the literal which starts that subcommand.To check whether the flag was specified in the command, call
CommandContext.flagInvocationCount(String)
, where the string is a flag's alias without the preceding dashes. - a single dash, follows by a single character (e.g.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Flag.Builder
A builder for creatingFlag
s.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Collection<String>
aliases()
Gets the aliases that this flag will act upon.Optional<Parameter>
associatedParameter()
Gets theParameter
that should be parsed if this flag is invoked.static Flag.Builder
builder()
Gets aFlag.Builder
for creating aFlag
static Flag
of(String... aliases)
Create a new, parameter-lessFlag
with the supplied aliases.static Flag
of(Parameter parameter, String... aliases)
Create a newFlag
with the supplied parameter and aliases.Predicate<CommandCause>
requirement()
Gets thePredicate
that will be checked in order for this flag to be usable by aCommandCause
Collection<String>
unprefixedAliases()
Gets the aliases that were supplied to this flag.
-
-
-
Method Detail
-
builder
static Flag.Builder builder()
Gets aFlag.Builder
for creating aFlag
- Returns:
- A
Flag.Builder
-
of
static Flag of(String... aliases)
Create a new, parameter-lessFlag
with the supplied aliases.- Parameters:
aliases
- Flag aliases- Returns:
- A new
Flag
-
of
static Flag of(Parameter parameter, String... aliases)
Create a newFlag
with the supplied parameter and aliases.- Parameters:
parameter
- The parameter to parse after this flagaliases
- Flag aliases- Returns:
- A new
Flag
-
unprefixedAliases
Collection<String> unprefixedAliases()
Gets the aliases that were supplied to this flag.Aliases returned here will not be prefixed with the appropriate dashes.
- Returns:
- The aliases.
-
aliases
Collection<String> aliases()
Gets the aliases that this flag will act upon.Aliases returned here will be prefixed with the appropriate dashes.
- Returns:
- The aliases.
-
requirement
Predicate<CommandCause> requirement()
Gets thePredicate
that will be checked in order for this flag to be usable by aCommandCause
- Returns:
- The
Predicate
-
-