All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.snapscript.studio.agent.local.LocalProcess Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
package org.snapscript.studio.agent.local;

import java.io.File;
import java.util.List;

import org.snapscript.studio.agent.cli.CommandLine;
import org.snapscript.studio.agent.cli.CommandLineBuilder;
import org.snapscript.studio.agent.cli.CommandLineUsage;
import org.snapscript.studio.agent.cli.CommandOption;
import org.snapscript.studio.agent.core.ClassPathUpdater;

public class LocalProcess {
   
   private static final String WARNING = "Could not find classpath entry %s";

   public static void main(String[] arguments) throws Exception {
      CommandLineBuilder builder = LocalOption.getBuilder();
      CommandLine line = builder.build(arguments);
      List options = line.getOptions();
      LocalCommandLine local = new LocalCommandLine(line);
      LocalProcessExecutor executor = new LocalProcessExecutor();
      List classpath = local.getClasspath();
      boolean debug = local.isDebug();

      if(local.isVersion()) {
         String version = LocalVersion.getVersion();
         System.err.println(version);
         System.err.flush();
         System.exit(0);
      }

      try {
         if(classpath != null) {
            for(File dependency : classpath) {
               if(!dependency.exists()) {
                  String warning = String.format(WARNING, dependency);
                  CommandLineUsage.usage(options, warning);
               }
            }
            ClassPathUpdater.updateClassPath(classpath, debug);
         }
      }catch(Exception cause) {
         String message = cause.getMessage();
         CommandLineUsage.usage(options, message);
      }
      executor.execute(local);
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy