diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-02-13 12:57:48 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-02-13 12:57:48 -0800 |
commit | b58a893bf9ba96db9a544cd33af4828826b73061 (patch) | |
tree | fad6c5dfcfd5be12a702d9117d260db7bdc05254 /sdkmanager/app | |
parent | 6990abcbc03c25aeff94da27ed6893e7993d2709 (diff) | |
download | sdk-b58a893bf9ba96db9a544cd33af4828826b73061.zip sdk-b58a893bf9ba96db9a544cd33af4828826b73061.tar.gz sdk-b58a893bf9ba96db9a544cd33af4828826b73061.tar.bz2 |
auto import from //branches/cupcake/...@131421
Diffstat (limited to 'sdkmanager/app')
3 files changed, 422 insertions, 194 deletions
diff --git a/sdkmanager/app/src/com/android/sdkmanager/CommandLineProcessor.java b/sdkmanager/app/src/com/android/sdkmanager/CommandLineProcessor.java index f1531e0..9f3fb99 100644 --- a/sdkmanager/app/src/com/android/sdkmanager/CommandLineProcessor.java +++ b/sdkmanager/app/src/com/android/sdkmanager/CommandLineProcessor.java @@ -128,15 +128,49 @@ public class CommandLineProcessor { /** * Raw access to parsed parameter values. - * @param verb The verb name, including {@link #GLOBAL_FLAG_VERB}. - * @param directObject The direct object name, including {@link #NO_VERB_OBJECT}. - * @param longFlagName The long flag name for the given action. + * <p/> + * The default is to scan all parameters. Parameters that have been explicitly set on the + * command line are returned first. Otherwise one with a non-null value is returned. + * <p/> + * Both a verb and a direct object filter can be specified. When they are non-null they limit + * the scope of the search. + * <p/> + * If nothing has been found, return the last default value seen matching the filter. + * + * @param verb The verb name, including {@link #GLOBAL_FLAG_VERB}. If null, all possible + * verbs that match the direct object condition will be examined and the first + * value set will be used. + * @param directObject The direct object name, including {@link #NO_VERB_OBJECT}. If null, + * all possible direct objects that match the verb condition will be examined and + * the first value set will be used. + * @param longFlagName The long flag name for the given action. Mandatory. Cannot be null. * @return The current value object stored in the parameter, which depends on the argument mode. */ public Object getValue(String verb, String directObject, String longFlagName) { - String key = verb + "/" + directObject + "/" + longFlagName; - Arg arg = mArguments.get(key); - return arg.getCurrentValue(); + + if (verb != null && directObject != null) { + String key = verb + "/" + directObject + "/" + longFlagName; + Arg arg = mArguments.get(key); + return arg.getCurrentValue(); + } + + Object lastDefault = null; + for (Arg arg : mArguments.values()) { + if (arg.getLongArg().equals(longFlagName)) { + if (verb == null || arg.getVerb().equals(verb)) { + if (directObject == null || arg.getDirectObject().equals(directObject)) { + if (arg.isInCommandLine()) { + return arg.getCurrentValue(); + } + if (arg.getCurrentValue() != null) { + lastDefault = arg.getCurrentValue(); + } + } + } + } + } + + return lastDefault; } /** @@ -243,6 +277,9 @@ public class CommandLineProcessor { } } } else if (arg != null) { + // This argument was present on the command line + arg.setInCommandLine(true); + // Process keyword String error = null; if (arg.getMode().needsExtra()) { @@ -408,13 +445,15 @@ public class CommandLineProcessor { "Global options:"); listOptions(GLOBAL_FLAG_VERB, NO_VERB_OBJECT); - stdout("\nValid actions are composed of a verb and an optional direct object:"); - for (String[] action : mActions) { - - stdout("- %1$6s %2$-7s: %3$s", - action[ACTION_VERB_INDEX], - action[ACTION_OBJECT_INDEX], - action[ACTION_DESC_INDEX]); + if (verb == null || directObject == null) { + stdout("\nValid actions are composed of a verb and an optional direct object:"); + for (String[] action : mActions) { + + stdout("- %1$6s %2$-7s: %3$s", + action[ACTION_VERB_INDEX], + action[ACTION_OBJECT_INDEX], + action[ACTION_DESC_INDEX]); + } } for (String[] action : mActions) { @@ -575,15 +614,26 @@ public class CommandLineProcessor { * or a String array (in which case the first item is the current by default.) */ static class Arg { + /** Verb for that argument. Never null. */ private final String mVerb; + /** Direct Object for that argument. Never null, but can be empty string. */ private final String mDirectObject; + /** The 1-letter short name of the argument, e.g. -v. */ private final String mShortName; + /** The long name of the argument, e.g. --verbose. */ private final String mLongName; + /** A description. Never null. */ private final String mDescription; + /** A default value. Can be null. */ private final Object mDefaultValue; + /** The argument mode (type + process method). Never null. */ private final MODE mMode; + /** True if this argument is mandatory for this verb/directobject. */ private final boolean mMandatory; + /** Current value. Initially set to the default value. */ private Object mCurrentValue; + /** True if the argument has been used on the command line. */ + private boolean mInCommandLine; /** * Creates a new argument flag description. @@ -612,6 +662,7 @@ public class CommandLineProcessor { mLongName = longName; mDescription = description; mDefaultValue = defaultValue; + mInCommandLine = false; if (defaultValue instanceof String[]) { mCurrentValue = ((String[])defaultValue)[0]; } else { @@ -619,45 +670,65 @@ public class CommandLineProcessor { } } + /** Return true if this argument is mandatory for this verb/directobject. */ public boolean isMandatory() { return mMandatory; } + /** Returns the 1-letter short name of the argument, e.g. -v. */ public String getShortArg() { return mShortName; } + /** Returns the long name of the argument, e.g. --verbose. */ public String getLongArg() { return mLongName; } + /** Returns the description. Never null. */ public String getDescription() { return mDescription; } + /** Returns the verb for that argument. Never null. */ public String getVerb() { return mVerb; } + /** Returns the direct Object for that argument. Never null, but can be empty string. */ public String getDirectObject() { return mDirectObject; } + /** Returns the default value. Can be null. */ public Object getDefaultValue() { return mDefaultValue; } + /** Returns the current value. Initially set to the default value. Can be null. */ public Object getCurrentValue() { return mCurrentValue; } + /** Sets the current value. Can be null. */ public void setCurrentValue(Object currentValue) { mCurrentValue = currentValue; } + /** Returns the argument mode (type + process method). Never null. */ public MODE getMode() { return mMode; } + + /** Returns true if the argument has been used on the command line. */ + public boolean isInCommandLine() { + return mInCommandLine; + } + + /** Sets if the argument has been used on the command line. */ + public void setInCommandLine(boolean inCommandLine) { + mInCommandLine = inCommandLine; + } } /** diff --git a/sdkmanager/app/src/com/android/sdkmanager/Main.java b/sdkmanager/app/src/com/android/sdkmanager/Main.java index 7965e87..3370e76 100644 --- a/sdkmanager/app/src/com/android/sdkmanager/Main.java +++ b/sdkmanager/app/src/com/android/sdkmanager/Main.java @@ -56,8 +56,6 @@ class Main { private ISdkLog mSdkLog; /** The SDK manager parses the SDK folder and gives access to the content. */ private SdkManager mSdkManager; - /** Virtual Machine manager to access the list of AVDs or create new ones. */ - private AvdManager mAvdManager; /** Command-line processor with options specific to SdkManager. */ private SdkCommandLine mSdkCommandLine; /** The working directory, either null or set to an existing absolute canonical directory. */ @@ -201,63 +199,85 @@ class Main { SdkCommandLine.OBJECT_AVD.equals(directObject)) { createAvd(); + } else if (SdkCommandLine.VERB_DELETE.equals(verb) && + SdkCommandLine.OBJECT_AVD.equals(directObject)) { + deleteAvd(); + + } else if (SdkCommandLine.VERB_MOVE.equals(verb) && + SdkCommandLine.OBJECT_AVD.equals(directObject)) { + moveAvd(); + } else if (SdkCommandLine.VERB_CREATE.equals(verb) && SdkCommandLine.OBJECT_PROJECT.equals(directObject)) { - // get the target and try to resolve it. - int targetId = mSdkCommandLine.getCreateProjectTargetId(); - IAndroidTarget[] targets = mSdkManager.getTargets(); - if (targetId < 1 || targetId > targets.length) { - errorAndExit("Target id is not valid. Use '%s list targets' to get the target ids.", - SdkConstants.androidCmdName()); - } - IAndroidTarget target = targets[targetId - 1]; - - ProjectCreator creator = new ProjectCreator(mSdkFolder, - mSdkCommandLine.isVerbose() ? OutputLevel.VERBOSE : - mSdkCommandLine.isSilent() ? OutputLevel.SILENT : - OutputLevel.NORMAL, - mSdkLog); - - String projectDir = getProjectLocation(mSdkCommandLine.getCreateProjectLocation()); - - creator.createProject(projectDir, - mSdkCommandLine.getCreateProjectName(), - mSdkCommandLine.getCreateProjectPackage(), - mSdkCommandLine.getCreateProjectActivity(), - target, - false /* isTestProject*/); + createProject(); } else if (SdkCommandLine.VERB_UPDATE.equals(verb) && SdkCommandLine.OBJECT_PROJECT.equals(directObject)) { - // get the target and try to resolve it. - IAndroidTarget target = null; - int targetId = mSdkCommandLine.getUpdateProjectTargetId(); - if (targetId >= 0) { - IAndroidTarget[] targets = mSdkManager.getTargets(); - if (targetId < 1 || targetId > targets.length) { - errorAndExit("Target id is not valid. Use '%s list targets' to get the target ids.", - SdkConstants.androidCmdName()); - } - target = targets[targetId - 1]; - } - - ProjectCreator creator = new ProjectCreator(mSdkFolder, - mSdkCommandLine.isVerbose() ? OutputLevel.VERBOSE : - mSdkCommandLine.isSilent() ? OutputLevel.SILENT : - OutputLevel.NORMAL, - mSdkLog); - - String projectDir = getProjectLocation(mSdkCommandLine.getUpdateProjectLocation()); - - creator.updateProject(projectDir, - target, - mSdkCommandLine.getUpdateProjectName()); + updateProject(); } else { mSdkCommandLine.printHelpAndExit(null); } } /** + * Creates a new Android project based on command-line parameters + */ + private void createProject() { + // get the target and try to resolve it. + int targetId = mSdkCommandLine.getParamTargetId(); + IAndroidTarget[] targets = mSdkManager.getTargets(); + if (targetId < 1 || targetId > targets.length) { + errorAndExit("Target id is not valid. Use '%s list targets' to get the target ids.", + SdkConstants.androidCmdName()); + } + IAndroidTarget target = targets[targetId - 1]; + + ProjectCreator creator = new ProjectCreator(mSdkFolder, + mSdkCommandLine.isVerbose() ? OutputLevel.VERBOSE : + mSdkCommandLine.isSilent() ? OutputLevel.SILENT : + OutputLevel.NORMAL, + mSdkLog); + + String projectDir = getProjectLocation(mSdkCommandLine.getParamLocationPath()); + + creator.createProject(projectDir, + mSdkCommandLine.getParamName(), + mSdkCommandLine.getParamProjectPackage(), + mSdkCommandLine.getParamProjectActivity(), + target, + false /* isTestProject*/); + } + + /** + * Updates an existing Android project based on command-line parameters + */ + private void updateProject() { + // get the target and try to resolve it. + IAndroidTarget target = null; + int targetId = mSdkCommandLine.getParamTargetId(); + if (targetId >= 0) { + IAndroidTarget[] targets = mSdkManager.getTargets(); + if (targetId < 1 || targetId > targets.length) { + errorAndExit("Target id is not valid. Use '%s list targets' to get the target ids.", + SdkConstants.androidCmdName()); + } + target = targets[targetId - 1]; + } + + ProjectCreator creator = new ProjectCreator(mSdkFolder, + mSdkCommandLine.isVerbose() ? OutputLevel.VERBOSE : + mSdkCommandLine.isSilent() ? OutputLevel.SILENT : + OutputLevel.NORMAL, + mSdkLog); + + String projectDir = getProjectLocation(mSdkCommandLine.getParamLocationPath()); + + creator.updateProject(projectDir, + target, + mSdkCommandLine.getParamName()); + } + + /** * Adjusts the project location to make it absolute & canonical relative to the * working directory, if any. * @@ -325,38 +345,45 @@ class Main { } // get the target skins - String[] skins = target.getSkins(); - mSdkLog.printf(" Skins: "); - if (skins != null) { - boolean first = true; - for (String skin : skins) { - if (first == false) { - mSdkLog.printf(", "); - } else { - first = false; - } - mSdkLog.printf(skin); - } - mSdkLog.printf("\n"); - } else { - mSdkLog.printf("no skins.\n"); - } + displaySkinList(target, " Skins: "); index++; } } + + /** + * Displays the skins valid for the given target. + */ + private void displaySkinList(IAndroidTarget target, String message) { + String[] skins = target.getSkins(); + mSdkLog.printf(message); + if (skins != null) { + boolean first = true; + for (String skin : skins) { + if (first == false) { + mSdkLog.printf(", "); + } else { + first = false; + } + mSdkLog.printf(skin); + } + mSdkLog.printf("\n"); + } else { + mSdkLog.printf("no skins.\n"); + } + } /** * Displays the list of available AVDs. */ private void displayAvdList() { try { - mAvdManager = new AvdManager(mSdkManager, null /* sdklog */); + AvdManager avdManager = new AvdManager(mSdkManager, null /* sdklog */); mSdkLog.printf("Available Android Virtual Devices:\n"); int index = 1; - for (AvdInfo info : mAvdManager.getAvds()) { + for (AvdInfo info : avdManager.getAvds()) { mSdkLog.printf("[%d] %s\n", index, info.getName()); mSdkLog.printf(" Path: %s\n", info.getPath()); @@ -384,7 +411,7 @@ class Main { */ private void createAvd() { // find a matching target - int targetId = mSdkCommandLine.getCreateAvdTargetId(); + int targetId = mSdkCommandLine.getParamTargetId(); IAndroidTarget target = null; if (targetId >= 1 && targetId <= mSdkManager.getTargets().length) { @@ -396,12 +423,12 @@ class Main { try { boolean removePrevious = false; - mAvdManager = new AvdManager(mSdkManager, mSdkLog); + AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog); - String avdName = mSdkCommandLine.getCreateAvdName(); - AvdInfo info = mAvdManager.getAvd(avdName); + String avdName = mSdkCommandLine.getParamName(); + AvdInfo info = avdManager.getAvd(avdName); if (info != null) { - if (mSdkCommandLine.getCreateAvdForce()) { + if (mSdkCommandLine.getFlagForce()) { removePrevious = true; mSdkLog.warning( "Android Virtual Device '%s' already exists and will be replaced.", @@ -412,9 +439,13 @@ class Main { } } - String avdParentFolder = mSdkCommandLine.getCreateAvdLocation(); - if (avdParentFolder == null) { - avdParentFolder = AndroidLocation.getFolder() + AndroidLocation.FOLDER_AVD; + String paramFolderPath = mSdkCommandLine.getParamLocationPath(); + File avdFolder = null; + if (paramFolderPath != null) { + avdFolder = new File(paramFolderPath); + } else { + avdFolder = new File(AndroidLocation.getFolder() + AndroidLocation.FOLDER_AVD, + avdName + AvdManager.AVD_FOLDER_EXTENSION); } Map<String, String> hardwareConfig = null; @@ -425,17 +456,45 @@ class Main { errorAndExit(e.getMessage()); } } - + AvdInfo oldAvdInfo = null; if (removePrevious) { - oldAvdInfo = mAvdManager.getAvd(avdName); + oldAvdInfo = avdManager.getAvd(avdName); + } + + // Validate skin is either default (empty) or NNNxMMM or a valid skin name. + String skin = mSdkCommandLine.getParamSkin(); + if (skin != null && skin.length() == 0) { + skin = null; + } + if (skin != null) { + boolean valid = false; + // Is it a know skin name for this target? + for (String s : target.getSkins()) { + if (skin.equalsIgnoreCase(s)) { + skin = s; // Make skin names case-insensitive. + valid = true; + break; + } + } + + // Is it NNNxMMM? + if (!valid) { + valid = skin.matches("[0-9]{2,}x[0-9]{2,}"); + } + + if (!valid) { + displaySkinList(target, "Valid skins: "); + errorAndExit("'%s' is not a valid skin name or size (NNNxMMM)", skin); + return; + } } - AvdInfo newAvdInfo = mAvdManager.createAvd(avdParentFolder, + AvdInfo newAvdInfo = avdManager.createAvd(avdFolder, avdName, target, - mSdkCommandLine.getCreateAvdSkin(), - mSdkCommandLine.getCreateAvdSdCard(), + skin, + mSdkCommandLine.getParamSdCard(), hardwareConfig, removePrevious, mSdkLog); @@ -446,10 +505,10 @@ class Main { mSdkLog.warning("Removing previous AVD directory at %s", oldAvdInfo.getPath()); // Remove the old data directory File dir = new File(oldAvdInfo.getPath()); - mAvdManager.recursiveDelete(dir); + avdManager.recursiveDelete(dir); dir.delete(); // Remove old avd info from manager - mAvdManager.removeAvd(oldAvdInfo); + avdManager.removeAvd(oldAvdInfo); } } catch (AndroidLocationException e) { @@ -458,6 +517,126 @@ class Main { } /** + * Delete an AVD. + */ + private void deleteAvd() { + try { + String avdName = mSdkCommandLine.getParamName(); + AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog); + AvdInfo info = avdManager.getAvd(avdName); + + if (info == null) { + errorAndExit("There is no Android Virtual Device named '%s'.", avdName); + return; + } + + avdManager.deleteAvd(info, mSdkLog); + } catch (AndroidLocationException e) { + errorAndExit(e.getMessage()); + } + } + + /** + * Move an AVD. + */ + private void moveAvd() { + try { + String avdName = mSdkCommandLine.getParamName(); + AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog); + AvdInfo info = avdManager.getAvd(avdName); + + if (info == null) { + errorAndExit("There is no Android Virtual Device named '%s'.", avdName); + return; + } + + // This is a rename if there's a new name for the AVD + String newName = mSdkCommandLine.getParamMoveNewName(); + if (newName != null && newName.equals(info.getName())) { + // same name, not actually a rename operation + newName = null; + } + + // This is a move (of the data files) if there's a new location path + String paramFolderPath = mSdkCommandLine.getParamLocationPath(); + if (paramFolderPath != null) { + // check if paths are the same. Use File methods to account for OS idiosyncrasies. + try { + File f1 = new File(paramFolderPath).getCanonicalFile(); + File f2 = new File(info.getPath()).getCanonicalFile(); + if (f1.equals(f2)) { + // same canonical path, so not actually a move + paramFolderPath = null; + } + } catch (IOException e) { + // Fail to resolve canonical path. Fail now since a move operation might fail + // later and be harder to recover from. + errorAndExit(e.getMessage()); + return; + } + } + + if (newName == null && paramFolderPath == null) { + mSdkLog.warning("Move operation aborted: same AVD name, same canonical data path"); + return; + } + + // If a rename was requested and no data move was requested, check if the original + // data path is our default constructed from the AVD name. In this case we still want + // to rename that folder too. + if (newName != null && paramFolderPath == null) { + // Compute the original data path + File originalFolder = new File( + AndroidLocation.getFolder() + AndroidLocation.FOLDER_AVD, + info.getName() + AvdManager.AVD_FOLDER_EXTENSION); + if (originalFolder.equals(info.getPath())) { + try { + // The AVD is using the default data folder path based on the AVD name. + // That folder needs to be adjusted to use the new name. + File f = new File(AndroidLocation.getFolder() + AndroidLocation.FOLDER_AVD, + newName + AvdManager.AVD_FOLDER_EXTENSION); + paramFolderPath = f.getCanonicalPath(); + } catch (IOException e) { + // Fail to resolve canonical path. Fail now rather than later. + errorAndExit(e.getMessage()); + } + } + } + + // Check for conflicts + + if (newName != null && avdManager.getAvd(newName) != null) { + errorAndExit("There is already an AVD named '%s'.", newName); + return; + } + if (newName != null) { + if (avdManager.getAvd(newName) != null) { + errorAndExit("There is already an AVD named '%s'.", newName); + return; + } + + File ini = info.getIniFile(); + if (ini.equals(AvdInfo.getIniFile(newName))) { + errorAndExit("The AVD file '%s' is in the way.", ini.getCanonicalPath()); + return; + } + } + + if (paramFolderPath != null && new File(paramFolderPath).exists()) { + errorAndExit( + "There is already a file or directory at '%s'.\nUse --path to specify a different data folder.", + paramFolderPath); + } + + avdManager.moveAvd(info, newName, paramFolderPath, mSdkLog); + } catch (AndroidLocationException e) { + errorAndExit(e.getMessage()); + } catch (IOException e) { + errorAndExit(e.getMessage()); + } + } + + /** * Prompts the user to setup a hardware config for a Platform-based AVD. * @throws IOException */ diff --git a/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java b/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java index fe93396..34a69bd 100644 --- a/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java +++ b/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java @@ -27,7 +27,6 @@ public class SdkCommandLine extends CommandLineProcessor { public final static String VERB_LIST = "list"; public final static String VERB_CREATE = "create"; - public final static String VERB_RENAME = "rename"; public final static String VERB_MOVE = "move"; public final static String VERB_DELETE = "delete"; public final static String VERB_UPDATE = "update"; @@ -51,6 +50,7 @@ public class SdkCommandLine extends CommandLineProcessor { public static final String KEY_SKIN = "skin"; public static final String KEY_SDCARD = "sdcard"; public static final String KEY_FORCE = "force"; + public static final String KEY_RENAME = "rename"; /** * Action definitions for SdkManager command line. @@ -64,92 +64,94 @@ public class SdkCommandLine extends CommandLineProcessor { * </ul> */ private final static String[][] ACTIONS = { - { VERB_LIST, - NO_VERB_OBJECT, + { VERB_LIST, NO_VERB_OBJECT, "Lists existing targets or virtual devices." }, - { VERB_LIST, - OBJECT_AVD, + { VERB_LIST, OBJECT_AVD, "Lists existing Android Virtual Devices.", OBJECT_AVDS }, - { VERB_LIST, - OBJECT_TARGET, + { VERB_LIST, OBJECT_TARGET, "Lists existing targets.", OBJECT_TARGETS }, - { VERB_CREATE, - OBJECT_AVD, + { VERB_CREATE, OBJECT_AVD, "Creates a new Android Virtual Device." }, - { VERB_RENAME, - OBJECT_AVD, - "Renames a new Android Virtual Device." }, - { VERB_MOVE, - OBJECT_AVD, - "Moves a new Android Virtual Device." }, - { VERB_DELETE, - OBJECT_AVD, - "Deletes a new Android Virtual Device." }, + { VERB_MOVE, OBJECT_AVD, + "Moves or renames an Android Virtual Device." }, + { VERB_DELETE, OBJECT_AVD, + "Deletes an Android Virtual Device." }, - { VERB_CREATE, - OBJECT_PROJECT, + { VERB_CREATE, OBJECT_PROJECT, "Creates a new Android Project." }, - { VERB_UPDATE, - OBJECT_PROJECT, + { VERB_UPDATE, OBJECT_PROJECT, "Updates an Android Project (must have an AndroidManifest.xml)." }, }; public SdkCommandLine(ISdkLog logger) { super(logger, ACTIONS); + // --- create avd --- + define(MODE.STRING, false, - VERB_CREATE, OBJECT_AVD, - "p", KEY_PATH, - "Location path of the parent directory where the new AVD will be created", null); + VERB_CREATE, OBJECT_AVD, "p", KEY_PATH, + "Location path of the directory where the new AVD will be created", null); define(MODE.STRING, true, - VERB_CREATE, OBJECT_AVD, - "n", KEY_NAME, + VERB_CREATE, OBJECT_AVD, "n", KEY_NAME, "Name of the new AVD", null); define(MODE.INTEGER, true, - VERB_CREATE, OBJECT_AVD, - "t", KEY_TARGET_ID, + VERB_CREATE, OBJECT_AVD, "t", KEY_TARGET_ID, "Target id of the new AVD", null); - define(MODE.STRING, true, - VERB_CREATE, OBJECT_AVD, - "s", KEY_SKIN, + define(MODE.STRING, false, + VERB_CREATE, OBJECT_AVD, "s", KEY_SKIN, "Skin of the new AVD", null); define(MODE.STRING, false, - VERB_CREATE, OBJECT_AVD, - "c", KEY_SDCARD, + VERB_CREATE, OBJECT_AVD, "c", KEY_SDCARD, "Path to a shared SD card image, or size of a new sdcard for the new AVD", null); define(MODE.BOOLEAN, false, - VERB_CREATE, OBJECT_AVD, - "f", KEY_FORCE, + VERB_CREATE, OBJECT_AVD, "f", KEY_FORCE, "Force creation (override an existing AVD)", false); + // --- delete avd --- + + define(MODE.STRING, true, + VERB_DELETE, OBJECT_AVD, "n", KEY_NAME, + "Name of the AVD to delete", null); + + // --- move avd --- + + define(MODE.STRING, true, + VERB_MOVE, OBJECT_AVD, "n", KEY_NAME, + "Name of the AVD to move or rename", null); + define(MODE.STRING, false, + VERB_MOVE, OBJECT_AVD, "r", KEY_RENAME, + "New name of the AVD to rename", null); + define(MODE.STRING, false, + VERB_MOVE, OBJECT_AVD, "p", KEY_PATH, + "New location path of the directory where to move the AVD", null); + + // --- create project --- + define(MODE.ENUM, true, - VERB_CREATE, OBJECT_PROJECT, - "m", KEY_MODE, + VERB_CREATE, OBJECT_PROJECT, "m", KEY_MODE, "Project mode", new String[] { ARG_ACTIVITY, ARG_ALIAS }); define(MODE.STRING, true, VERB_CREATE, OBJECT_PROJECT, "p", KEY_PATH, "Location path of new project", null); define(MODE.INTEGER, true, - VERB_CREATE, OBJECT_PROJECT, - "t", KEY_TARGET_ID, + VERB_CREATE, OBJECT_PROJECT, "t", KEY_TARGET_ID, "Target id of the new project", null); define(MODE.STRING, true, - VERB_CREATE, OBJECT_PROJECT, - "k", KEY_PACKAGE, + VERB_CREATE, OBJECT_PROJECT, "k", KEY_PACKAGE, "Package name", null); define(MODE.STRING, true, - VERB_CREATE, OBJECT_PROJECT, - "a", KEY_ACTIVITY, + VERB_CREATE, OBJECT_PROJECT, "a", KEY_ACTIVITY, "Activity name", null); define(MODE.STRING, false, - VERB_CREATE, OBJECT_PROJECT, - "n", KEY_NAME, + VERB_CREATE, OBJECT_PROJECT, "n", KEY_NAME, "Project name", null); + // --- update project --- + define(MODE.STRING, true, VERB_UPDATE, OBJECT_PROJECT, "p", KEY_PATH, @@ -164,79 +166,55 @@ public class SdkCommandLine extends CommandLineProcessor { "Project name", null); } - // -- some helpers for AVD action flags + // -- some helpers for generic action flags - /** Helper to retrieve the --out location for the new AVD action. */ - public String getCreateAvdLocation() { - return ((String) getValue(VERB_CREATE, OBJECT_AVD, KEY_PATH)); + /** Helper to retrieve the --path value. */ + public String getParamLocationPath() { + return ((String) getValue(null, null, KEY_PATH)); } - /** Helper to retrieve the --target id for the new AVD action. */ - public int getCreateAvdTargetId() { - return ((Integer) getValue(VERB_CREATE, OBJECT_AVD, KEY_TARGET_ID)).intValue(); + /** Helper to retrieve the --target id value. */ + public int getParamTargetId() { + return ((Integer) getValue(null, null, KEY_TARGET_ID)).intValue(); } - /** Helper to retrieve the --name for the new AVD action. */ - public String getCreateAvdName() { - return ((String) getValue(VERB_CREATE, OBJECT_AVD, KEY_NAME)); + /** Helper to retrieve the --name value. */ + public String getParamName() { + return ((String) getValue(null, null, KEY_NAME)); } - /** Helper to retrieve the --skin name for the new AVD action. */ - public String getCreateAvdSkin() { - return ((String) getValue(VERB_CREATE, OBJECT_AVD, KEY_SKIN)); + /** Helper to retrieve the --skin value. */ + public String getParamSkin() { + return ((String) getValue(null, null, KEY_SKIN)); } - /** Helper to retrieve the --sdcard data for the new AVD action. */ - public String getCreateAvdSdCard() { - return ((String) getValue(VERB_CREATE, OBJECT_AVD, KEY_SDCARD)); + /** Helper to retrieve the --sdcard value. */ + public String getParamSdCard() { + return ((String) getValue(null, null, KEY_SDCARD)); } - public boolean getCreateAvdForce() { - return ((Boolean) getValue(VERB_CREATE, OBJECT_AVD, KEY_FORCE)).booleanValue(); + /** Helper to retrieve the --force flag. */ + public boolean getFlagForce() { + return ((Boolean) getValue(null, null, KEY_FORCE)).booleanValue(); } + // -- some helpers for avd action flags - // -- some helpers for project action flags - - /** Helper to retrieve the --out location for the new project action. */ - public String getCreateProjectLocation() { - return ((String) getValue(VERB_CREATE, OBJECT_PROJECT, KEY_PATH)); - } - - /** Helper to retrieve the --target id for the new project action. */ - public int getCreateProjectTargetId() { - return ((Integer) getValue(VERB_CREATE, OBJECT_PROJECT, KEY_TARGET_ID)).intValue(); + /** Helper to retrieve the --rename value for a move verb. */ + public String getParamMoveNewName() { + return ((String) getValue(VERB_MOVE, null, KEY_RENAME)); } - /** Helper to retrieve the --name for the new project action. */ - public String getCreateProjectName() { - return ((String) getValue(VERB_CREATE, OBJECT_PROJECT, KEY_NAME)); - } - /** Helper to retrieve the --package for the new project action. */ - public String getCreateProjectPackage() { - return ((String) getValue(VERB_CREATE, OBJECT_PROJECT, KEY_PACKAGE)); - } - - /** Helper to retrieve the --activity for the new project action. */ - public String getCreateProjectActivity() { - return ((String) getValue(VERB_CREATE, OBJECT_PROJECT, KEY_ACTIVITY)); - } - - // -- some helpers for update action flags - - /** Helper to retrieve the --out location for the update project action. */ - public String getUpdateProjectLocation() { - return ((String) getValue(VERB_UPDATE, OBJECT_PROJECT, KEY_PATH)); - } + // -- some helpers for project action flags - /** Helper to retrieve the --target id for the update project action. */ - public int getUpdateProjectTargetId() { - return ((Integer) getValue(VERB_UPDATE, OBJECT_PROJECT, KEY_TARGET_ID)).intValue(); + /** Helper to retrieve the --package value. */ + public String getParamProjectPackage() { + return ((String) getValue(null, OBJECT_PROJECT, KEY_PACKAGE)); } - /** Helper to retrieve the --name for the update project action. */ - public String getUpdateProjectName() { - return ((String) getValue(VERB_UPDATE, OBJECT_PROJECT, KEY_NAME)); + /** Helper to retrieve the --activity for the new project action. */ + public String getParamProjectActivity() { + return ((String) getValue(null, OBJECT_PROJECT, KEY_ACTIVITY)); } } |