package runner;

import swing.*;

public class SwingRunner {

  public static void printUsage() {
    System.out.println("Usage:");
    System.out.println("./run.sh -udp [broadcast address]");
    System.out.println("./run.sh [address of robot]");
    System.out.println("./run.sh [address of robot] [port of robot]");
  }
  
  public static void main(String[] args) {
    if (args.length < 1) {
      printUsage();
      return;
    }
    
    if (args[0].equalsIgnoreCase("-udp")) {
      System.out.println("Using UDP on Visualizer.");
      if (args.length >= 2) {
        new Visualizer(args[1], 0, true);
      }
      else {
        new Visualizer();
      }
    }
    else {
      String robotAddress = args[0];
      int robotPort = -1;
      if (args.length >= 2) {
        try {
          robotPort = Integer.parseInt(args[1]);
        }
        catch (NumberFormatException e) {
          robotPort = -1;
        }
      }
      
      System.out.println("Using TCP on Visualizer.");
      if (robotPort >= 0) {
        new Visualizer(robotAddress, robotPort);
      }
      else {
        new Visualizer(robotAddress);
      }
    }
  }

}
