Changeset 49621 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Nov 22, 2013 11:15:41 AM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/Makefile.kmk
r49165 r49621 23 23 endif 24 24 VBoxManageHelp_TEMPLATE = VBoxAdvBldProg 25 VBoxManageHelp_DEFS += VBOX_ONLY_DOCS 26 VBoxManageHelp_SOURCES = \ 25 VBoxManageHelp_DEFS += \ 26 VBOX_ONLY_DOCS \ 27 $(if $(VBOX_WITH_GUEST_CONTROL),VBOX_WITH_GUEST_CONTROL) 28 VBoxManageHelp_SOURCES = \ 27 29 VBoxManage.cpp \ 28 30 VBoxManageHelp.cpp \ … … 35 37 VBoxManage_TEMPLATE = VBOXMAINCLIENTEXE 36 38 VBoxManage_DEFS.win = _WIN32_WINNT=0x0500 37 VBoxManage_SOURCES = \39 VBoxManage_SOURCES = \ 38 40 VBoxManage.cpp \ 39 41 VBoxInternalManage.cpp \ -
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r48878 r49621 2384 2384 2385 2385 default: 2386 return errorGetOpt(USAGE_DEBUGLOG 2386 return errorGetOpt(USAGE_DEBUGLOG, ch, &ValueUnion); 2387 2387 } 2388 2388 } … … 2454 2454 2455 2455 default: 2456 return errorGetOpt(USAGE_GUESTSTATS 2456 return errorGetOpt(USAGE_GUESTSTATS, ch, &ValueUnion); 2457 2457 } 2458 2458 } … … 2523 2523 return CmdLoadSyms(a->argc - 1, &a->argv[1], a->virtualBox, a->session); 2524 2524 //if (!strcmp(pszCmd, "unloadsyms")) 2525 // return CmdUnloadSyms(argc - 1 2525 // return CmdUnloadSyms(argc - 1, &a->argv[1]); 2526 2526 if (!strcmp(pszCmd, "sethduuid") || !strcmp(pszCmd, "sethdparentuuid")) 2527 2527 return CmdSetHDUUID(a->argc, &a->argv[0], a->virtualBox, a->session); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r46649 r49621 333 333 { 334 334 showLogo(g_pStdOut); 335 printUsage(USAGE_ALL, g_pStdOut);335 printUsage(USAGE_ALL, ~0U, g_pStdOut); 336 336 return 0; 337 337 } … … 357 357 /* Special option to dump really all commands, 358 358 * even the ones not understood on this platform. */ 359 printUsage(USAGE_DUMPOPTS, g_pStdOut);359 printUsage(USAGE_DUMPOPTS, ~0U, g_pStdOut); 360 360 return 0; 361 361 } … … 555 555 && s_commandHandlers[commandIndex].help)) 556 556 { 557 printUsage(s_commandHandlers[commandIndex].help, g_pStdOut);557 printUsage(s_commandHandlers[commandIndex].help, ~0U, g_pStdOut); 558 558 rcExit = RTEXITCODE_FAILURE; /* error */ 559 559 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r47908 r49621 30 30 #include <iprt/message.h> 31 31 #include <iprt/stream.h> 32 #include <iprt/getopt.h> 32 33 33 34 //////////////////////////////////////////////////////////////////////////////// … … 106 107 /** @} */ 107 108 109 #ifdef VBOX_WITH_GUEST_CONTROL 110 # define USAGE_GSTCTRL_EXEC RT_BIT(0) 111 # define USAGE_GSTCTRL_COPYFROM RT_BIT(1) 112 # define USAGE_GSTCTRL_COPYTO RT_BIT(2) 113 # define USAGE_GSTCTRL_CREATEDIR RT_BIT(3) 114 # define USAGE_GSTCTRL_REMOVEDIR RT_BIT(4) 115 # define USAGE_GSTCTRL_REMOVEFILE RT_BIT(5) 116 # define USAGE_GSTCTRL_RENAME RT_BIT(6) 117 # define USAGE_GSTCTRL_CREATETEMP RT_BIT(7) 118 # define USAGE_GSTCTRL_LIST RT_BIT(8) 119 # define USAGE_GSTCTRL_PROCESS RT_BIT(9) 120 # define USAGE_GSTCTRL_KILL RT_BIT(10) 121 # define USAGE_GSTCTRL_SESSION RT_BIT(11) 122 # define USAGE_GSTCTRL_STAT RT_BIT(12) 123 # define USAGE_GSTCTRL_UPDATEADDS RT_BIT(13) 124 # define USAGE_GSTCTRL_WATCH RT_BIT(14) 125 #endif 126 108 127 typedef uint64_t USAGECATEGORY; 109 128 … … 148 167 149 168 /* VBoxManageHelp.cpp */ 150 void printUsage(USAGECATEGORY u64Cmd, PRTSTREAM pStrm); 151 RTEXITCODE errorSyntax(USAGECATEGORY u64Cmd, const char *pszFormat, ...); 152 RTEXITCODE errorGetOpt(USAGECATEGORY u64Cmd, int rc, union RTGETOPTUNION const *pValueUnion); 169 void printUsage(USAGECATEGORY fCategory, uint32_t fSubCategory, PRTSTREAM pStrm); 170 RTEXITCODE errorSyntax(USAGECATEGORY fCategory, const char *pszFormat, ...); 171 RTEXITCODE errorSyntaxEx(USAGECATEGORY fCategory, uint32_t fSubCategory, const char *pszFormat, ...); 172 RTEXITCODE errorGetOpt(USAGECATEGORY fCategory, int rc, union RTGETOPTUNION const *pValueUnion); 173 RTEXITCODE errorGetOptEx(USAGECATEGORY fCategory, uint32_t fSubCategory, int rc, union RTGETOPTUNION const *pValueUnion); 153 174 RTEXITCODE errorArgument(const char *pszFormat, ...); 154 175 155 void printUsageInternal(USAGECATEGORY u64Cmd, PRTSTREAM pStrm);176 void printUsageInternal(USAGECATEGORY fCategory, PRTSTREAM pStrm); 156 177 157 178 #ifndef VBOX_ONLY_DOCS … … 187 208 188 209 /* VBoxManageGuestCtrl.cpp */ 189 extern void usageGuestControl(PRTSTREAM pStrm, const char *pcszSep1, const char *pcszSep2 );210 extern void usageGuestControl(PRTSTREAM pStrm, const char *pcszSep1, const char *pcszSep2, uint32_t fSubCategory); 190 211 191 212 #ifndef VBOX_ONLY_DOCS -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageBandwidthControl.cpp
r48950 r49621 275 275 switch (c) 276 276 { 277 case 'M': enmDetails = VMINFO_MACHINEREADABLE; break; 278 default: return errorGetOpt(USAGE_BANDWIDTHCONTROL, c, &ValueUnion); 277 case 'M': 278 enmDetails = VMINFO_MACHINEREADABLE; 279 break; 280 default: 281 return errorGetOpt(USAGE_BANDWIDTHCONTROL, c, &ValueUnion); 279 282 } 280 283 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r49503 r49621 301 301 #endif /* VBOX_ONLY_DOCS */ 302 302 303 void usageGuestControl(PRTSTREAM pStrm, const char *pcszSep1, const char *pcszSep2 )303 void usageGuestControl(PRTSTREAM pStrm, const char *pcszSep1, const char *pcszSep2, uint32_t uSubCmd) 304 304 { 305 305 RTStrmPrintf(pStrm, 306 "%s guestcontrol %s <uuid|vmname>\n" 307 " exec[ute]\n" 308 " --image <path to program> --username <name>\n" 309 " [--passwordfile <file> | --password <password>]\n" 310 " [--domain <domain>] [--verbose] [--timeout <msec>]\n" 311 " [--environment \"<NAME>=<VALUE> [<NAME>=<VALUE>]\"]\n" 312 " [--wait-exit] [--wait-stdout] [--wait-stderr]\n" 313 " [--dos2unix] [--unix2dos]\n" 314 " [-- [<argument1>] ... [<argumentN>]]\n" 315 /** @todo Add a "--" parameter (has to be last parameter) to directly execute 316 * stuff, e.g. "VBoxManage guestcontrol execute <VMName> --username <> ... -- /bin/rm -Rf /foo". */ 317 "\n" 318 " copyfrom\n" 319 " <guest source> <host dest> --username <name>\n" 320 " [--passwordfile <file> | --password <password>]\n" 321 " [--domain <domain>] [--verbose]\n" 322 " [--dryrun] [--follow] [--recursive]\n" 323 "\n" 324 " copyto|cp\n" 325 " <host source> <guest dest> --username <name>\n" 326 " [--passwordfile <file> | --password <password>]\n" 327 " [--domain <domain>] [--verbose]\n" 328 " [--dryrun] [--follow] [--recursive]\n" 329 "\n" 330 " createdir[ectory]|mkdir|md\n" 331 " <guest directory>... --username <name>\n" 332 " [--passwordfile <file> | --password <password>]\n" 333 " [--domain <domain>] [--verbose]\n" 334 " [--parents] [--mode <mode>]\n" 335 "\n" 336 " removedir[ectory]|rmdir\n" 337 " <guest directory>... --username <name>\n" 338 " [--passwordfile <file> | --password <password>]\n" 339 " [--domain <domain>] [--verbose]\n" 340 " [--recursive|-R|-r]\n" 341 "\n" 342 " removefile|rm\n" 343 " <guest file>... --username <name>\n" 344 " [--passwordfile <file> | --password <password>]\n" 345 " [--domain <domain>] [--verbose]\n" 346 "\n" 347 " ren[ame]|mv\n" 348 " <source>... <dest> --username <name>\n" 349 " [--passwordfile <file> | --password <password>]\n" 350 " [--domain <domain>] [--verbose]\n" 351 "\n" 352 " createtemp[orary]|mktemp\n" 353 " <template> --username <name>\n" 354 " [--passwordfile <file> | --password <password>]\n" 355 " [--directory] [--secure] [--tmpdir <directory>]\n" 356 " [--domain <domain>] [--mode <mode>] [--verbose]\n" 357 "\n" 358 " list <all|sessions|processes|files> [--verbose]\n" 359 "\n" 360 /** @todo Add an own help group for "session" and "process" sub commands. */ 361 " process kill --session-id <ID>\n" 306 "%s guestcontrol %s <uuid|vmname>\n%s", 307 pcszSep1, pcszSep2, 308 uSubCmd == ~0U ? "\n" : ""); 309 if (uSubCmd & USAGE_GSTCTRL_EXEC) 310 RTStrmPrintf(pStrm, 311 " exec[ute]\n" 312 " --image <path to program> --username <name>\n" 313 " [--passwordfile <file> | --password <password>]\n" 314 " [--domain <domain>] [--verbose] [--timeout <msec>]\n" 315 " [--environment \"<NAME>=<VALUE> [<NAME>=<VALUE>]\"]\n" 316 " [--wait-exit] [--wait-stdout] [--wait-stderr]\n" 317 " [--dos2unix] [--unix2dos]\n" 318 " [-- [<argument1>] ... [<argumentN>]]\n" 319 "\n"); 320 if (uSubCmd & USAGE_GSTCTRL_COPYFROM) 321 RTStrmPrintf(pStrm, 322 " copyfrom\n" 323 " <guest source> <host dest> --username <name>\n" 324 " [--passwordfile <file> | --password <password>]\n" 325 " [--domain <domain>] [--verbose]\n" 326 " [--dryrun] [--follow] [--recursive]\n" 327 "\n"); 328 if (uSubCmd & USAGE_GSTCTRL_COPYTO) 329 RTStrmPrintf(pStrm, 330 " copyto|cp\n" 331 " <host source> <guest dest> --username <name>\n" 332 " [--passwordfile <file> | --password <password>]\n" 333 " [--domain <domain>] [--verbose]\n" 334 " [--dryrun] [--follow] [--recursive]\n" 335 "\n"); 336 if (uSubCmd & USAGE_GSTCTRL_CREATEDIR) 337 RTStrmPrintf(pStrm, 338 " createdir[ectory]|mkdir|md\n" 339 " <guest directory>... --username <name>\n" 340 " [--passwordfile <file> | --password <password>]\n" 341 " [--domain <domain>] [--verbose]\n" 342 " [--parents] [--mode <mode>]\n" 343 "\n"); 344 if (uSubCmd & USAGE_GSTCTRL_REMOVEDIR) 345 RTStrmPrintf(pStrm, 346 " removedir[ectory]|rmdir\n" 347 " <guest directory>... --username <name>\n" 348 " [--passwordfile <file> | --password <password>]\n" 349 " [--domain <domain>] [--verbose]\n" 350 " [--recursive|-R|-r]\n" 351 "\n"); 352 if (uSubCmd & USAGE_GSTCTRL_REMOVEFILE) 353 RTStrmPrintf(pStrm, 354 " removefile|rm\n" 355 " <guest file>... --username <name>\n" 356 " [--passwordfile <file> | --password <password>]\n" 357 " [--domain <domain>] [--verbose]\n" 358 "\n"); 359 if (uSubCmd & USAGE_GSTCTRL_RENAME) 360 RTStrmPrintf(pStrm, 361 " ren[ame]|mv\n" 362 " <source>... <dest> --username <name>\n" 363 " [--passwordfile <file> | --password <password>]\n" 364 " [--domain <domain>] [--verbose]\n" 365 "\n"); 366 if (uSubCmd & USAGE_GSTCTRL_CREATETEMP) 367 RTStrmPrintf(pStrm, 368 " createtemp[orary]|mktemp\n" 369 " <template> --username <name>\n" 370 " [--passwordfile <file> | --password <password>]\n" 371 " [--directory] [--secure] [--tmpdir <directory>]\n" 372 " [--domain <domain>] [--mode <mode>] [--verbose]\n" 373 "\n"); 374 if (uSubCmd & USAGE_GSTCTRL_LIST) 375 RTStrmPrintf(pStrm, 376 " list <all|sessions|processes|files> [--verbose]\n" 377 "\n"); 378 /** @todo Add an own help group for "session" and "process" sub commands. */ 379 if (uSubCmd & USAGE_GSTCTRL_PROCESS) 380 RTStrmPrintf(pStrm, 381 " process kill --session-id <ID>\n" 382 " | --session-name <name or pattern>\n" 383 " [--verbose]\n" 384 " <PID> ... <PID n>\n" 385 "\n"); 386 if (uSubCmd & USAGE_GSTCTRL_KILL) 387 RTStrmPrintf(pStrm, 388 " [p[s]]kill --session-id <ID>\n" 362 389 " | --session-name <name or pattern>\n" 363 390 " [--verbose]\n" 364 391 " <PID> ... <PID n>\n" 365 "\n" 366 " [p[s]]kill --session-id <ID>\n" 367 " | --session-name <name or pattern>\n" 368 " [--verbose]\n" 369 " <PID> ... <PID n>\n" 370 "\n" 371 " session close --session-id <ID>\n" 372 " | --session-name <name or pattern>\n" 373 " | --all\n" 374 " [--verbose]\n" 375 " stat\n" 376 " <file>... --username <name>\n" 377 " [--passwordfile <file> | --password <password>]\n" 378 " [--domain <domain>] [--verbose]\n" 379 "\n" 380 " updateadditions\n" 381 " [--source <guest additions .ISO>] [--verbose]\n" 382 " [--wait-start]\n" 383 " [-- [<argument1>] ... [<argumentN>]]\n" 384 "\n" 385 " watch [--verbose]\n" 386 "\n", pcszSep1, pcszSep2); 392 "\n"); 393 if (uSubCmd & USAGE_GSTCTRL_SESSION) 394 RTStrmPrintf(pStrm, 395 " session close --session-id <ID>\n" 396 " | --session-name <name or pattern>\n" 397 " | --all\n" 398 " [--verbose]\n" 399 "\n"); 400 if (uSubCmd & USAGE_GSTCTRL_STAT) 401 RTStrmPrintf(pStrm, 402 " stat\n" 403 " <file>... --username <name>\n" 404 " [--passwordfile <file> | --password <password>]\n" 405 " [--domain <domain>] [--verbose]\n" 406 "\n"); 407 if (uSubCmd & USAGE_GSTCTRL_UPDATEADDS) 408 RTStrmPrintf(pStrm, 409 " updateadditions\n" 410 " [--source <guest additions .ISO>] [--verbose]\n" 411 " [--wait-start]\n" 412 " [-- [<argument1>] ... [<argumentN>]]\n" 413 "\n"); 414 if (uSubCmd & USAGE_GSTCTRL_WATCH) 415 RTStrmPrintf(pStrm, 416 " watch [--verbose]\n" 417 "\n"); 387 418 } 388 419 … … 749 780 */ 750 781 static RTEXITCODE ctrlInitVM(HandlerArg *pArg, 751 PGCTLCMDCTX pCtx, uint32_t uFlags )782 PGCTLCMDCTX pCtx, uint32_t uFlags, uint32_t uUsage) 752 783 { 753 784 AssertPtrReturn(pArg, RTEXITCODE_FAILURE); … … 859 890 iArgIdx = GetState.iNext; 860 891 break; 892 893 case 'h': /* Help */ 894 errorGetOptEx(USAGE_GUESTCONTROL, uUsage, ch, &ValueUnion); 895 return RTEXITCODE_SYNTAX; 861 896 862 897 default: … … 909 944 { 910 945 if (pCtx->strUsername.isEmpty()) 911 rcExit = errorSyntax (USAGE_GUESTCONTROL, "No user name specified!");946 rcExit = errorSyntaxEx(USAGE_GUESTCONTROL, uUsage, "No user name specified!"); 912 947 } 913 948 } … … 1160 1195 case GETOPTDEF_EXEC_DOS2UNIX: 1161 1196 if (eOutputType != OUTPUTTYPE_UNDEFINED) 1162 return errorSyntax(USAGE_GUESTCONTROL, "More than one output type (dos2unix/unix2dos) specified!"); 1197 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_EXEC, 1198 "More than one output type (dos2unix/unix2dos) specified!"); 1163 1199 eOutputType = OUTPUTTYPE_DOS2UNIX; 1164 1200 break; … … 1171 1207 vrc = RTGetOptArgvFromString(&papszArg, &cArgs, ValueUnion.psz, NULL); 1172 1208 if (RT_FAILURE(vrc)) 1173 return errorSyntax(USAGE_GUESTCONTROL, "Failed to parse environment value, rc=%Rrc", vrc); 1209 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_EXEC, 1210 "Failed to parse environment value, rc=%Rrc", vrc); 1174 1211 for (int j = 0; j < cArgs; j++) 1175 1212 aEnv.push_back(Bstr(papszArg[j]).raw()); … … 1199 1236 case GETOPTDEF_EXEC_UNIX2DOS: 1200 1237 if (eOutputType != OUTPUTTYPE_UNDEFINED) 1201 return errorSyntax(USAGE_GUESTCONTROL, "More than one output type (dos2unix/unix2dos) specified!"); 1238 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_EXEC, 1239 "More than one output type (dos2unix/unix2dos) specified!"); 1202 1240 eOutputType = OUTPUTTYPE_UNIX2DOS; 1203 1241 break; … … 1233 1271 aArgs.push_back(Bstr(ValueUnion.psz).raw()); 1234 1272 else 1235 return RTGetOptPrintError(ch, &ValueUnion);1273 return errorGetOptEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_EXEC, ch, &ValueUnion); 1236 1274 break; 1237 1275 … … 1248 1286 1249 1287 if (strCmd.isEmpty()) 1250 return errorSyntax(USAGE_GUESTCONTROL, "No command to execute specified!"); 1288 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_EXEC, 1289 "No command to execute specified!"); 1251 1290 1252 1291 /** @todo Any output conversion not supported yet! */ 1253 1292 if (eOutputType != OUTPUTTYPE_UNDEFINED) 1254 return errorSyntax(USAGE_GUESTCONTROL, "Output conversion not implemented yet!"); 1293 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_EXEC, 1294 "Output conversion not implemented yet!"); 1255 1295 1256 1296 RTEXITCODE rcExit = RTEXITCODE_SUCCESS; … … 2394 2434 bool fCopyRecursive = false; 2395 2435 bool fDryRun = false; 2436 uint32_t uUsage = fHostToGuest ? USAGE_GSTCTRL_COPYTO : USAGE_GSTCTRL_COPYFROM; 2396 2437 2397 2438 SOURCEVEC vecSources; … … 2438 2479 2439 2480 default: 2440 return RTGetOptPrintError(ch, &ValueUnion); 2441 break; 2481 return errorGetOptEx(USAGE_GUESTCONTROL, uUsage, ch, &ValueUnion); 2442 2482 } 2443 2483 } 2444 2484 2445 2485 if (!vecSources.size()) 2446 return errorSyntax (USAGE_GUESTCONTROL,2447 "No source(s) specified!");2486 return errorSyntaxEx(USAGE_GUESTCONTROL, uUsage, 2487 "No source(s) specified!"); 2448 2488 2449 2489 if (strDest.isEmpty()) 2450 return errorSyntax (USAGE_GUESTCONTROL,2451 "No destination specified!");2490 return errorSyntaxEx(USAGE_GUESTCONTROL, uUsage, 2491 "No destination specified!"); 2452 2492 2453 2493 /* … … 2663 2703 2664 2704 default: 2665 return RTGetOptPrintError(ch, &ValueUnion); 2666 break; 2705 return errorGetOptEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_CREATEDIR, ch, &ValueUnion); 2667 2706 } 2668 2707 } … … 2670 2709 uint32_t cDirs = mapDirs.size(); 2671 2710 if (!cDirs) 2672 return errorSyntax(USAGE_GUESTCONTROL, "No directory to create specified!"); 2711 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_CREATEDIR, 2712 "No directory to create specified!"); 2673 2713 2674 2714 /* … … 2726 2766 2727 2767 default: 2728 return RTGetOptPrintError(ch, &ValueUnion); 2729 break; 2768 return errorGetOptEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_REMOVEDIR, ch, &ValueUnion); 2730 2769 } 2731 2770 } … … 2733 2772 uint32_t cDirs = mapDirs.size(); 2734 2773 if (!cDirs) 2735 return errorSyntax(USAGE_GUESTCONTROL, "No directory to remove specified!"); 2774 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_REMOVEDIR, 2775 "No directory to remove specified!"); 2736 2776 2737 2777 /* … … 2809 2849 2810 2850 default: 2811 return RTGetOptPrintError(ch, &ValueUnion); 2812 break; 2851 return errorGetOptEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_REMOVEFILE, ch, &ValueUnion); 2813 2852 } 2814 2853 } … … 2816 2855 uint32_t cFiles = mapDirs.size(); 2817 2856 if (!cFiles) 2818 return errorSyntax(USAGE_GUESTCONTROL, "No file to remove specified!"); 2857 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_REMOVEFILE, 2858 "No file to remove specified!"); 2819 2859 2820 2860 /* … … 2879 2919 2880 2920 default: 2881 return RTGetOptPrintError(ch, &ValueUnion); 2882 break; 2921 return errorGetOptEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_RENAME, ch, &ValueUnion); 2883 2922 } 2884 2923 } … … 2894 2933 uint32_t cSources = vecSources.size(); 2895 2934 if (!cSources) 2896 return errorSyntax(USAGE_GUESTCONTROL, "No source(s) to move specified!"); 2935 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_RENAME, 2936 "No source(s) to move specified!"); 2897 2937 if (cSources < 2) 2898 return errorSyntax(USAGE_GUESTCONTROL, "No destination specified!"); 2938 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_RENAME, 2939 "No destination specified!"); 2899 2940 2900 2941 /* Delete last element, which now is the destination. */ … … 3055 3096 strTemplate = ValueUnion.psz; 3056 3097 else 3057 return errorSyntax (USAGE_GUESTCONTROL,3058 "More than one template specified!\n");3098 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_CREATETEMP, 3099 "More than one template specified!\n"); 3059 3100 break; 3060 3101 } 3061 3102 3062 3103 default: 3063 return RTGetOptPrintError(ch, &ValueUnion); 3064 break; 3104 return errorGetOptEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_CREATETEMP, ch, &ValueUnion); 3065 3105 } 3066 3106 } 3067 3107 3068 3108 if (strTemplate.isEmpty()) 3069 return errorSyntax(USAGE_GUESTCONTROL, "No template specified!"); 3109 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_CREATETEMP, 3110 "No template specified!"); 3070 3111 3071 3112 if (!fDirectory) 3072 return errorSyntax(USAGE_GUESTCONTROL, "Creating temporary files is currently not supported!"); 3113 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_CREATETEMP, 3114 "Creating temporary files is currently not supported!"); 3073 3115 3074 3116 /* … … 3136 3178 case 'c': /* Format */ 3137 3179 case 't': /* Terse */ 3138 return errorSyntax(USAGE_GUESTCONTROL, "Command \"%s\" not implemented yet!", 3139 ValueUnion.psz); 3140 break; /* Never reached. */ 3180 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_STAT, 3181 "Command \"%s\" not implemented yet!", ValueUnion.psz); 3141 3182 3142 3183 case VINF_GETOPT_NOT_OPTION: … … 3145 3186 3146 3187 default: 3147 return RTGetOptPrintError(ch, &ValueUnion); 3148 break; 3188 return errorGetOptEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_STAT, ch, &ValueUnion); 3149 3189 } 3150 3190 } … … 3152 3192 uint32_t cObjs = mapObjs.size(); 3153 3193 if (!cObjs) 3154 return errorSyntax(USAGE_GUESTCONTROL, "No element(s) to check specified!"); 3194 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_STAT, 3195 "No element(s) to check specified!"); 3155 3196 3156 3197 HRESULT rc; … … 3257 3298 3258 3299 default: 3259 return RTGetOptPrintError(ch, &ValueUnion); 3260 break; 3300 return errorGetOptEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_UPDATEADDS, ch, &ValueUnion); 3261 3301 } 3262 3302 } … … 3335 3375 3336 3376 if (pCtx->iArgc < 1) 3337 return errorSyntax(USAGE_GUESTCONTROL, "Must specify a listing category"); 3377 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_LIST, 3378 "Must specify a listing category"); 3338 3379 3339 3380 RTEXITCODE rcExit = RTEXITCODE_SUCCESS; … … 3459 3500 } 3460 3501 else 3461 return errorSyntax(USAGE_GUESTCONTROL, "Invalid listing category '%s", pCtx->ppaArgv[0]); 3502 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_LIST, 3503 "Invalid listing category '%s", pCtx->ppaArgv[0]); 3462 3504 3463 3505 return rcExit; … … 3469 3511 3470 3512 if (pCtx->iArgc < 1) 3471 return errorSyntax(USAGE_GUESTCONTROL, "Must specify at least a PID to close"); 3513 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_PROCESS, 3514 "Must specify at least a PID to close"); 3472 3515 3473 3516 static const RTGETOPTDEF s_aOptions[] = … … 3524 3567 3525 3568 default: 3526 return RTGetOptPrintError(ch, &ValueUnion); 3527 break; 3569 return errorGetOptEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_PROCESS, ch, &ValueUnion); 3528 3570 } 3529 3571 } 3530 3572 3531 3573 if (vecPID.empty()) 3532 return errorSyntax(USAGE_GUESTCONTROL, "At least one PID must be specified to kill!"); 3533 else if ( strSessionName.isEmpty() 3534 && ulSessionID == UINT32_MAX) 3535 { 3536 return errorSyntax(USAGE_GUESTCONTROL, "No session ID specified!"); 3537 } 3538 else if ( !strSessionName.isEmpty() 3539 && ulSessionID != UINT32_MAX) 3540 { 3541 return errorSyntax(USAGE_GUESTCONTROL, "Either session ID or name (pattern) must be specified"); 3542 } 3574 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_PROCESS, 3575 "At least one PID must be specified to kill!"); 3576 3577 if ( strSessionName.isEmpty() 3578 && ulSessionID == UINT32_MAX) 3579 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_PROCESS, 3580 "No session ID specified!"); 3581 3582 if ( !strSessionName.isEmpty() 3583 && ulSessionID != UINT32_MAX) 3584 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_PROCESS, 3585 "Either session ID or name (pattern) must be specified"); 3543 3586 3544 3587 if (RT_FAILURE(vrc)) 3545 return errorSyntax(USAGE_GUESTCONTROL, "Invalid parameters specified"); 3588 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_PROCESS, 3589 "Invalid parameters specified"); 3546 3590 3547 3591 HRESULT rc = S_OK; … … 3646 3690 3647 3691 if (pCtx->iArgc < 1) 3648 return errorSyntax(USAGE_GUESTCONTROL, "Must specify an action"); 3692 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_PROCESS, 3693 "Must specify an action"); 3649 3694 3650 3695 /** Use RTGetOpt here when handling command line args gets more complex. */ … … 3658 3703 } 3659 3704 3660 return errorSyntax(USAGE_GUESTCONTROL, "Invalid process action '%s'", pCtx->ppaArgv[0]); 3705 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_PROCESS, 3706 "Invalid process action '%s'", pCtx->ppaArgv[0]); 3661 3707 } 3662 3708 … … 3666 3712 3667 3713 if (pCtx->iArgc < 1) 3668 return errorSyntax(USAGE_GUESTCONTROL, "Must specify at least a session to close"); 3714 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_SESSION, 3715 "Must specify at least a session to close"); 3669 3716 3670 3717 static const RTGETOPTDEF s_aOptions[] = … … 3706 3753 3707 3754 default: 3708 return RTGetOptPrintError(ch, &ValueUnion); 3709 break; 3755 return errorGetOptEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_SESSION, ch, &ValueUnion); 3710 3756 } 3711 3757 } … … 3713 3759 if ( strSessionName.isEmpty() 3714 3760 && ulSessionID == UINT32_MAX) 3715 { 3716 return errorSyntax(USAGE_GUESTCONTROL, "No session ID specified!"); 3717 } 3718 else if ( !strSessionName.isEmpty() 3719 && ulSessionID != UINT32_MAX) 3720 { 3721 return errorSyntax(USAGE_GUESTCONTROL, "Either session ID or name (pattern) must be specified"); 3722 } 3761 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_SESSION, 3762 "No session ID specified!"); 3763 3764 if ( !strSessionName.isEmpty() 3765 && ulSessionID != UINT32_MAX) 3766 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_SESSION, 3767 "Either session ID or name (pattern) must be specified"); 3723 3768 3724 3769 HRESULT rc = S_OK; … … 3786 3831 3787 3832 if (pCtx->iArgc < 1) 3788 return errorSyntax(USAGE_GUESTCONTROL, "Must specify an action"); 3833 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_SESSION, 3834 "Must specify an action"); 3789 3835 3790 3836 /** Use RTGetOpt here when handling command line args gets more complex. */ … … 3798 3844 } 3799 3845 3800 return errorSyntax(USAGE_GUESTCONTROL, "Invalid session action '%s'", pCtx->ppaArgv[0]); 3846 return errorSyntaxEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_SESSION, 3847 "Invalid session action '%s'", pCtx->ppaArgv[0]); 3801 3848 } 3802 3849 … … 3825 3872 3826 3873 default: 3827 return RTGetOptPrintError(ch, &ValueUnion); 3828 break; 3874 return errorGetOptEx(USAGE_GUESTCONTROL, USAGE_GSTCTRL_WATCH, ch, &ValueUnion); 3829 3875 } 3830 3876 } … … 3908 3954 3909 3955 uint32_t uCmdCtxFlags = 0; 3956 uint32_t uUsage; 3910 3957 GCTLCMD gctlCmd; 3911 3958 if ( !RTStrICmp(pArg->argv[1], "exec") 3912 3959 || !RTStrICmp(pArg->argv[1], "execute")) 3960 { 3913 3961 gctlCmd.pfnHandler = handleCtrlProcessExec; 3962 uUsage = USAGE_GSTCTRL_EXEC; 3963 } 3914 3964 else if (!RTStrICmp(pArg->argv[1], "copyfrom")) 3965 { 3915 3966 gctlCmd.pfnHandler = handleCtrlCopyFrom; 3967 uUsage = USAGE_GSTCTRL_COPYFROM; 3968 } 3916 3969 else if ( !RTStrICmp(pArg->argv[1], "copyto") 3917 3970 || !RTStrICmp(pArg->argv[1], "cp")) 3971 { 3918 3972 gctlCmd.pfnHandler = handleCtrlCopyTo; 3973 uUsage = USAGE_GSTCTRL_COPYTO; 3974 } 3919 3975 else if ( !RTStrICmp(pArg->argv[1], "createdirectory") 3920 3976 || !RTStrICmp(pArg->argv[1], "createdir") 3921 3977 || !RTStrICmp(pArg->argv[1], "mkdir") 3922 3978 || !RTStrICmp(pArg->argv[1], "md")) 3979 { 3923 3980 gctlCmd.pfnHandler = handleCtrlCreateDirectory; 3981 uUsage = USAGE_GSTCTRL_CREATEDIR; 3982 } 3924 3983 else if ( !RTStrICmp(pArg->argv[1], "removedirectory") 3925 3984 || !RTStrICmp(pArg->argv[1], "removedir") 3926 3985 || !RTStrICmp(pArg->argv[1], "rmdir")) 3986 { 3927 3987 gctlCmd.pfnHandler = handleCtrlRemoveDirectory; 3988 uUsage = USAGE_GSTCTRL_REMOVEDIR; 3989 } 3928 3990 else if ( !RTStrICmp(pArg->argv[1], "rm") 3929 3991 || !RTStrICmp(pArg->argv[1], "removefile")) 3992 { 3930 3993 gctlCmd.pfnHandler = handleCtrlRemoveFile; 3994 uUsage = USAGE_GSTCTRL_REMOVEFILE; 3995 } 3931 3996 else if ( !RTStrICmp(pArg->argv[1], "ren") 3932 3997 || !RTStrICmp(pArg->argv[1], "rename") 3933 3998 || !RTStrICmp(pArg->argv[1], "mv")) 3999 { 3934 4000 gctlCmd.pfnHandler = handleCtrlRename; 4001 uUsage = USAGE_GSTCTRL_RENAME; 4002 } 3935 4003 else if ( !RTStrICmp(pArg->argv[1], "createtemporary") 3936 4004 || !RTStrICmp(pArg->argv[1], "createtemp") 3937 4005 || !RTStrICmp(pArg->argv[1], "mktemp")) 4006 { 3938 4007 gctlCmd.pfnHandler = handleCtrlCreateTemp; 4008 uUsage = USAGE_GSTCTRL_CREATETEMP; 4009 } 3939 4010 else if ( !RTStrICmp(pArg->argv[1], "kill") /* Linux. */ 3940 4011 || !RTStrICmp(pArg->argv[1], "pkill") /* Solaris / *BSD. */ … … 3945 4016 | CTLCMDCTX_FLAGS_NO_SIGNAL_HANDLER; 3946 4017 gctlCmd.pfnHandler = handleCtrlProcessClose; 4018 uUsage = USAGE_GSTCTRL_KILL; 3947 4019 } 3948 4020 /** @todo Implement "killall"? */ 3949 4021 else if ( !RTStrICmp(pArg->argv[1], "stat")) 4022 { 3950 4023 gctlCmd.pfnHandler = handleCtrlStat; 4024 uUsage = USAGE_GSTCTRL_STAT; 4025 } 3951 4026 else if ( !RTStrICmp(pArg->argv[1], "updateadditions") 3952 4027 || !RTStrICmp(pArg->argv[1], "updateadds")) … … 3955 4030 | CTLCMDCTX_FLAGS_NO_SIGNAL_HANDLER; 3956 4031 gctlCmd.pfnHandler = handleCtrlUpdateAdditions; 4032 uUsage = USAGE_GSTCTRL_UPDATEADDS; 3957 4033 } 3958 4034 else if ( !RTStrICmp(pArg->argv[1], "list")) … … 3961 4037 | CTLCMDCTX_FLAGS_NO_SIGNAL_HANDLER; 3962 4038 gctlCmd.pfnHandler = handleCtrlList; 4039 uUsage = USAGE_GSTCTRL_LIST; 3963 4040 } 3964 4041 else if ( !RTStrICmp(pArg->argv[1], "session")) … … 3967 4044 | CTLCMDCTX_FLAGS_NO_SIGNAL_HANDLER; 3968 4045 gctlCmd.pfnHandler = handleCtrlSession; 4046 uUsage = USAGE_GSTCTRL_SESSION; 3969 4047 } 3970 4048 else if ( !RTStrICmp(pArg->argv[1], "process")) … … 3973 4051 | CTLCMDCTX_FLAGS_NO_SIGNAL_HANDLER; 3974 4052 gctlCmd.pfnHandler = handleCtrlProcess; 4053 uUsage = USAGE_GSTCTRL_PROCESS; 3975 4054 } 3976 4055 else if ( !RTStrICmp(pArg->argv[1], "watch")) … … 3979 4058 | CTLCMDCTX_FLAGS_NO_SIGNAL_HANDLER; 3980 4059 gctlCmd.pfnHandler = handleCtrlWatch; 4060 uUsage = USAGE_GSTCTRL_WATCH; 3981 4061 } 3982 4062 else … … 3986 4066 RT_ZERO(cmdCtx); 3987 4067 3988 RTEXITCODE rcExit = ctrlInitVM(pArg, &cmdCtx, uCmdCtxFlags );4068 RTEXITCODE rcExit = ctrlInitVM(pArg, &cmdCtx, uCmdCtxFlags, uUsage); 3989 4069 if (rcExit == RTEXITCODE_SUCCESS) 3990 4070 { -
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 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r48983 r49621 1027 1027 strAttachment = "nat"; 1028 1028 strNatSettings = Utf8StrFmt("mtu=\"%d\"\nsockSnd=\"%d\"\nsockRcv=\"%d\"\ntcpWndSnd=\"%d\"\ntcpWndRcv=\"%d\"\n", 1029 mtu, sockSnd ? sockSnd : 64, sockRcv ? sockRcv : 64 1029 mtu, sockSnd ? sockSnd : 64, sockRcv ? sockRcv : 64, tcpSnd ? tcpSnd : 64, tcpRcv ? tcpRcv : 64); 1030 1030 } 1031 1031 else … … 1033 1033 strAttachment = "NAT"; 1034 1034 strNatSettings = Utf8StrFmt("NIC %d Settings: MTU: %d, Socket (send: %d, receive: %d), TCP Window (send:%d, receive: %d)\n", 1035 currentNIC + 1, mtu, sockSnd ? sockSnd : 64, sockRcv ? sockRcv : 64 1035 currentNIC + 1, mtu, sockSnd ? sockSnd : 64, sockRcv ? sockRcv : 64, tcpSnd ? tcpSnd : 64, tcpRcv ? tcpRcv : 64); 1036 1036 } 1037 1037 break;
Note:
See TracChangeset
for help on using the changeset viewer.