Inceptum/src/main/java/io/gitlab/jfronny/inceptum/cli/Command.java

36 lines
804 B
Java
Raw Normal View History

2021-10-30 22:05:24 +02:00
package io.gitlab.jfronny.inceptum.cli;
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;
}
public abstract void invoke(CommandArguments args);
2021-10-30 22:05:24 +02:00
}