Beispiel #1
0
 private static void showHelpAndExit(
     final Context context, final boolean headers, final List<CompileParameter> parameters) {
   if (headers) {
     context.show("DSL Platform - Command-Line Client (" + Main.getVersion() + ")");
     context.show(
         "This tool allows you to compile provided DSL to various languages such as Java, Scala, PHP, C#, etc... or create an SQL migration between two DSL models.");
   }
   context.show();
   context.show();
   context.show("Command parameters:");
   int max = 0;
   for (final CompileParameter cp : parameters) {
     if (cp.getShortDescription() == null) {
       continue;
     }
     int width = cp.getAlias().length();
     if (cp.getUsage() != null) {
       width += 1 + cp.getUsage().length();
     }
     if (max < width) {
       max = width;
     }
   }
   max += 2;
   for (final CompileParameter cp : parameters) {
     if (cp.getShortDescription() == null) {
       continue;
     }
     final StringBuilder sb = new StringBuilder();
     sb.append(" -").append(cp.getAlias());
     int len = max - cp.getAlias().length();
     if (cp.getUsage() != null) {
       sb.append("=").append(cp.getUsage());
       len -= cp.getUsage().length() + 1;
     }
     for (; len >= 0; len--) {
       sb.append(' ');
     }
     sb.append(cp.getShortDescription());
     context.show(sb.toString());
   }
   context.show();
   context.show("Example usages:");
   context.show("\ttarget=java_client,revenj.java postgres=localhost/Database?user=postgres");
   context.show(
       "\tjava_client=model.jar revenj.net=Model.dll postgres=localhost/Database?user=postgres");
   context.show("\tproperties=development.props download");
 }