View Javadoc

1   /*
2    * Version.java
3    *
4    * Created on May 11, 2005, 2:46 PM
5    *
6    * To change this template, choose Tools | Options and locate the template under
7    * the Source Creation and Management node. Right-click the template and choose
8    * Open. You can then make changes to the template in the Source Editor.
9    */
10  
11  package gov.bnl.gums.admin;
12  
13  import java.io.File;
14  import org.apache.commons.cli.Options;
15  
16  /***
17   *
18   * @author carcassi
19   */
20  public class Version extends RemoteCommand {
21  
22      static {
23          command = new Version();
24      }
25  
26      /***
27       * Creates a new UpdateGroups object.
28       */
29      public Version() {
30          syntax = "";
31          description = "Returns the version of GUMS client being used.";
32      }
33  
34      protected org.apache.commons.cli.Options buildOptions() {
35          Options options = new Options();
36  
37          return options;
38      }
39  
40      protected void execute(org.apache.commons.cli.CommandLine cmd)
41          throws Exception {
42          File dir = new File("../lib");
43          String[] files = dir.list();
44          for (int nFile = 0; nFile < files.length; nFile++) {
45              if (files[nFile].startsWith("gums-client-")) {
46                  System.out.println("GUMS client version " + files[nFile].substring(12, files[nFile].length() - 4));
47                  return;
48              }
49          }
50          System.out.println("Couldn't determine GUMS client version. Sorry...");
51          System.exit(-1);
52      }
53      
54  }