| /* |
| * Copyright 2012-present Facebook, Inc. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| * not use this file except in compliance with the License. You may obtain |
| * a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| * License for the specific language governing permissions and limitations |
| * under the License. |
| */ |
| |
| package com.facebook.buck.cli; |
| |
| import com.facebook.buck.cli.UninstallCommandOptions.UninstallOptions; |
| import com.google.common.annotations.VisibleForTesting; |
| |
| import org.kohsuke.args4j.Option; |
| |
| import javax.annotation.Nullable; |
| |
| |
| public class InstallCommandOptions extends BuildCommandOptions { |
| |
| @VisibleForTesting static final String RUN_LONG_ARG = "--run"; |
| @VisibleForTesting static final String RUN_SHORT_ARG = "-r"; |
| @VisibleForTesting static final String ACTIVITY_LONG_ARG = "--activity"; |
| @VisibleForTesting static final String ACTIVITY_SHORT_ARG = "-a"; |
| @VisibleForTesting static final String UNINSTALL_LONG_ARG = "--uninstall"; |
| @VisibleForTesting static final String UNINSTALL_SHORT_ARG = "-u"; |
| |
| @Option( |
| name = UNINSTALL_LONG_ARG, |
| aliases = { UNINSTALL_SHORT_ARG }, |
| usage = "Uninstall the existing version before installing.") |
| private boolean uninstallFirst = false; |
| |
| @AdditionalOptions |
| private UninstallOptions uninstallOptions; |
| |
| @AdditionalOptions |
| private AdbOptions adbOptions; |
| |
| @AdditionalOptions |
| private TargetDeviceOptions deviceOptions; |
| |
| @Option( |
| name = RUN_LONG_ARG, |
| aliases = { RUN_SHORT_ARG }, |
| usage = "Run an activity (the default activity for package unless -a is specified).") |
| private boolean run = false; |
| |
| @Option( |
| name = ACTIVITY_LONG_ARG, |
| aliases = { ACTIVITY_SHORT_ARG }, |
| metaVar = "<pkg/activity>", |
| usage = "Activity to launch e.g. com.facebook.katana/.LoginActivity. Implies -r.") |
| private String activity = null; |
| |
| public AdbOptions adbOptions() { |
| return adbOptions; |
| } |
| |
| public TargetDeviceOptions targetDeviceOptions() { |
| return deviceOptions; |
| } |
| |
| public UninstallOptions uninstallOptions() { |
| return uninstallOptions; |
| } |
| |
| public boolean shouldUninstallFirst() { |
| return uninstallFirst; |
| } |
| |
| public boolean shouldStartActivity() { |
| return (activity != null) || run; |
| } |
| |
| public @Nullable String getActivityToStart() { |
| return activity; |
| } |
| |
| public InstallCommandOptions(BuckConfig buckConfig) { |
| super(buckConfig); |
| } |
| } |