/**
   * Starts an interactive command loop for sending job commands to the cluster using current active
   * cluster definition.
   */
  public static void main(String[] args) throws IOException {
    // ./run org.sd.cluster.config.JobAdmin

    final PropertiesParser pp = new PropertiesParser(args, true);
    final Properties properties = pp.getProperties();
    final ClusterRunner cr = new ClusterRunner(true /*useActiveCluster*/, properties);
    // final String user = cr.getUser();
    final ClusterDefinition clusterDef = cr.getClusterDefinition();
    final JobAdmin jobAdmin = new JobAdmin(clusterDef, 10000);
    final String cmdFile = properties != null ? properties.getProperty("cmdFile") : null;
    final CommandInterpreter interp = new CommandInterpreter(jobAdmin, cmdFile);

    interp.setVar("prompt", "jobcmd> ");
    interp.setVar("user", clusterDef.getUser());
    interp.setVar("defName", clusterDef.getDefinitionName());
    interp.setVar("machines", concat(clusterDef.getMachines(), ", "));

    jobAdmin.init();
    if (cmdFile != null) {
      interp.init(); // just run commands in command file
    } else {
      interp.init();
      interp.start(); // start interactive interpreter
    }
    jobAdmin.shutdown();
  }
  /**
   * Starts an interactive command loop for sending job commands to the cluster.
   *
   * <p>arg1: user (i.e. bperry) arg2: defName (i.e. dev-3a) arg3: gateway (i.e. vorta) arg4+
   * machine names (i.e. suliban andorian tholian)
   */
  public static void oldMain(String[] args) throws IOException {
    // java -Xmx640m org.sd.cluster.config.JobAdmin bperry 3m3n.1-2 vorta suliban andorian tholian
    // java -Xmx640m org.sd.cluster.config.JobAdmin bperry 3m10n.2-8 vorta suliban founder shran

    // todo: manage args through cli

    final String user = args[0];
    final String defName = args[1];
    final String gateway = args[2];
    final String[] machines = new String[args.length - 3];
    for (int i = 3; i < args.length; ++i) {
      machines[i - 3] = args[i];
    }
    final ClusterDefinition clusterDef = new ClusterDefinition(user, defName, gateway, machines);
    final JobAdmin jobAdmin = new JobAdmin(clusterDef, 10000);
    final CommandInterpreter interp = new CommandInterpreter(jobAdmin, null);

    interp.setVar("prompt", "jobcmd> ");
    interp.setVar("user", user);
    interp.setVar("defName", defName);
    interp.setVar("gateway", gateway);
    interp.setVar("machines", concat(machines, ", "));

    jobAdmin.init();
    interp.start();
    jobAdmin.shutdown();
  }