aboutsummaryrefslogtreecommitdiffstats
path: root/tools/domctl/src/uk/ac/cam/cl/xeno/domctl/Main.java
blob: 49b4fb3c54c0bb794be104e6e34430e4f96eb48b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package uk.ac.cam.cl.xeno.domctl;

public class Main 
{
  static CommandHelp help = new CommandHelp ();
  static CommandNew newdom = new CommandNew ();
  static CommandStart start = new CommandStart ();
  static CommandStop stop = new CommandStop ();
  static CommandDestroy destroy = new CommandDestroy ();
  static Command commands[] = { help, newdom, start, stop, destroy };

  public static void main (String[] args)
  {
    Defaults d = new Defaults ();
    int ec = -1;

    if (args.length == 0) {
      ec = help.doCommand (d, args);
    } else {
      String c = args[0];
      int i;
      for (i = 0; i < commands.length; i ++) {
	if (commands[i].getName().equals(c)) {
	  if (commands[i].getFlagParameter (args, '?')) {
	    ec = help.doHelpFor (commands[i]);
	  } else {
	    ec = commands[i].doCommand (d, args);
	  }
	  break;
	}
      }
      if (i == commands.length) {
	System.out.println ("Unknown command " + c);
      }
    }

    System.exit (ec);
  }
}