blob: c3b26669c4ab7daaad9af28694870695489f2d6c (
plain) (
blame)
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
|
/*******************************************************************************
* Copyright (c) 2007 Innoopract Informationssysteme GmbH
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Innoopract - initial API and implementation
*******************************************************************************/
package org.eclipse.epp.packaging.core.configuration;
/**
* Parses the arguments given to the main application.
*/
public class ArgumentParser {
/**
* @param args the argument vector as a String array
* @return an initialised <code>ICommand</code> object with the parsed
* command line options
* @throws IllegalArgumentException if arguments is no array of strings.
*/
public static ICommands parse( final String[] args ) {
if( args == null || args.length == 0 ) {
throw new IllegalArgumentException( "Argument must contain at least one value." ); //$NON-NLS-1$
}
Commands command = new Commands();
command.setConfigurationFile( args[ 0 ] );
if( args.length > 1 ) {
String[] tasks = new String[ args.length - 1 ];
System.arraycopy( args, 1, tasks, 0, tasks.length );
command.setTasks( tasks );
}
return command;
}
}
|