Changeset 49621 in vbox for trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
- Timestamp:
- Nov 22, 2013 11:15:41 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r49190 r49621 47 47 } 48 48 49 void printUsage(USAGECATEGORY u64Cmd, PRTSTREAM pStrm)49 void printUsage(USAGECATEGORY fCategory, uint32_t fSubCategory, PRTSTREAM pStrm) 50 50 { 51 51 bool fDumpOpts = false; … … 81 81 #endif 82 82 83 if ( u64Cmd== USAGE_DUMPOPTS)83 if (fCategory == USAGE_DUMPOPTS) 84 84 { 85 85 fDumpOpts = true; … … 90 90 fDarwin = true; 91 91 fVBoxSDL = true; 92 u64Cmd= USAGE_ALL;92 fCategory = USAGE_ALL; 93 93 } 94 94 … … 97 97 "\n"); 98 98 99 if ( u64Cmd== USAGE_ALL)99 if (fCategory == USAGE_ALL) 100 100 RTStrmPrintf(pStrm, 101 101 " VBoxManage [<general option>] <command>\n" … … 111 111 const char *pcszSep1 = " "; 112 112 const char *pcszSep2 = " "; 113 if ( u64Cmd!= USAGE_ALL)113 if (fCategory != USAGE_ALL) 114 114 { 115 115 pcszSep1 = "VBoxManage"; … … 119 119 #define SEP pcszSep1, pcszSep2 120 120 121 if ( u64Cmd& USAGE_LIST)121 if (fCategory & USAGE_LIST) 122 122 RTStrmPrintf(pStrm, 123 123 "%s list [--long|-l]%s vms|runningvms|ostypes|hostdvds|hostfloppies|\n" … … 132 132 "\n", SEP); 133 133 134 if ( u64Cmd& USAGE_SHOWVMINFO)134 if (fCategory & USAGE_SHOWVMINFO) 135 135 RTStrmPrintf(pStrm, 136 136 "%s showvminfo %s <uuid|vmname> [--details]\n" … … 139 139 "\n", SEP, SEP); 140 140 141 if ( u64Cmd& USAGE_REGISTERVM)141 if (fCategory & USAGE_REGISTERVM) 142 142 RTStrmPrintf(pStrm, 143 143 "%s registervm %s <filename>\n" 144 144 "\n", SEP); 145 145 146 if ( u64Cmd& USAGE_UNREGISTERVM)146 if (fCategory & USAGE_UNREGISTERVM) 147 147 RTStrmPrintf(pStrm, 148 148 "%s unregistervm %s <uuid|vmname> [--delete]\n" 149 149 "\n", SEP); 150 150 151 if ( u64Cmd& USAGE_CREATEVM)151 if (fCategory & USAGE_CREATEVM) 152 152 RTStrmPrintf(pStrm, 153 153 "%s createvm %s --name <name>\n" … … 159 159 "\n", SEP); 160 160 161 if ( u64Cmd& USAGE_MODIFYVM)161 if (fCategory & USAGE_MODIFYVM) 162 162 { 163 163 RTStrmPrintf(pStrm, … … 382 382 } 383 383 384 if ( u64Cmd& USAGE_CLONEVM)384 if (fCategory & USAGE_CLONEVM) 385 385 RTStrmPrintf(pStrm, 386 386 "%s clonevm %s <uuid|vmname>\n" … … 396 396 "\n", SEP); 397 397 398 if ( u64Cmd& USAGE_IMPORTAPPLIANCE)398 if (fCategory & USAGE_IMPORTAPPLIANCE) 399 399 RTStrmPrintf(pStrm, 400 400 "%s import %s <ovfname/ovaname>\n" … … 405 405 " for a particular OVF)\n\n", SEP); 406 406 407 if ( u64Cmd& USAGE_EXPORTAPPLIANCE)407 if (fCategory & USAGE_EXPORTAPPLIANCE) 408 408 RTStrmPrintf(pStrm, 409 409 "%s export %s <machines> --output|-o <name>.<ovf/ova>\n" … … 422 422 "\n", SEP); 423 423 424 if ( u64Cmd& USAGE_STARTVM)424 if (fCategory & USAGE_STARTVM) 425 425 { 426 426 RTStrmPrintf(pStrm, … … 434 434 } 435 435 436 if ( u64Cmd& USAGE_CONTROLVM)436 if (fCategory & USAGE_CONTROLVM) 437 437 { 438 438 RTStrmPrintf(pStrm, … … 487 487 } 488 488 489 if ( u64Cmd& USAGE_DISCARDSTATE)489 if (fCategory & USAGE_DISCARDSTATE) 490 490 RTStrmPrintf(pStrm, 491 491 "%s discardstate %s <uuid|vmname>\n" 492 492 "\n", SEP); 493 493 494 if ( u64Cmd& USAGE_ADOPTSTATE)494 if (fCategory & USAGE_ADOPTSTATE) 495 495 RTStrmPrintf(pStrm, 496 496 "%s adoptstate %s <uuid|vmname> <state_file>\n" 497 497 "\n", SEP); 498 498 499 if ( u64Cmd& USAGE_SNAPSHOT)499 if (fCategory & USAGE_SNAPSHOT) 500 500 RTStrmPrintf(pStrm, 501 501 "%s snapshot %s <uuid|vmname>\n" … … 511 511 "\n", SEP); 512 512 513 if ( u64Cmd& USAGE_CLOSEMEDIUM)513 if (fCategory & USAGE_CLOSEMEDIUM) 514 514 RTStrmPrintf(pStrm, 515 515 "%s closemedium %s disk|dvd|floppy <uuid|filename>\n" … … 517 517 "\n", SEP); 518 518 519 if ( u64Cmd& USAGE_STORAGEATTACH)519 if (fCategory & USAGE_STORAGEATTACH) 520 520 RTStrmPrintf(pStrm, 521 521 "%s storageattach %s <uuid|vmname>\n" … … 549 549 "\n", SEP); 550 550 551 if ( u64Cmd& USAGE_STORAGECONTROLLER)551 if (fCategory & USAGE_STORAGECONTROLLER) 552 552 RTStrmPrintf(pStrm, 553 553 "%s storagectl %s <uuid|vmname>\n" … … 562 562 "\n", SEP); 563 563 564 if ( u64Cmd& USAGE_BANDWIDTHCONTROL)564 if (fCategory & USAGE_BANDWIDTHCONTROL) 565 565 RTStrmPrintf(pStrm, 566 566 "%s bandwidthctl %s <uuid|vmname>\n" … … 575 575 "\n", SEP); 576 576 577 if ( u64Cmd& USAGE_SHOWHDINFO)577 if (fCategory & USAGE_SHOWHDINFO) 578 578 RTStrmPrintf(pStrm, 579 579 "%s showhdinfo %s <uuid|filename>\n" 580 580 "\n", SEP); 581 581 582 if ( u64Cmd& USAGE_CREATEHD)582 if (fCategory & USAGE_CREATEHD) 583 583 RTStrmPrintf(pStrm, 584 584 "%s createhd %s --filename <filename>\n" … … 589 589 "\n", SEP); 590 590 591 if ( u64Cmd& USAGE_MODIFYHD)591 if (fCategory & USAGE_MODIFYHD) 592 592 RTStrmPrintf(pStrm, 593 593 "%s modifyhd %s <uuid|filename>\n" … … 600 600 "\n", SEP); 601 601 602 if ( u64Cmd& USAGE_CLONEHD)602 if (fCategory & USAGE_CLONEHD) 603 603 RTStrmPrintf(pStrm, 604 604 "%s clonehd %s <uuid|inputfile> <uuid|outputfile>\n" … … 608 608 "\n", SEP); 609 609 610 if ( u64Cmd& USAGE_CONVERTFROMRAW)610 if (fCategory & USAGE_CONVERTFROMRAW) 611 611 RTStrmPrintf(pStrm, 612 612 "%s convertfromraw %s <filename> <outputfile>\n" … … 620 620 "\n", SEP, SEP); 621 621 622 if ( u64Cmd& USAGE_GETEXTRADATA)622 if (fCategory & USAGE_GETEXTRADATA) 623 623 RTStrmPrintf(pStrm, 624 624 "%s getextradata %s global|<uuid|vmname>\n" … … 626 626 "\n", SEP); 627 627 628 if ( u64Cmd& USAGE_SETEXTRADATA)628 if (fCategory & USAGE_SETEXTRADATA) 629 629 RTStrmPrintf(pStrm, 630 630 "%s setextradata %s global|<uuid|vmname>\n" … … 633 633 "\n", SEP); 634 634 635 if ( u64Cmd& USAGE_SETPROPERTY)635 if (fCategory & USAGE_SETPROPERTY) 636 636 RTStrmPrintf(pStrm, 637 637 "%s setproperty %s machinefolder default|<folder> |\n" … … 645 645 "\n", SEP); 646 646 647 if ( u64Cmd& USAGE_USBFILTER_ADD)647 if (fCategory & USAGE_USBFILTER_ADD) 648 648 RTStrmPrintf(pStrm, 649 649 "%s usbfilter %s add <index,0-N>\n" … … 662 662 "\n", SEP); 663 663 664 if ( u64Cmd& USAGE_USBFILTER_MODIFY)664 if (fCategory & USAGE_USBFILTER_MODIFY) 665 665 RTStrmPrintf(pStrm, 666 666 "%s usbfilter %s modify <index,0-N>\n" … … 679 679 "\n", SEP); 680 680 681 if ( u64Cmd& USAGE_USBFILTER_REMOVE)681 if (fCategory & USAGE_USBFILTER_REMOVE) 682 682 RTStrmPrintf(pStrm, 683 683 "%s usbfilter %s remove <index,0-N>\n" … … 685 685 "\n", SEP); 686 686 687 if ( u64Cmd& USAGE_SHAREDFOLDER_ADD)687 if (fCategory & USAGE_SHAREDFOLDER_ADD) 688 688 RTStrmPrintf(pStrm, 689 689 "%s sharedfolder %s add <uuid|vmname>\n" … … 692 692 "\n", SEP); 693 693 694 if ( u64Cmd& USAGE_SHAREDFOLDER_REMOVE)694 if (fCategory & USAGE_SHAREDFOLDER_REMOVE) 695 695 RTStrmPrintf(pStrm, 696 696 "%s sharedfolder %s remove <uuid|vmname>\n" … … 699 699 700 700 #ifdef VBOX_WITH_GUEST_PROPS 701 if ( u64Cmd& USAGE_GUESTPROPERTY)701 if (fCategory & USAGE_GUESTPROPERTY) 702 702 usageGuestProperty(pStrm, SEP); 703 703 #endif /* VBOX_WITH_GUEST_PROPS defined */ 704 704 705 705 #ifdef VBOX_WITH_GUEST_CONTROL 706 if ( u64Cmd& USAGE_GUESTCONTROL)707 usageGuestControl(pStrm, SEP );706 if (fCategory & USAGE_GUESTCONTROL) 707 usageGuestControl(pStrm, SEP, fSubCategory); 708 708 #endif /* VBOX_WITH_GUEST_CONTROL defined */ 709 709 710 if ( u64Cmd& USAGE_DEBUGVM)710 if (fCategory & USAGE_DEBUGVM) 711 711 { 712 712 RTStrmPrintf(pStrm, … … 730 730 "\n", SEP); 731 731 } 732 if ( u64Cmd& USAGE_METRICS)732 if (fCategory & USAGE_METRICS) 733 733 RTStrmPrintf(pStrm, 734 734 "%s metrics %s list [*|host|<vmname> [<metric_list>]]\n" … … 755 755 756 756 #if defined(VBOX_WITH_NAT_SERVICE) 757 if ( u64Cmd& USAGE_NATNETWORK)757 if (fCategory & USAGE_NATNETWORK) 758 758 { 759 759 RTStrmPrintf(pStrm, … … 786 786 787 787 #if defined(VBOX_WITH_NETFLT) 788 if ( u64Cmd& USAGE_HOSTONLYIFS)788 if (fCategory & USAGE_HOSTONLYIFS) 789 789 { 790 790 RTStrmPrintf(pStrm, … … 801 801 #endif 802 802 803 if ( u64Cmd& USAGE_DHCPSERVER)803 if (fCategory & USAGE_DHCPSERVER) 804 804 { 805 805 RTStrmPrintf(pStrm, … … 819 819 "\n", SEP, SEP); 820 820 } 821 if ( u64Cmd& USAGE_EXTPACK)821 if (fCategory & USAGE_EXTPACK) 822 822 { 823 823 RTStrmPrintf(pStrm, … … 833 833 * @returns RTEXITCODE_SYNTAX. 834 834 */ 835 RTEXITCODE errorSyntax(USAGECATEGORY u64Cmd, const char *pszFormat, ...)835 RTEXITCODE errorSyntax(USAGECATEGORY fCategory, const char *pszFormat, ...) 836 836 { 837 837 va_list args; … … 839 839 #ifndef VBOX_ONLY_DOCS 840 840 if (g_fInternalMode) 841 printUsageInternal( u64Cmd, g_pStdErr);841 printUsageInternal(fCategory, g_pStdErr); 842 842 else 843 printUsage( u64Cmd, g_pStdErr);843 printUsage(fCategory, ~0U, g_pStdErr); 844 844 #endif /* !VBOX_ONLY_DOCS */ 845 845 va_start(args, pszFormat); … … 847 847 va_end(args); 848 848 return RTEXITCODE_SYNTAX; 849 } 850 851 /** 852 * Print a usage synopsis and the syntax error message. 853 * @returns RTEXITCODE_SYNTAX. 854 */ 855 RTEXITCODE errorSyntaxEx(USAGECATEGORY fCategory, uint32_t fSubCategory, const char *pszFormat, ...) 856 { 857 va_list args; 858 showLogo(g_pStdErr); // show logo even if suppressed 859 #ifndef VBOX_ONLY_DOCS 860 if (g_fInternalMode) 861 printUsageInternal(fCategory, g_pStdErr); 862 else 863 printUsage(fCategory, fSubCategory, g_pStdErr); 864 #endif /* !VBOX_ONLY_DOCS */ 865 va_start(args, pszFormat); 866 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args); 867 va_end(args); 868 return RTEXITCODE_SYNTAX; 869 } 870 871 /** 872 * errorSyntax for RTGetOpt users. 873 * 874 * @returns RTEXITCODE_SYNTAX. 875 * 876 * @param fCategory The usage category of the command. 877 * @param fSubCategory The usage sub-category of the command. 878 * @param rc The RTGetOpt return code. 879 * @param pValueUnion The value union. 880 */ 881 RTEXITCODE errorGetOptEx(USAGECATEGORY fCategory, uint32_t fSubCategory, int rc, union RTGETOPTUNION const *pValueUnion) 882 { 883 /* 884 * Check if it is an unhandled standard option. 885 */ 886 if (rc == 'V') 887 { 888 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision()); 889 return RTEXITCODE_SUCCESS; 890 } 891 892 if (rc == 'h') 893 { 894 showLogo(g_pStdErr); 895 #ifndef VBOX_ONLY_DOCS 896 if (g_fInternalMode) 897 printUsageInternal(fCategory, g_pStdOut); 898 else 899 printUsage(fCategory, fSubCategory, g_pStdOut); 900 #endif 901 return RTEXITCODE_SUCCESS; 902 } 903 904 /* 905 * General failure. 906 */ 907 showLogo(g_pStdErr); // show logo even if suppressed 908 #ifndef VBOX_ONLY_DOCS 909 if (g_fInternalMode) 910 printUsageInternal(fCategory, g_pStdErr); 911 else 912 printUsage(fCategory, fSubCategory, g_pStdErr); 913 #endif /* !VBOX_ONLY_DOCS */ 914 915 if (rc == VINF_GETOPT_NOT_OPTION) 916 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid parameter '%s'", pValueUnion->psz); 917 if (rc > 0) 918 { 919 if (RT_C_IS_PRINT(rc)) 920 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option -%c", rc); 921 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option case %i", rc); 922 } 923 if (rc == VERR_GETOPT_UNKNOWN_OPTION) 924 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown option: %s", pValueUnion->psz); 925 if (rc == VERR_GETOPT_INVALID_ARGUMENT_FORMAT) 926 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid argument format: %s", pValueUnion->psz); 927 if (pValueUnion->pDef) 928 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, rc); 929 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%Rrs", rc); 849 930 } 850 931 … … 858 939 * @param pValueUnion The value union. 859 940 */ 860 RTEXITCODE errorGetOpt(USAGECATEGORY f UsageCategory, int rc, union RTGETOPTUNION const *pValueUnion)941 RTEXITCODE errorGetOpt(USAGECATEGORY fCategory, int rc, union RTGETOPTUNION const *pValueUnion) 861 942 { 862 /* 863 * Check if it is an unhandled standard option. 864 */ 865 if (rc == 'V') 866 { 867 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision()); 868 return RTEXITCODE_SUCCESS; 869 } 870 871 if (rc == 'h') 872 { 873 showLogo(g_pStdErr); 874 #ifndef VBOX_ONLY_DOCS 875 if (g_fInternalMode) 876 printUsageInternal(fUsageCategory, g_pStdOut); 877 else 878 printUsage(fUsageCategory, g_pStdOut); 879 #endif 880 return RTEXITCODE_SUCCESS; 881 } 882 883 /* 884 * General failure. 885 */ 886 showLogo(g_pStdErr); // show logo even if suppressed 887 #ifndef VBOX_ONLY_DOCS 888 if (g_fInternalMode) 889 printUsageInternal(fUsageCategory, g_pStdErr); 890 else 891 printUsage(fUsageCategory, g_pStdErr); 892 #endif /* !VBOX_ONLY_DOCS */ 893 894 if (rc == VINF_GETOPT_NOT_OPTION) 895 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid parameter '%s'", pValueUnion->psz); 896 if (rc > 0) 897 { 898 if (RT_C_IS_PRINT(rc)) 899 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option -%c", rc); 900 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option case %i", rc); 901 } 902 if (rc == VERR_GETOPT_UNKNOWN_OPTION) 903 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown option: %s", pValueUnion->psz); 904 if (rc == VERR_GETOPT_INVALID_ARGUMENT_FORMAT) 905 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid argument format: %s", pValueUnion->psz); 906 if (pValueUnion->pDef) 907 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, rc); 908 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%Rrs", rc); 943 return errorGetOptEx(fCategory, ~0U, rc, pValueUnion); 909 944 } 910 945
Note:
See TracChangeset
for help on using the changeset viewer.