private void parseCommandline()

in SamplesV1/CustomizedJavaOnHDInsight/HDInsight-ADF/src/com/adf/jobonhdi/JobOnHdiLauncher.java [114:187]


    private void parseCommandline(String[] args)
    {
        Options options = new Options();
        CommandLineParser parser = new BasicParser();

        options.addOption(FILES, FILES, true, "Comma-separated list of files to be placed in the working directory");       
        options.addOption(COMMAND, COMMAND, true, "The command to be executed");
        options.addOption(CONNECTION_STRING, CONNECTION_STRING, true, "Connection String for blob storage in which FILES contain");

    	// For debugging purpose -- list environment
    	try
    	{
	    	java.net.InetAddress localMachine = java.net.InetAddress.getLocalHost();
	    	System.out.println("hostname : " + localMachine.getHostName());
    	}
    	catch (Exception ex)
    	{    		
    	}
    	System.out.println("user.name : " + System.getProperty("user.name"));
    	System.out.println("working dir : " + System.getProperty("user.dir"));
    	String osName = System.getProperty("os.name");
    	System.out.println("os.name : " + osName);
    	
    	this.isWindowsOs = osName.startsWith("Windows");
    	
    	// For debugging purpose -- list all arguments
    	for (String s : args)
    	{
            System.out.println("===Args 1 : " + s);
        }

        try 
        {     	
        	// skip first several args provided by ADF MapReduce
        	for (int i=0; i < args.length; i++)
        	{
        		if (args[i].startsWith("fs.azure.account.key"))
        		{
        			int keyStart = args[i].indexOf('=');
        			String accountName = args[i].substring("fs.azure.account.key.".length(), keyStart);
        			accountName = accountName.substring(0, accountName.indexOf('.'));
        			String accountKey = args[i].substring(keyStart+1);
        			
        			String account = "DefaultEndpointsProtocol=https;AccountName=" + accountName + ";AccountKey=" + accountKey;
        			linkedStorageAccounts.add(account);
        		}
        		
        		if (options.getOption(args[i]) != null)
        		{
                	args = Arrays.copyOfRange(args, i, args.length);
                	break;
        		}
        	}        		
        	
        	for (String s : args)
        	{
                System.out.println("===Args 2 : " + s);
            }

        	cmd = parser.parse(options, args);
            validateArg(COMMAND);
            
            if (cmd.hasOption(CONNECTION_STRING))
            {
            	linkedStorageAccounts.add(cmd.getOptionValue(CONNECTION_STRING));
            }
        } 
        catch (ParseException ex)
        {
        	System.err.println("Error while parsing arguments ...");
        	ex.printStackTrace();
            throw new RuntimeException("ParseException is thrown");
        }
    }