001 package org.hackystat.sensor.xmldata; 002 003 import java.util.Arrays; 004 005 /** 006 * The entry point into the XmlDataSensor. This class allows command-line 007 * arguments to be specified by the user to perform actions based on the options 008 * and their parameters. 009 * 010 * @author Austen Ito 011 * 012 */ 013 public class XmlDataCliSensor { 014 /** A summary usage message. */ 015 private static final String[] USAGE_MSG = { "\nUsage:\n " + "[-verbose]\n " + "[-sdt <name>]\n" 016 + " -file <filename> [filename]... \n -argList <filename>\n " 017 + "-migration <v7 directory> <v7 account> <v8 username> <v8 password>" 018 + "\n\nNote: optional arguments are within square brackets. " 019 + "Arguments can be used in any order." }; 020 021 /** 022 * Provide the command line interface to the XmlData sensor. 023 * 024 * @param args The command line arguments. 025 */ 026 public static void main(String[] args) { 027 try { 028 if (args.length == 0) { 029 XmlDataCliSensor sensor = new XmlDataCliSensor(); 030 sensor.usage(); 031 } 032 else { 033 XmlDataController controller = new XmlDataController(); 034 controller.processArguments(Arrays.asList(args)); 035 controller.execute(); 036 } 037 } 038 catch (Exception e) { 039 e.printStackTrace(); 040 System.out.println("A fatal error has occured. Please contact " 041 + "your hackystat administrator."); 042 } 043 } 044 045 /** 046 * Display a usage summary message on System.err and exit. 047 */ 048 private void usage() { 049 for (int i = 0; i < USAGE_MSG.length; i++) { 050 System.err.println(USAGE_MSG[i]); 051 } 052 } 053 }