VirtualBox

Changeset 77801 in vbox


Ignore:
Timestamp:
Mar 19, 2019 5:44:40 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
129468
Message:

VBoxManage snapshot: Use manpage help text (option parsing needs cleaning up!).

Location:
trunk/src/VBox/Frontends/VBoxManage
Files:
4 edited

Legend:

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

    r77777 r77801  
    125125    { "discardstate",       USAGE_DISCARDSTATE,     VBMG_CMD_TODO, handleDiscardState,         0 },
    126126    { "adoptstate",         USAGE_ADOPTSTATE,       VBMG_CMD_TODO, handleAdoptState,           0 },
    127     { "snapshot",           USAGE_SNAPSHOT,         VBMG_CMD_TODO, handleSnapshot,             0 },
     127    { "snapshot",           USAGE_S_NEWCMD,     HELP_CMD_SNAPSHOT, handleSnapshot,             0 },
    128128    { "closemedium",        USAGE_CLOSEMEDIUM,      VBMG_CMD_TODO, handleCloseMedium,          0 },
    129129    { "storageattach",      USAGE_STORAGEATTACH,    VBMG_CMD_TODO, handleStorageAttach,        0 },
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h

    r77777 r77801  
    6161    USAGE_CONTROLVM,
    6262    USAGE_DISCARDSTATE,
    63     USAGE_SNAPSHOT,
    6463    USAGE_CLOSEMEDIUM,
    6564    USAGE_SHOWMEDIUMINFO,
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r77606 r77801  
    898898                     "\n", SEP);
    899899
    900     if (enmCommand == USAGE_SNAPSHOT || enmCommand == USAGE_S_ALL)
    901         RTStrmPrintf(pStrm,
    902                            "%s snapshot %s        <uuid|vmname>\n"
    903                      "                            take <name> [--description <desc>] [--live]\n"
    904                      "                                 [--uniquename Number,Timestamp,Space,Force] |\n"
    905                      "                            delete <uuid|snapname> |\n"
    906                      "                            restore <uuid|snapname> |\n"
    907                      "                            restorecurrent |\n"
    908                      "                            edit <uuid|snapname>|--current\n"
    909                      "                                 [--name <name>]\n"
    910                      "                                 [--description <desc>] |\n"
    911                      "                            list [--details|--machinereadable] |\n"
    912                      "                            showvminfo <uuid|snapname>\n"
    913                      "\n", SEP);
    914 
    915900    if (enmCommand == USAGE_CLOSEMEDIUM || enmCommand == USAGE_S_ALL)
    916901        RTStrmPrintf(pStrm,
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp

    r76553 r77801  
    186186            case 'D':   enmDetails = VMINFO_FULL; break;
    187187            case 'M':   enmDetails = VMINFO_MACHINEREADABLE; break;
    188             default:    return errorGetOpt(USAGE_SNAPSHOT, c, &ValueUnion);
     188            default:    return errorGetOpt(c, &ValueUnion);
    189189        }
    190190    }
     
    316316    HRESULT rc;
    317317
     318/** @todo r=bird: sub-standard command line parsing here!
     319 *
     320 * 'VBoxManage snapshot empty take --help' takes a snapshot rather than display
     321 * help as you would expect.
     322 *
     323 */
     324
    318325    /* we need at least a VM and a command */
    319326    if (a->argc < 2)
    320         return errorSyntax(USAGE_SNAPSHOT, "Not enough parameters");
     327        return errorSyntax("Not enough parameters");
    321328
    322329    /* the first argument must be the VM */
     
    343350        if (!strcmp(a->argv[1], "take"))
    344351        {
     352            setCurrentSubcommand(HELP_SCOPE_SNAPSHOT_TAKE);
     353
    345354            /* there must be a name */
    346355            if (a->argc < 3)
    347356            {
    348                 errorSyntax(USAGE_SNAPSHOT, "Missing snapshot name");
     357                errorSyntax("Missing snapshot name");
    349358                rc = E_FAIL;
    350359                break;
     
    395404
    396405                    default:
    397                         errorGetOpt(USAGE_SNAPSHOT, ch, &Value);
     406                        errorGetOpt(ch, &Value);
    398407                        rc = E_FAIL;
    399408                        break;
     
    479488                )
    480489        {
     490            setCurrentSubcommand(fDelete    ? HELP_SCOPE_SNAPSHOT_DELETE
     491                                 : fRestore ? HELP_SCOPE_SNAPSHOT_RESTORE
     492                                            : HELP_SCOPE_SNAPSHOT_RESTORECURRENT);
     493
    481494            if (fRestoreCurrent)
    482495            {
    483496                if (a->argc > 2)
    484497                {
    485                     errorSyntax(USAGE_SNAPSHOT, "Too many arguments");
     498                    errorSyntax("Too many arguments");
    486499                    rc = E_FAIL;
    487500                    break;
     
    491504            else if (a->argc != 3)
    492505            {
    493                 errorSyntax(USAGE_SNAPSHOT, "Expecting snapshot name only");
     506                errorSyntax("Expecting snapshot name only");
    494507                rc = E_FAIL;
    495508                break;
     
    541554        else if (!strcmp(a->argv[1], "edit"))
    542555        {
     556            setCurrentSubcommand(HELP_SCOPE_SNAPSHOT_EDIT);
    543557            if (a->argc < 3)
    544558            {
    545                 errorSyntax(USAGE_SNAPSHOT, "Missing snapshot name");
     559                errorSyntax("Missing snapshot name");
    546560                rc = E_FAIL;
    547561                break;
     
    597611                else
    598612                {
    599                     errorSyntax(USAGE_SNAPSHOT, "Invalid parameter '%s'", Utf8Str(a->argv[i]).c_str());
     613                    errorSyntax("Invalid parameter '%s'", Utf8Str(a->argv[i]).c_str());
    600614                    rc = E_FAIL;
    601615                    break;
     
    606620        else if (!strcmp(a->argv[1], "showvminfo"))
    607621        {
     622            setCurrentSubcommand(HELP_SCOPE_SNAPSHOT_SHOWVMINFO);
     623
    608624            /* exactly one parameter: snapshot name */
    609625            if (a->argc != 3)
    610626            {
    611                 errorSyntax(USAGE_SNAPSHOT, "Expecting snapshot name only");
     627                errorSyntax("Expecting snapshot name only");
    612628                rc = E_FAIL;
    613629                break;
     
    625641        }
    626642        else if (!strcmp(a->argv[1], "list"))
     643        {
     644            setCurrentSubcommand(HELP_SCOPE_SNAPSHOT_LIST);
    627645            rc = handleSnapshotList(a, sessionMachine) == RTEXITCODE_SUCCESS ? S_OK : E_FAIL;
     646        }
    628647        else if (!strcmp(a->argv[1], "dump"))          // undocumented parameter to debug snapshot info
    629648            DumpSnapshot(sessionMachine);
    630649        else
    631650        {
    632             errorSyntax(USAGE_SNAPSHOT, "Invalid parameter '%s'", Utf8Str(a->argv[1]).c_str());
     651            errorSyntax("Invalid parameter '%s'", Utf8Str(a->argv[1]).c_str());
    633652            rc = E_FAIL;
    634653        }
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