2021-10-30 22:05:24 +02:00
|
|
|
package io.gitlab.jfronny.inceptum.cli;
|
|
|
|
|
2021-10-31 16:59:25 +01:00
|
|
|
import io.gitlab.jfronny.inceptum.model.inceptum.CommandArguments;
|
|
|
|
|
2021-10-30 22:05:24 +02:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
public abstract class Command {
|
|
|
|
private final String help;
|
|
|
|
private final List<String> aliases;
|
|
|
|
|
|
|
|
public Command(String help, String... aliases) {
|
|
|
|
this.help = help;
|
|
|
|
this.aliases = Arrays.asList(aliases);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAlias(String text) {
|
|
|
|
return aliases.contains(text.replaceAll("^[-/]*", "").toLowerCase(Locale.ROOT));
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
return aliases.get(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getHelp() {
|
|
|
|
return help;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean enableLog() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-10-31 16:59:25 +01:00
|
|
|
public abstract void invoke(CommandArguments args);
|
2021-10-30 22:05:24 +02:00
|
|
|
}
|