ArgNameFormat.java
package net.morimekta.terminal.args;
import net.morimekta.strings.NamingUtil;
import net.morimekta.strings.StringUtil;
public enum ArgNameFormat {
LISP("-", NamingUtil.Format.LISP, false),
SNAKE("_", NamingUtil.Format.SNAKE, false),
CAMEL("", NamingUtil.Format.CAMEL, true);
private final String sep;
private final NamingUtil.Format nameFormat;
private final boolean capitalizeName;
ArgNameFormat(String sep, NamingUtil.Format nameFormat, boolean capitalizeName) {
this.sep = sep;
this.nameFormat = nameFormat;
this.capitalizeName = capitalizeName;
}
public String format(String name) {
return NamingUtil.format(name, nameFormat);
}
public String join(String prefix, String name) {
if (prefix.isEmpty()) {
return name;
}
if (capitalizeName) {
return prefix + sep + StringUtil.capitalize(name);
} else {
return prefix + sep + name;
}
}
}