mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-06-18 15:50:28 +00:00
added scheduling support
added remind command added support for parameters with spaces (they are contained by ") fixed support for remainder parameters added maxlength support for parameters added ability to embed templates, to have a text as well moved properties to a more appropriate position added method do parse a duration
This commit is contained in:
@@ -11,4 +11,5 @@ public class Parameter {
|
||||
private String description;
|
||||
private boolean optional;
|
||||
private boolean remainder;
|
||||
private Integer maxLength;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,38 @@
|
||||
package dev.sheldan.abstracto.command.meta;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
public class UnParsedCommandParameter {
|
||||
|
||||
private static Pattern SPLIT_REGEX = Pattern.compile("\"([^\"]*)\"|(\\S+)");
|
||||
|
||||
public UnParsedCommandParameter(String parameters) {
|
||||
this.parameters = new ArrayList<>();
|
||||
Matcher m = SPLIT_REGEX.matcher(parameters);
|
||||
boolean skippedCommand = false;
|
||||
while (m.find()) {
|
||||
if(!skippedCommand) {
|
||||
skippedCommand = true;
|
||||
continue;
|
||||
}
|
||||
if (m.group(1) != null) {
|
||||
String group = m.group(1);
|
||||
if(!group.equals("")) {
|
||||
this.parameters.add(group);
|
||||
}
|
||||
} else {
|
||||
String group = m.group(2);
|
||||
if(!group.equals("")) {
|
||||
this.parameters.add(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private List<String> parameters;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user