Changeset 85106 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Jul 8, 2020 10:24:23 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 139033
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp
r82968 r85106 562 562 } 563 563 564 /* Parse the optional arguments, allowing more freedom than the 565 * synopsis explains. Can rename multiple snapshots and so on. */ 564 566 ComPtr<ISnapshot> pSnapshot; 565 566 if ( !strcmp(a->argv[2], "--current") 567 || !strcmp(a->argv[2], "-current")) 568 { 569 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(CurrentSnapshot)(pSnapshot.asOutParam())); 570 if (pSnapshot.isNull()) 567 static const RTGETOPTDEF s_aEditOptions[] = 568 { 569 { "--current", 'c', RTGETOPT_REQ_NOTHING }, 570 { "-current", 'c', RTGETOPT_REQ_NOTHING }, 571 { "--name", 'n', RTGETOPT_REQ_STRING }, 572 { "-name", 'n', RTGETOPT_REQ_STRING }, 573 { "-newname", 'n', RTGETOPT_REQ_STRING }, 574 { "--description", 'd', RTGETOPT_REQ_STRING }, 575 { "-description", 'd', RTGETOPT_REQ_STRING }, 576 { "-desc", 'd', RTGETOPT_REQ_STRING } 577 }; 578 RTGETOPTSTATE GetOptState; 579 RTGetOptInit(&GetOptState, a->argc, a->argv, s_aEditOptions, RT_ELEMENTS(s_aEditOptions), 580 2, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 581 int ch; 582 RTGETOPTUNION Value; 583 while ( SUCCEEDED(rc) 584 && (ch = RTGetOpt(&GetOptState, &Value))) 585 { 586 switch (ch) 571 587 { 572 RTPrintf("This machine does not have any snapshots\n"); 573 return RTEXITCODE_FAILURE; 588 case 'c': 589 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(CurrentSnapshot)(pSnapshot.asOutParam())); 590 if (pSnapshot.isNull()) 591 { 592 RTPrintf("This machine does not have any snapshots\n"); 593 return RTEXITCODE_FAILURE; 594 } 595 break; 596 597 case 'n': 598 CHECK_ERROR_BREAK(pSnapshot, COMSETTER(Name)(Bstr(Value.psz).raw())); 599 break; 600 601 case 'd': 602 CHECK_ERROR_BREAK(pSnapshot, COMSETTER(Description)(Bstr(Value.psz).raw())); 603 break; 604 605 case VINF_GETOPT_NOT_OPTION: 606 CHECK_ERROR_BREAK(sessionMachine, FindSnapshot(Bstr(Value.psz).raw(), pSnapshot.asOutParam())); 607 break; 608 609 default: 610 errorGetOpt(ch, &Value); 611 rc = E_FAIL; 612 break; 574 613 } 575 614 } 576 else 577 { 578 CHECK_ERROR_BREAK(sessionMachine, FindSnapshot(Bstr(a->argv[2]).raw(), 579 pSnapshot.asOutParam())); 580 } 581 582 /* parse options */ 583 for (int i = 3; i < a->argc; i++) 584 { 585 if ( !strcmp(a->argv[i], "--name") 586 || !strcmp(a->argv[i], "-name") 587 || !strcmp(a->argv[i], "-newname")) 588 { 589 if (a->argc <= i + 1) 590 { 591 errorArgument("Missing argument to '%s'", a->argv[i]); 592 rc = E_FAIL; 593 break; 594 } 595 i++; 596 pSnapshot->COMSETTER(Name)(Bstr(a->argv[i]).raw()); 597 } 598 else if ( !strcmp(a->argv[i], "--description") 599 || !strcmp(a->argv[i], "-description") 600 || !strcmp(a->argv[i], "-newdesc")) 601 { 602 if (a->argc <= i + 1) 603 { 604 errorArgument("Missing argument to '%s'", a->argv[i]); 605 rc = E_FAIL; 606 break; 607 } 608 i++; 609 pSnapshot->COMSETTER(Description)(Bstr(a->argv[i]).raw()); 610 } 611 else 612 { 613 errorSyntax("Invalid parameter '%s'", Utf8Str(a->argv[i]).c_str()); 614 rc = E_FAIL; 615 break; 616 } 617 } 618 615 616 if (FAILED(rc)) 617 break; 619 618 } 620 619 else if (!strcmp(a->argv[1], "showvminfo"))
Note:
See TracChangeset
for help on using the changeset viewer.