Changeset 17098 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Feb 24, 2009 8:18:52 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 43329
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp
r17074 r17098 41 41 42 42 #include <iprt/stream.h> 43 #include <iprt/getopt.h> 43 44 44 45 #include <VBox/log.h> … … 493 494 } 494 495 496 static const RTGETOPTDEF g_aExportOptions[] 497 = { 498 { "--output", 'o', RTGETOPT_REQ_STRING }, 499 }; 500 495 501 int handleExportAppliance(HandlerArg *a) 496 502 { … … 502 508 do 503 509 { 504 for (int i = 0; 505 i < a->argc; 506 ++i) 507 { 508 Utf8Str strThisArg(a->argv[i]); 509 510 if ( strThisArg == "--output" 511 || strThisArg == "-output" 512 || strThisArg == "-o" 513 ) 510 int c; 511 512 RTGETOPTUNION ValueUnion; 513 RTGETOPTSTATE GetState; 514 RTGetOptInit(&GetState, 515 a->argc, 516 a->argv, 517 g_aExportOptions, 518 RT_ELEMENTS(g_aExportOptions), 519 0, // start at 0 even though arg 1 was "list" because main() has hacked both the argc and argv given to us 520 0 /* fFlags */); 521 while ((c = RTGetOpt(&GetState, &ValueUnion))) 522 { 523 switch (c) 514 524 { 515 if (++i < a->argc) 516 { 525 case 'o': // --output 517 526 if (strOutputFile.length()) 518 527 return errorSyntax(USAGE_EXPORTAPPLIANCE, "You can only specify --output once."); 519 528 else 520 strOutputFile = strThisArg; 529 strOutputFile = ValueUnion.psz; 530 break; 531 532 case VINF_GETOPT_NOT_OPTION: 533 { 534 Utf8Str strMachine(ValueUnion.psz); 535 // must be machine: try UUID or name 536 ComPtr<IMachine> machine; 537 /* assume it's a UUID */ 538 rc = a->virtualBox->GetMachine(Guid(strMachine), machine.asOutParam()); 539 if (FAILED(rc) || !machine) 540 { 541 /* must be a name */ 542 CHECK_ERROR_BREAK(a->virtualBox, FindMachine(Bstr(strMachine), machine.asOutParam())); 543 } 544 545 if (machine) 546 llMachines.push_back(machine); 521 547 } 522 else 523 return errorSyntax(USAGE_EXPORTAPPLIANCE, "Missing argument to --output option."); 524 } 525 else 526 { 527 // must be machine: try UUID or name 528 ComPtr<IMachine> machine; 529 /* assume it's a UUID */ 530 rc = a->virtualBox->GetMachine(Guid(strThisArg), machine.asOutParam()); 531 if (FAILED(rc) || !machine) 532 { 533 /* must be a name */ 534 CHECK_ERROR_BREAK(a->virtualBox, FindMachine(Bstr(strThisArg), machine.asOutParam())); 535 } 536 537 if (machine) 538 llMachines.push_back(machine); 548 break; 549 550 default: 551 if (c > 0) 552 return errorSyntax(USAGE_LIST, "missing case: %c\n", c); 553 else if (ValueUnion.pDef) 554 return errorSyntax(USAGE_LIST, "%s: %Rrs", ValueUnion.pDef->pszLong, c); 555 else 556 return errorSyntax(USAGE_LIST, "%Rrs", c); 539 557 } 540 558 } … … 544 562 545 563 if (llMachines.size() == 0) 546 return errorSyntax(USAGE_EXPORTAPPLIANCE, "Missing arguments to export command."); 564 return errorSyntax(USAGE_EXPORTAPPLIANCE, "At least one machine must be specified with the export command."); 565 if (!strOutputFile.length()) 566 return errorSyntax(USAGE_EXPORTAPPLIANCE, "Missing --output argument with export command."); 547 567 548 568 ComPtr<IAppliance> pAppliance;
Note:
See TracChangeset
for help on using the changeset viewer.