VirtualBox

Changeset 79935 in vbox


Ignore:
Timestamp:
Jul 23, 2019 4:44:25 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
132356
Message:

OCI: exportCloudImage - improve parameter handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/VBox/Frontends/VBoxManage/VBoxManageCloud.cpp

    r79869 r79935  
    919919    Utf8Str strObjectName;
    920920    Utf8Str strImageId;
    921     com::SafeArray<BSTR>  parameters;
     921    com::SafeArray<BSTR> parameters;
    922922
    923923    int c;
     
    927927        {
    928928            case 'b':
    929                 strBucketName=ValueUnion.psz;
    930                 Bstr(Utf8Str("bucket-name=").append(ValueUnion.psz)).detachTo(parameters.appendedRaw());
    931                 break;
     929            {
     930                if (strBucketName.isNotEmpty())
     931                    return errorArgument("Duplicate parameter: --bucket-name");
     932
     933                strBucketName = ValueUnion.psz;
     934                if (strBucketName.isEmpty())
     935                    return errorArgument("Empty parameter: --bucket-name");
     936
     937                break;
     938            }
     939
    932940            case 'o':
    933                 strObjectName=ValueUnion.psz;
    934                 Bstr(Utf8Str("object-name=").append(ValueUnion.psz)).detachTo(parameters.appendedRaw());
    935                 break;
     941            {
     942                if (strObjectName.isNotEmpty())
     943                    return errorArgument("Duplicate parameter: --object-name");
     944
     945                strObjectName = ValueUnion.psz;
     946                if (strObjectName.isEmpty())
     947                    return errorArgument("Empty parameter: --object-name");
     948
     949                break;
     950            }
     951
    936952            case 'i':
    937                 strImageId=ValueUnion.psz;
    938                 Bstr(Utf8Str("image-id=").append(ValueUnion.psz)).detachTo(parameters.appendedRaw());
    939                 break;
    940             case VINF_GETOPT_NOT_OPTION:
    941                 return errorUnknownSubcommand(ValueUnion.psz);
    942             default:
    943                 return errorGetOpt(c, &ValueUnion);
    944         }
    945     }
     953            {
     954                if (strImageId.isNotEmpty())
     955                    return errorArgument("Duplicate parameter: --id");
     956
     957                strImageId = ValueUnion.psz;
     958                if (strImageId.isEmpty())
     959                    return errorArgument("Empty parameter: --id");
     960
     961                break;
     962            }
     963
     964            case VINF_GETOPT_NOT_OPTION:
     965                return errorUnknownSubcommand(ValueUnion.psz);
     966
     967            default:
     968                return errorGetOpt(c, &ValueUnion);
     969        }
     970    }
     971
     972    if (strBucketName.isNotEmpty())
     973        BstrFmt("bucket-name=%s", strBucketName.c_str()).detachTo(parameters.appendedRaw());
     974    else
     975        return errorArgument("Missing parameter: --bucket-name");
     976
     977    /* API will use display name as object name if not specified */
     978    if (strObjectName.isNotEmpty())
     979        BstrFmt("object-name=%s", strObjectName.c_str()).detachTo(parameters.appendedRaw());
     980
     981    if (strImageId.isNotEmpty())
     982        BstrFmt("image-id=%s", strImageId.c_str()).detachTo(parameters.appendedRaw());
     983    else
     984        return errorArgument("Missing parameter: --id");
     985
    946986
    947987    Bstr bstrProfileName;
     
    953993                     CreateCloudClient(oCloudClient.asOutParam()),
    954994                     RTEXITCODE_FAILURE);
    955     RTPrintf("Exporting image \'%s\' to the Cloud with name \'%s\'...\n", strImageId.c_str(), strObjectName.c_str());
     995
     996    if (strObjectName.isNotEmpty())
     997        RTPrintf("Exporting image \'%s\' to the Cloud with name \'%s\'...\n",
     998                 strImageId.c_str(), strObjectName.c_str());
     999    else
     1000        RTPrintf("Exporting image \'%s\' to the Cloud with default name\n",
     1001                 strImageId.c_str());
    9561002
    9571003    ComPtr<IVirtualBox> pVirtualBox = a->virtualBox;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette