browserl.ist.Main Maven / Gradle / Ivy
The newest version!
package browserl.ist;
import com.beust.jcommander.IStringConverter;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
/**
*
* @author Kent Yeh
*/
public class Main implements Runnable {
public static class PatternConverter implements IStringConverter {
@Override
public Pattern convert(String string) {
return Pattern.compile(string);
}
}
public Main() {
this.paramBs = new ArrayList<>();
}
@Parameter(names = {"--browser", "-b"}, description = "http://browserl.ist, e,g.: -b defaults -b iOS10.1 -b \"not IE<9\" -b \"last 2 versions\" -b \"> 1%\" -b \">= 5% in TW\"...")
private final List paramBs;
@Override
public void run() {
boolean odd = false;
StringBuilder sb = new StringBuilder();
for (Browser browser : new CanIUse().queryBrwosers(paramBs.toArray(new String[paramBs.size()]))) {
String s40 = " ";
if (odd) {
sb.append(browser.toString()).append("\n");
odd = !odd;
} else {
odd = !odd;
sb.append(browser.toString()).append(s40.substring(browser.toString().length()));
}
}
System.out.println(sb.toString());
}
public static void main(String[] args) throws IOException {
final Main main = new Main();
JCommander jcmd = new JCommander(main, args);
if (main.paramBs.isEmpty()) {
jcmd.usage();
} else {
main.run();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy