From 38fa5725468c556d3aabd02fb5fb4fd746e1fe1a Mon Sep 17 00:00:00 2001 From: xsz233 Date: Sun, 23 Apr 2023 18:10:57 +0800 Subject: [PATCH] recover bm install -r Signed-off-by: xsz233 --- frameworks/src/bundle_command.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/frameworks/src/bundle_command.cpp b/frameworks/src/bundle_command.cpp index f56d49a..6d931d2 100644 --- a/frameworks/src/bundle_command.cpp +++ b/frameworks/src/bundle_command.cpp @@ -53,10 +53,11 @@ const int32_t MAX_OVERLAY_ARGUEMENTS_NUMBER = 8; const int32_t MINIMUM_WAITTING_TIME = 180; // 3 mins const int32_t MAXIMUM_WAITTING_TIME = 600; // 10 mins -const std::string SHORT_OPTIONS = "hp:n:m:a:cdu:w:s:"; +const std::string SHORT_OPTIONS = "hp:rn:m:a:cdu:w:s:"; const struct option LONG_OPTIONS[] = { {"help", no_argument, nullptr, 'h'}, {"bundle-path", required_argument, nullptr, 'p'}, + {"replace", no_argument, nullptr, 'r'}, {"bundle-name", required_argument, nullptr, 'n'}, {"module-name", required_argument, nullptr, 'm'}, {"ability-name", required_argument, nullptr, 'a'}, @@ -234,7 +235,8 @@ bool BundleManagerShellCommand::IsInstallOption(int index) const if (index >= argc_ || index < INDEX_OFFSET) { return false; } - if (argList_[index - INDEX_OFFSET] == "-p" || argList_[index - INDEX_OFFSET] == "--bundle-path" || + if (argList_[index - INDEX_OFFSET] == "-r" || argList_[index - INDEX_OFFSET] == "--replace" || + argList_[index - INDEX_OFFSET] == "-p" || argList_[index - INDEX_OFFSET] == "--bundle-path" || argList_[index - INDEX_OFFSET] == "-u" || argList_[index - INDEX_OFFSET] == "--user-id" || argList_[index - INDEX_OFFSET] == "-w" || argList_[index - INDEX_OFFSET] == "--waitting-time" || argList_[index - INDEX_OFFSET] == "-s" || argList_[index - INDEX_OFFSET] == "--shared-bundle-dir-path") { @@ -336,6 +338,12 @@ ErrCode BundleManagerShellCommand::RunAsInstallCommand() index = optind; break; } + case 'r': { + // 'bm install -r' + // 'bm install --replace' + installFlag = InstallFlag::REPLACE_EXISTING; + break; + } case 'u': { // 'bm install -p -u userId' // 'bm install --bundle-path --user-id userId' @@ -444,7 +452,8 @@ ErrCode BundleManagerShellCommand::GetBundlePath(const std::string& param, if (param.empty()) { return OHOS::ERR_INVALID_VALUE; } - if (param == "-p" || param == "--bundle-path" || param == "-u" || param == "--user-id" || + if (param == "-r" || param == "--replace" || param == "-p" || + param == "--bundle-path" || param == "-u" || param == "--user-id" || param == "-w" || param == "--waitting-time") { return OHOS::ERR_INVALID_VALUE; } -- Gitee