VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp@ 68863

Last change on this file since 68863 was 68863, checked in by vboxsync, 7 years ago

iprt,vboxmanage,manual: Try write the iso maker docs as a docbook refentry document. Tried to generalize the vboxmanage refentry output handling, moving it to RTMsg*. Made VBoxManage and IPRT generate their C/H sources in their own Makefiles. Hacked the C/H source generation till it can deal with the rather different RTIsoMaker command structure (no sub or sub-sub command stuff). [build fix]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 62.8 KB
Line 
1/* $Id: VBoxManageHelp.cpp 68863 2017-09-25 20:24:39Z vboxsync $ */
2/** @file
3 * VBoxManage - help and other message output.
4 */
5
6/*
7 * Copyright (C) 2006-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#include <VBox/version.h>
23
24#include <iprt/buildconfig.h>
25#include <iprt/ctype.h>
26#include <iprt/env.h>
27#include <iprt/err.h>
28#include <iprt/getopt.h>
29#include <iprt/stream.h>
30#include <iprt/message.h>
31
32#include "VBoxManage.h"
33
34
35/*********************************************************************************************************************************
36* Defined Constants And Macros *
37*********************************************************************************************************************************/
38/** If the usage is the given number of length long or longer, the error is
39 * repeated so the user can actually see it. */
40#define ERROR_REPEAT_AFTER_USAGE_LENGTH 16
41
42
43/*********************************************************************************************************************************
44* Global Variables *
45*********************************************************************************************************************************/
46#ifndef VBOX_ONLY_DOCS
47enum HELP_CMD_VBOXMANAGE g_enmCurCommand = HELP_CMD_VBOXMANAGE_INVALID;
48/** The scope maskt for the current subcommand. */
49uint64_t g_fCurSubcommandScope = RTMSGREFENTRYSTR_SCOPE_GLOBAL;
50
51/**
52 * Sets the current command.
53 *
54 * This affects future calls to error and help functions.
55 *
56 * @param enmCommand The command.
57 */
58void setCurrentCommand(enum HELP_CMD_VBOXMANAGE enmCommand)
59{
60 Assert(g_enmCurCommand == HELP_CMD_VBOXMANAGE_INVALID);
61 g_enmCurCommand = enmCommand;
62 g_fCurSubcommandScope = RTMSGREFENTRYSTR_SCOPE_GLOBAL;
63}
64
65
66/**
67 * Sets the current subcommand.
68 *
69 * This affects future calls to error and help functions.
70 *
71 * @param fSubcommandScope The subcommand scope.
72 */
73void setCurrentSubcommand(uint64_t fSubcommandScope)
74{
75 g_fCurSubcommandScope = fSubcommandScope;
76}
77
78
79
80
81/**
82 * Prints brief help for a command or subcommand.
83 *
84 * @returns Number of lines written.
85 * @param enmCommand The command.
86 * @param fSubcommandScope The subcommand scope, REFENTRYSTR_SCOPE_GLOBAL
87 * for all.
88 * @param pStrm The output stream.
89 */
90static uint32_t printBriefCommandOrSubcommandHelp(enum HELP_CMD_VBOXMANAGE enmCommand, uint64_t fSubcommandScope, PRTSTREAM pStrm)
91{
92 uint32_t cLinesWritten = 0;
93 uint32_t cPendingBlankLines = 0;
94 uint32_t cFound = 0;
95 for (uint32_t i = 0; i < g_cHelpEntries; i++)
96 {
97 PCRTMSGREFENTRY pHelp = g_apHelpEntries[i];
98 if (pHelp->idInternal == (int64_t)enmCommand)
99 {
100 cFound++;
101 if (cFound == 1)
102 {
103 if (fSubcommandScope == RTMSGREFENTRYSTR_SCOPE_GLOBAL)
104 RTStrmPrintf(pStrm, "Usage - %c%s:\n", RT_C_TO_UPPER(pHelp->pszBrief[0]), pHelp->pszBrief + 1);
105 else
106 RTStrmPrintf(pStrm, "Usage:\n");
107 }
108 RTMsgRefEntryPrintStringTable(pStrm, &pHelp->Synopsis, fSubcommandScope, &cPendingBlankLines, &cLinesWritten);
109 if (!cPendingBlankLines)
110 cPendingBlankLines = 1;
111 }
112 }
113 Assert(cFound > 0);
114 return cLinesWritten;
115}
116
117
118/**
119 * Prints the brief usage information for the current (sub)command.
120 *
121 * @param pStrm The output stream.
122 */
123void printUsage(PRTSTREAM pStrm)
124{
125 printBriefCommandOrSubcommandHelp(g_enmCurCommand, g_fCurSubcommandScope, pStrm);
126}
127
128
129/**
130 * Prints full help for a command or subcommand.
131 *
132 * @param enmCommand The command.
133 * @param fSubcommandScope The subcommand scope, REFENTRYSTR_SCOPE_GLOBAL
134 * for all.
135 * @param pStrm The output stream.
136 */
137static void printFullCommandOrSubcommandHelp(enum HELP_CMD_VBOXMANAGE enmCommand, uint64_t fSubcommandScope, PRTSTREAM pStrm)
138{
139 uint32_t cPendingBlankLines = 0;
140 uint32_t cFound = 0;
141 for (uint32_t i = 0; i < g_cHelpEntries; i++)
142 {
143 PCRTMSGREFENTRY pHelp = g_apHelpEntries[i];
144 if ( pHelp->idInternal == (int64_t)enmCommand
145 || enmCommand == HELP_CMD_VBOXMANAGE_INVALID)
146 {
147 cFound++;
148 RTMsgRefEntryPrintStringTable(pStrm, &pHelp->Help, fSubcommandScope, &cPendingBlankLines, NULL /*pcLinesWritten*/);
149 if (cPendingBlankLines < 2)
150 cPendingBlankLines = 2;
151 }
152 }
153 Assert(cFound > 0);
154}
155
156
157/**
158 * Prints the full help for the current (sub)command.
159 *
160 * @param pStrm The output stream.
161 */
162void printHelp(PRTSTREAM pStrm)
163{
164 printFullCommandOrSubcommandHelp(g_enmCurCommand, g_fCurSubcommandScope, pStrm);
165}
166
167
168/**
169 * Display no subcommand error message and current command usage.
170 *
171 * @returns RTEXITCODE_SYNTAX.
172 */
173RTEXITCODE errorNoSubcommand(void)
174{
175 Assert(g_enmCurCommand != HELP_CMD_VBOXMANAGE_INVALID);
176 Assert(g_fCurSubcommandScope == RTMSGREFENTRYSTR_SCOPE_GLOBAL);
177
178 return errorSyntax("No subcommand specified");
179}
180
181
182/**
183 * Display unknown subcommand error message and current command usage.
184 *
185 * May show full command help instead if the subcommand is a common help option.
186 *
187 * @returns RTEXITCODE_SYNTAX, or RTEXITCODE_SUCCESS if common help option.
188 * @param pszSubcommand The name of the alleged subcommand.
189 */
190RTEXITCODE errorUnknownSubcommand(const char *pszSubcommand)
191{
192 Assert(g_enmCurCommand != HELP_CMD_VBOXMANAGE_INVALID);
193 Assert(g_fCurSubcommandScope == RTMSGREFENTRYSTR_SCOPE_GLOBAL);
194
195 /* check if help was requested. */
196 if ( strcmp(pszSubcommand, "--help") == 0
197 || strcmp(pszSubcommand, "-h") == 0
198 || strcmp(pszSubcommand, "-?") == 0)
199 {
200 printFullCommandOrSubcommandHelp(g_enmCurCommand, g_fCurSubcommandScope, g_pStdOut);
201 return RTEXITCODE_SUCCESS;
202 }
203
204 return errorSyntax("Unknown subcommand: %s", pszSubcommand);
205}
206
207
208/**
209 * Display too many parameters error message and current command usage.
210 *
211 * May show full command help instead if the subcommand is a common help option.
212 *
213 * @returns RTEXITCODE_SYNTAX, or RTEXITCODE_SUCCESS if common help option.
214 * @param papszArgs The first unwanted parameter. Terminated by
215 * NULL entry.
216 */
217RTEXITCODE errorTooManyParameters(char **papszArgs)
218{
219 Assert(g_enmCurCommand != HELP_CMD_VBOXMANAGE_INVALID);
220 Assert(g_fCurSubcommandScope != RTMSGREFENTRYSTR_SCOPE_GLOBAL);
221
222 /* check if help was requested. */
223 if (papszArgs)
224 {
225 for (uint32_t i = 0; papszArgs[i]; i++)
226 if ( strcmp(papszArgs[i], "--help") == 0
227 || strcmp(papszArgs[i], "-h") == 0
228 || strcmp(papszArgs[i], "-?") == 0)
229 {
230 printFullCommandOrSubcommandHelp(g_enmCurCommand, g_fCurSubcommandScope, g_pStdOut);
231 return RTEXITCODE_SUCCESS;
232 }
233 else if (!strcmp(papszArgs[i], "--"))
234 break;
235 }
236
237 return errorSyntax("Too many parameters");
238}
239
240
241/**
242 * Display current (sub)command usage and the custom error message.
243 *
244 * @returns RTEXITCODE_SYNTAX.
245 * @param pszFormat Custom error message format string.
246 * @param ... Format arguments.
247 */
248RTEXITCODE errorSyntax(const char *pszFormat, ...)
249{
250 Assert(g_enmCurCommand != HELP_CMD_VBOXMANAGE_INVALID);
251
252 showLogo(g_pStdErr);
253
254 va_list va;
255 va_start(va, pszFormat);
256 RTMsgErrorV(pszFormat, va);
257 va_end(va);
258
259 RTStrmPutCh(g_pStdErr, '\n');
260 if ( printBriefCommandOrSubcommandHelp(g_enmCurCommand, g_fCurSubcommandScope, g_pStdErr)
261 >= ERROR_REPEAT_AFTER_USAGE_LENGTH)
262 {
263 /* Usage was very long, repeat the error message. */
264 RTStrmPutCh(g_pStdErr, '\n');
265 va_start(va, pszFormat);
266 RTMsgErrorV(pszFormat, va);
267 va_end(va);
268 }
269 return RTEXITCODE_SYNTAX;
270}
271
272
273/**
274 * Worker for errorGetOpt.
275 *
276 * @param rcGetOpt The RTGetOpt return value.
277 * @param pValueUnion The value union returned by RTGetOpt.
278 */
279static void errorGetOptWorker(int rcGetOpt, union RTGETOPTUNION const *pValueUnion)
280{
281 if (rcGetOpt == VINF_GETOPT_NOT_OPTION)
282 RTMsgError("Invalid parameter '%s'", pValueUnion->psz);
283 else if (rcGetOpt > 0)
284 {
285 if (RT_C_IS_PRINT(rcGetOpt))
286 RTMsgError("Invalid option -%c", rcGetOpt);
287 else
288 RTMsgError("Invalid option case %i", rcGetOpt);
289 }
290 else if (rcGetOpt == VERR_GETOPT_UNKNOWN_OPTION)
291 RTMsgError("Unknown option: %s", pValueUnion->psz);
292 else if (rcGetOpt == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)
293 RTMsgError("Invalid argument format: %s", pValueUnion->psz);
294 else if (pValueUnion->pDef)
295 RTMsgError("%s: %Rrs", pValueUnion->pDef->pszLong, rcGetOpt);
296 else
297 RTMsgError("%Rrs", rcGetOpt);
298}
299
300
301/**
302 * Handled an RTGetOpt error or common option.
303 *
304 * This implements the 'V' and 'h' cases. It reports appropriate syntax errors
305 * for other @a rcGetOpt values.
306 *
307 * @retval RTEXITCODE_SUCCESS if help or version request.
308 * @retval RTEXITCODE_SYNTAX if not help or version request.
309 * @param rcGetOpt The RTGetOpt return value.
310 * @param pValueUnion The value union returned by RTGetOpt.
311 */
312RTEXITCODE errorGetOpt(int rcGetOpt, union RTGETOPTUNION const *pValueUnion)
313{
314 Assert(g_enmCurCommand != HELP_CMD_VBOXMANAGE_INVALID);
315
316 /*
317 * Check if it is an unhandled standard option.
318 */
319 if (rcGetOpt == 'V')
320 {
321 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision());
322 return RTEXITCODE_SUCCESS;
323 }
324
325 if (rcGetOpt == 'h')
326 {
327 printFullCommandOrSubcommandHelp(g_enmCurCommand, g_fCurSubcommandScope, g_pStdOut);
328 return RTEXITCODE_SUCCESS;
329 }
330
331 /*
332 * We failed.
333 */
334 showLogo(g_pStdErr);
335 errorGetOptWorker(rcGetOpt, pValueUnion);
336 if ( printBriefCommandOrSubcommandHelp(g_enmCurCommand, g_fCurSubcommandScope, g_pStdErr)
337 >= ERROR_REPEAT_AFTER_USAGE_LENGTH)
338 {
339 /* Usage was very long, repeat the error message. */
340 RTStrmPutCh(g_pStdErr, '\n');
341 errorGetOptWorker(rcGetOpt, pValueUnion);
342 }
343 return RTEXITCODE_SYNTAX;
344}
345
346#endif /* !VBOX_ONLY_DOCS */
347
348
349
350void showLogo(PRTSTREAM pStrm)
351{
352 static bool s_fShown; /* show only once */
353
354 if (!s_fShown)
355 {
356 RTStrmPrintf(pStrm, VBOX_PRODUCT " Command Line Management Interface Version "
357 VBOX_VERSION_STRING "\n"
358 "(C) 2005-" VBOX_C_YEAR " " VBOX_VENDOR "\n"
359 "All rights reserved.\n"
360 "\n");
361 s_fShown = true;
362 }
363}
364
365
366
367
368void printUsage(USAGECATEGORY fCategory, uint32_t fSubCategory, PRTSTREAM pStrm)
369{
370 bool fDumpOpts = false;
371#ifdef RT_OS_LINUX
372 bool fLinux = true;
373#else
374 bool fLinux = false;
375#endif
376#ifdef RT_OS_WINDOWS
377 bool fWin = true;
378#else
379 bool fWin = false;
380#endif
381#ifdef RT_OS_SOLARIS
382 bool fSolaris = true;
383#else
384 bool fSolaris = false;
385#endif
386#ifdef RT_OS_FREEBSD
387 bool fFreeBSD = true;
388#else
389 bool fFreeBSD = false;
390#endif
391#ifdef RT_OS_DARWIN
392 bool fDarwin = true;
393#else
394 bool fDarwin = false;
395#endif
396#ifdef VBOX_WITH_VBOXSDL
397 bool fVBoxSDL = true;
398#else
399 bool fVBoxSDL = false;
400#endif
401
402 if (fCategory == USAGE_DUMPOPTS)
403 {
404 fDumpOpts = true;
405 fLinux = true;
406 fWin = true;
407 fSolaris = true;
408 fFreeBSD = true;
409 fDarwin = true;
410 fVBoxSDL = true;
411 fCategory = USAGE_ALL;
412 }
413
414 RTStrmPrintf(pStrm,
415 "Usage:\n"
416 "\n");
417
418 if (fCategory == USAGE_ALL)
419 RTStrmPrintf(pStrm,
420 " VBoxManage [<general option>] <command>\n"
421 " \n \n"
422 "General Options:\n \n"
423 " [-v|--version] print version number and exit\n"
424 " [-q|--nologo] suppress the logo\n"
425 " [--settingspw <pw>] provide the settings password\n"
426 " [--settingspwfile <file>] provide a file containing the settings password\n"
427 " [@<response-file>] load arguments from the given response file (bourne style)\n"
428 " \n \n"
429 "Commands:\n \n");
430
431 const char *pcszSep1 = " ";
432 const char *pcszSep2 = " ";
433 if (fCategory != USAGE_ALL)
434 {
435 pcszSep1 = "VBoxManage";
436 pcszSep2 = "";
437 }
438
439#define SEP pcszSep1, pcszSep2
440
441 if (fCategory & USAGE_LIST)
442 RTStrmPrintf(pStrm,
443 "%s list [--long|-l] [--sorted|-s]%s vms|runningvms|ostypes|hostdvds|hostfloppies|\n"
444#if defined(VBOX_WITH_NETFLT)
445 " intnets|bridgedifs|hostonlyifs|natnets|dhcpservers|\n"
446#else
447 " intnets|bridgedifs|natnets|dhcpservers|hostinfo|\n"
448#endif
449 " hostinfo|hostcpuids|hddbackends|hdds|dvds|floppies|\n"
450 " usbhost|usbfilters|systemproperties|extpacks|\n"
451 " groups|webcams|screenshotformats\n"
452 "\n", SEP);
453
454 if (fCategory & USAGE_SHOWVMINFO)
455 RTStrmPrintf(pStrm,
456 "%s showvminfo %s <uuid|vmname> [--details]\n"
457 " [--machinereadable]\n"
458 "%s showvminfo %s <uuid|vmname> --log <idx>\n"
459 "\n", SEP, SEP);
460
461 if (fCategory & USAGE_REGISTERVM)
462 RTStrmPrintf(pStrm,
463 "%s registervm %s <filename>\n"
464 "\n", SEP);
465
466 if (fCategory & USAGE_UNREGISTERVM)
467 RTStrmPrintf(pStrm,
468 "%s unregistervm %s <uuid|vmname> [--delete]\n"
469 "\n", SEP);
470
471 if (fCategory & USAGE_CREATEVM)
472 RTStrmPrintf(pStrm,
473 "%s createvm %s --name <name>\n"
474 " [--groups <group>, ...]\n"
475 " [--ostype <ostype>]\n"
476 " [--register]\n"
477 " [--basefolder <path>]\n"
478 " [--uuid <uuid>]\n"
479 "\n", SEP);
480
481 if (fCategory & USAGE_MODIFYVM)
482 {
483 RTStrmPrintf(pStrm,
484 "%s modifyvm %s <uuid|vmname>\n"
485 " [--name <name>]\n"
486 " [--groups <group>, ...]\n"
487 " [--description <desc>]\n"
488 " [--ostype <ostype>]\n"
489 " [--iconfile <filename>]\n"
490 " [--memory <memorysize in MB>]\n"
491 " [--pagefusion on|off]\n"
492 " [--vram <vramsize in MB>]\n"
493 " [--acpi on|off]\n"
494#ifdef VBOX_WITH_PCI_PASSTHROUGH
495 " [--pciattach 03:04.0]\n"
496 " [--pciattach 03:04.0@02:01.0]\n"
497 " [--pcidetach 03:04.0]\n"
498#endif
499 " [--ioapic on|off]\n"
500 " [--hpet on|off]\n"
501 " [--triplefaultreset on|off]\n"
502 " [--apic on|off]\n"
503 " [--x2apic on|off]\n"
504 " [--paravirtprovider none|default|legacy|minimal|\n"
505 " hyperv|kvm]\n"
506 " [--paravirtdebug <key=value> [,<key=value> ...]]\n"
507 " [--hwvirtex on|off]\n"
508 " [--nestedpaging on|off]\n"
509 " [--largepages on|off]\n"
510 " [--vtxvpid on|off]\n"
511 " [--vtxux on|off]\n"
512 " [--pae on|off]\n"
513 " [--longmode on|off]\n"
514 " [--cpu-profile \"host|Intel 80[86|286|386]\"]\n"
515 " [--cpuid-portability-level <0..3>\n"
516 " [--cpuidset <leaf> <eax> <ebx> <ecx> <edx>]\n"
517 " [--cpuidremove <leaf>]\n"
518 " [--cpuidremoveall]\n"
519 " [--hardwareuuid <uuid>]\n"
520 " [--cpus <number>]\n"
521 " [--cpuhotplug on|off]\n"
522 " [--plugcpu <id>]\n"
523 " [--unplugcpu <id>]\n"
524 " [--cpuexecutioncap <1-100>]\n"
525 " [--rtcuseutc on|off]\n"
526#ifdef VBOX_WITH_VMSVGA
527 " [--graphicscontroller none|vboxvga|vmsvga]\n"
528#else
529 " [--graphicscontroller none|vboxvga]\n"
530#endif
531 " [--monitorcount <number>]\n"
532 " [--accelerate3d on|off]\n"
533#ifdef VBOX_WITH_VIDEOHWACCEL
534 " [--accelerate2dvideo on|off]\n"
535#endif
536 " [--firmware bios|efi|efi32|efi64]\n"
537 " [--chipset ich9|piix3]\n"
538 " [--bioslogofadein on|off]\n"
539 " [--bioslogofadeout on|off]\n"
540 " [--bioslogodisplaytime <msec>]\n"
541 " [--bioslogoimagepath <imagepath>]\n"
542 " [--biosbootmenu disabled|menuonly|messageandmenu]\n"
543 " [--biosapic disabled|apic|x2apic]\n"
544 " [--biossystemtimeoffset <msec>]\n"
545 " [--biospxedebug on|off]\n"
546 " [--boot<1-4> none|floppy|dvd|disk|net>]\n"
547 " [--nic<1-N> none|null|nat|bridged|intnet"
548#if defined(VBOX_WITH_NETFLT)
549 "|hostonly"
550#endif
551 "|\n"
552 " generic|natnetwork"
553 "]\n"
554 " [--nictype<1-N> Am79C970A|Am79C973"
555#ifdef VBOX_WITH_E1000
556 "|\n 82540EM|82543GC|82545EM"
557#endif
558#ifdef VBOX_WITH_VIRTIO
559 "|\n virtio"
560#endif /* VBOX_WITH_VIRTIO */
561 "]\n"
562 " [--cableconnected<1-N> on|off]\n"
563 " [--nictrace<1-N> on|off]\n"
564 " [--nictracefile<1-N> <filename>]\n"
565 " [--nicproperty<1-N> name=[value]]\n"
566 " [--nicspeed<1-N> <kbps>]\n"
567 " [--nicbootprio<1-N> <priority>]\n"
568 " [--nicpromisc<1-N> deny|allow-vms|allow-all]\n"
569 " [--nicbandwidthgroup<1-N> none|<name>]\n"
570 " [--bridgeadapter<1-N> none|<devicename>]\n"
571#if defined(VBOX_WITH_NETFLT)
572 " [--hostonlyadapter<1-N> none|<devicename>]\n"
573#endif
574 " [--intnet<1-N> <network name>]\n"
575 " [--nat-network<1-N> <network name>]\n"
576 " [--nicgenericdrv<1-N> <driver>\n"
577 " [--natnet<1-N> <network>|default]\n"
578 " [--natsettings<1-N> [<mtu>],[<socksnd>],\n"
579 " [<sockrcv>],[<tcpsnd>],\n"
580 " [<tcprcv>]]\n"
581 " [--natpf<1-N> [<rulename>],tcp|udp,[<hostip>],\n"
582 " <hostport>,[<guestip>],<guestport>]\n"
583 " [--natpf<1-N> delete <rulename>]\n"
584 " [--nattftpprefix<1-N> <prefix>]\n"
585 " [--nattftpfile<1-N> <file>]\n"
586 " [--nattftpserver<1-N> <ip>]\n"
587 " [--natbindip<1-N> <ip>\n"
588 " [--natdnspassdomain<1-N> on|off]\n"
589 " [--natdnsproxy<1-N> on|off]\n"
590 " [--natdnshostresolver<1-N> on|off]\n"
591 " [--nataliasmode<1-N> default|[log],[proxyonly],\n"
592 " [sameports]]\n"
593 " [--macaddress<1-N> auto|<mac>]\n"
594 " [--mouse ps2|usb|usbtablet|usbmultitouch]\n"
595 " [--keyboard ps2|usb\n"
596 " [--uart<1-N> off|<I/O base> <IRQ>]\n"
597 " [--uartmode<1-N> disconnected|\n"
598 " server <pipe>|\n"
599 " client <pipe>|\n"
600 " tcpserver <port>|\n"
601 " tcpclient <hostname:port>|\n"
602 " file <file>|\n"
603 " <devicename>]\n"
604#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
605 " [--lpt<1-N> off|<I/O base> <IRQ>]\n"
606 " [--lptmode<1-N> <devicename>]\n"
607#endif
608 " [--guestmemoryballoon <balloonsize in MB>]\n"
609 " [--audio none|null", SEP);
610 if (fWin)
611 {
612#ifdef VBOX_WITH_WINMM
613 RTStrmPrintf(pStrm, "|winmm|dsound");
614#else
615 RTStrmPrintf(pStrm, "|dsound");
616#endif
617 }
618 if (fLinux || fSolaris)
619 {
620 RTStrmPrintf(pStrm, ""
621#ifdef VBOX_WITH_AUDIO_OSS
622 "|oss"
623#endif
624#ifdef VBOX_WITH_AUDIO_ALSA
625 "|alsa"
626#endif
627#ifdef VBOX_WITH_AUDIO_PULSE
628 "|pulse"
629#endif
630 );
631 }
632 if (fFreeBSD)
633 {
634#ifdef VBOX_WITH_AUDIO_OSS
635 /* Get the line break sorted when dumping all option variants. */
636 if (fDumpOpts)
637 {
638 RTStrmPrintf(pStrm, "|\n"
639 " oss");
640 }
641 else
642 RTStrmPrintf(pStrm, "|oss");
643#endif
644#ifdef VBOX_WITH_AUDIO_PULSE
645 RTStrmPrintf(pStrm, "|pulse");
646#endif
647 }
648 if (fDarwin)
649 {
650 RTStrmPrintf(pStrm, "|coreaudio");
651 }
652 RTStrmPrintf(pStrm, "]\n");
653 RTStrmPrintf(pStrm,
654 " [--audioin on|off]\n"
655 " [--audioout on|off]\n"
656 " [--audiocontroller ac97|hda|sb16]\n"
657 " [--audiocodec stac9700|ad1980|stac9221|sb16]\n"
658 " [--clipboard disabled|hosttoguest|guesttohost|\n"
659 " bidirectional]\n"
660 " [--draganddrop disabled|hosttoguest]\n");
661 RTStrmPrintf(pStrm,
662 " [--vrde on|off]\n"
663 " [--vrdeextpack default|<name>\n"
664 " [--vrdeproperty <name=[value]>]\n"
665 " [--vrdeport <hostport>]\n"
666 " [--vrdeaddress <hostip>]\n"
667 " [--vrdeauthtype null|external|guest]\n"
668 " [--vrdeauthlibrary default|<name>\n"
669 " [--vrdemulticon on|off]\n"
670 " [--vrdereusecon on|off]\n"
671 " [--vrdevideochannel on|off]\n"
672 " [--vrdevideochannelquality <percent>]\n");
673 RTStrmPrintf(pStrm,
674 " [--usb on|off]\n"
675 " [--usbehci on|off]\n"
676 " [--usbxhci on|off]\n"
677 " [--usbrename <oldname> <newname>]\n"
678 " [--snapshotfolder default|<path>]\n"
679 " [--teleporter on|off]\n"
680 " [--teleporterport <port>]\n"
681 " [--teleporteraddress <address|empty>\n"
682 " [--teleporterpassword <password>]\n"
683 " [--teleporterpasswordfile <file>|stdin]\n"
684 " [--tracing-enabled on|off]\n"
685 " [--tracing-config <config-string>]\n"
686 " [--tracing-allow-vm-access on|off]\n"
687#if 0
688 " [--iocache on|off]\n"
689 " [--iocachesize <I/O cache size in MB>]\n"
690#endif
691#if 0
692 " [--faulttolerance master|standby]\n"
693 " [--faulttoleranceaddress <name>]\n"
694 " [--faulttoleranceport <port>]\n"
695 " [--faulttolerancesyncinterval <msec>]\n"
696 " [--faulttolerancepassword <password>]\n"
697#endif
698#ifdef VBOX_WITH_USB_CARDREADER
699 " [--usbcardreader on|off]\n"
700#endif
701 " [--autostart-enabled on|off]\n"
702 " [--autostart-delay <seconds>]\n"
703#if 0
704 " [--autostop-type disabled|savestate|poweroff|\n"
705 " acpishutdown]\n"
706#endif
707#ifdef VBOX_WITH_VIDEOREC
708 " [--videocap on|off]\n"
709 " [--videocapscreens all|<screen ID> [<screen ID> ...]]\n"
710 " [--videocapfile <filename>]\n"
711 " [--videocapres <width> <height>]\n"
712 " [--videocaprate <rate>]\n"
713 " [--videocapfps <fps>]\n"
714 " [--videocapmaxtime <ms>]\n"
715 " [--videocapmaxsize <MB>]\n"
716 " [--videocapopts <key=value> [,<key=value> ...]]\n"
717#endif
718 " [--defaultfrontend default|<name>]\n"
719 "\n");
720 }
721
722 if (fCategory & USAGE_CLONEVM)
723 RTStrmPrintf(pStrm,
724 "%s clonevm %s <uuid|vmname>\n"
725 " [--snapshot <uuid>|<name>]\n"
726 " [--mode machine|machineandchildren|all]\n"
727 " [--options link|keepallmacs|keepnatmacs|\n"
728 " keepdisknames]\n"
729 " [--name <name>]\n"
730 " [--groups <group>, ...]\n"
731 " [--basefolder <basefolder>]\n"
732 " [--uuid <uuid>]\n"
733 " [--register]\n"
734 "\n", SEP);
735
736 if (fCategory & USAGE_IMPORTAPPLIANCE)
737 RTStrmPrintf(pStrm,
738 "%s import %s <ovfname/ovaname>\n"
739 " [--dry-run|-n]\n"
740 " [--options keepallmacs|keepnatmacs|importtovdi]\n"
741 " [more options]\n"
742 " (run with -n to have options displayed\n"
743 " for a particular OVF)\n\n", SEP);
744
745 if (fCategory & USAGE_EXPORTAPPLIANCE)
746 RTStrmPrintf(pStrm,
747 "%s export %s <machines> --output|-o <name>.<ovf/ova/tar.gz>\n"
748 " [--legacy09|--ovf09|--ovf10|--ovf20|--opc10]\n"
749 " [--manifest]\n"
750 " [--iso]\n"
751 " [--options manifest|iso|nomacs|nomacsbutnat]\n"
752 " [--vsys <number of virtual system>]\n"
753 " [--product <product name>]\n"
754 " [--producturl <product url>]\n"
755 " [--vendor <vendor name>]\n"
756 " [--vendorurl <vendor url>]\n"
757 " [--version <version info>]\n"
758 " [--description <description info>]\n"
759 " [--eula <license text>]\n"
760 " [--eulafile <filename>]\n"
761 "\n", SEP);
762
763 if (fCategory & USAGE_STARTVM)
764 {
765 RTStrmPrintf(pStrm,
766 "%s startvm %s <uuid|vmname>...\n"
767 " [--type gui", SEP);
768 if (fVBoxSDL)
769 RTStrmPrintf(pStrm, "|sdl");
770 RTStrmPrintf(pStrm, "|headless|separate]\n");
771 RTStrmPrintf(pStrm,
772 " [-E|--putenv <NAME>[=<VALUE>]]\n"
773 "\n");
774 }
775
776 if (fCategory & USAGE_CONTROLVM)
777 {
778 RTStrmPrintf(pStrm,
779 "%s controlvm %s <uuid|vmname>\n"
780 " pause|resume|reset|poweroff|savestate|\n"
781 " acpipowerbutton|acpisleepbutton|\n"
782 " keyboardputscancode <hex> [<hex> ...]|\n"
783 " keyboardputstring <string1> [<string2> ...]|\n"
784 " keyboardputfile <filename>|\n"
785 " setlinkstate<1-N> on|off |\n"
786#if defined(VBOX_WITH_NETFLT)
787 " nic<1-N> null|nat|bridged|intnet|hostonly|generic|\n"
788 " natnetwork [<devicename>] |\n"
789#else /* !VBOX_WITH_NETFLT */
790 " nic<1-N> null|nat|bridged|intnet|generic|natnetwork\n"
791 " [<devicename>] |\n"
792#endif /* !VBOX_WITH_NETFLT */
793 " nictrace<1-N> on|off |\n"
794 " nictracefile<1-N> <filename> |\n"
795 " nicproperty<1-N> name=[value] |\n"
796 " nicpromisc<1-N> deny|allow-vms|allow-all |\n"
797 " natpf<1-N> [<rulename>],tcp|udp,[<hostip>],\n"
798 " <hostport>,[<guestip>],<guestport> |\n"
799 " natpf<1-N> delete <rulename> |\n"
800 " guestmemoryballoon <balloonsize in MB> |\n"
801 " usbattach <uuid>|<address>\n"
802 " [--capturefile <filename>] |\n"
803 " usbdetach <uuid>|<address> |\n"
804 " audioin on|off |\n"
805 " audioout on|off |\n"
806 " clipboard disabled|hosttoguest|guesttohost|\n"
807 " bidirectional |\n"
808 " draganddrop disabled|hosttoguest |\n"
809 " vrde on|off |\n"
810 " vrdeport <port> |\n"
811 " vrdeproperty <name=[value]> |\n"
812 " vrdevideochannelquality <percent> |\n"
813 " setvideomodehint <xres> <yres> <bpp>\n"
814 " [[<display>] [<enabled:yes|no> |\n"
815 " [<xorigin> <yorigin>]]] |\n"
816 " screenshotpng <file> [display] |\n"
817 " videocap on|off |\n"
818 " videocapscreens all|none|<screen>,[<screen>...] |\n"
819 " videocapfile <file>\n"
820 " videocapres <width>x<height>\n"
821 " videocaprate <rate>\n"
822 " videocapfps <fps>\n"
823 " videocapmaxtime <ms>\n"
824 " videocapmaxsize <MB>\n"
825 " setcredentials <username>\n"
826 " --passwordfile <file> | <password>\n"
827 " <domain>\n"
828 " [--allowlocallogon <yes|no>] |\n"
829 " teleport --host <name> --port <port>\n"
830 " [--maxdowntime <msec>]\n"
831 " [--passwordfile <file> |\n"
832 " --password <password>] |\n"
833 " plugcpu <id> |\n"
834 " unplugcpu <id> |\n"
835 " cpuexecutioncap <1-100>\n"
836 " webcam <attach [path [settings]]> | <detach [path]> | <list>\n"
837 " addencpassword <id>\n"
838 " <password file>|-\n"
839 " [--removeonsuspend <yes|no>]\n"
840 " removeencpassword <id>\n"
841 " removeallencpasswords\n"
842 "\n", SEP);
843 }
844
845 if (fCategory & USAGE_DISCARDSTATE)
846 RTStrmPrintf(pStrm,
847 "%s discardstate %s <uuid|vmname>\n"
848 "\n", SEP);
849
850 if (fCategory & USAGE_ADOPTSTATE)
851 RTStrmPrintf(pStrm,
852 "%s adoptstate %s <uuid|vmname> <state_file>\n"
853 "\n", SEP);
854
855 if (fCategory & USAGE_SNAPSHOT)
856 RTStrmPrintf(pStrm,
857 "%s snapshot %s <uuid|vmname>\n"
858 " take <name> [--description <desc>] [--live]\n"
859 " [--uniquename Number,Timestamp,Space,Force] |\n"
860 " delete <uuid|snapname> |\n"
861 " restore <uuid|snapname> |\n"
862 " restorecurrent |\n"
863 " edit <uuid|snapname>|--current\n"
864 " [--name <name>]\n"
865 " [--description <desc>] |\n"
866 " list [--details|--machinereadable]\n"
867 " showvminfo <uuid|snapname>\n"
868 "\n", SEP);
869
870 if (fCategory & USAGE_CLOSEMEDIUM)
871 RTStrmPrintf(pStrm,
872 "%s closemedium %s [disk|dvd|floppy] <uuid|filename>\n"
873 " [--delete]\n"
874 "\n", SEP);
875
876 if (fCategory & USAGE_STORAGEATTACH)
877 RTStrmPrintf(pStrm,
878 "%s storageattach %s <uuid|vmname>\n"
879 " --storagectl <name>\n"
880 " [--port <number>]\n"
881 " [--device <number>]\n"
882 " [--type dvddrive|hdd|fdd]\n"
883 " [--medium none|emptydrive|additions|\n"
884 " <uuid|filename>|host:<drive>|iscsi]\n"
885 " [--mtype normal|writethrough|immutable|shareable|\n"
886 " readonly|multiattach]\n"
887 " [--comment <text>]\n"
888 " [--setuuid <uuid>]\n"
889 " [--setparentuuid <uuid>]\n"
890 " [--passthrough on|off]\n"
891 " [--tempeject on|off]\n"
892 " [--nonrotational on|off]\n"
893 " [--discard on|off]\n"
894 " [--hotpluggable on|off]\n"
895 " [--bandwidthgroup <name>]\n"
896 " [--forceunmount]\n"
897 " [--server <name>|<ip>]\n"
898 " [--target <target>]\n"
899 " [--tport <port>]\n"
900 " [--lun <lun>]\n"
901 " [--encodedlun <lun>]\n"
902 " [--username <username>]\n"
903 " [--password <password>]\n"
904 " [--initiator <initiator>]\n"
905 " [--intnet]\n"
906 "\n", SEP);
907
908 if (fCategory & USAGE_STORAGECONTROLLER)
909 RTStrmPrintf(pStrm,
910 "%s storagectl %s <uuid|vmname>\n"
911 " --name <name>\n"
912 " [--add ide|sata|scsi|floppy|sas|usb|pcie]\n"
913 " [--controller LSILogic|LSILogicSAS|BusLogic|\n"
914 " IntelAHCI|PIIX3|PIIX4|ICH6|I82078|\n"
915 " [ USB|NVMe]\n"
916 " [--portcount <1-n>]\n"
917 " [--hostiocache on|off]\n"
918 " [--bootable on|off]\n"
919 " [--rename <name>]\n"
920 " [--remove]\n"
921 "\n", SEP);
922
923 if (fCategory & USAGE_BANDWIDTHCONTROL)
924 RTStrmPrintf(pStrm,
925 "%s bandwidthctl %s <uuid|vmname>\n"
926 " add <name> --type disk|network\n"
927 " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
928 " set <name>\n"
929 " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
930 " remove <name> |\n"
931 " list [--machinereadable]\n"
932 " (limit units: k=kilobit, m=megabit, g=gigabit,\n"
933 " K=kilobyte, M=megabyte, G=gigabyte)\n"
934 "\n", SEP);
935
936 if (fCategory & USAGE_SHOWMEDIUMINFO)
937 RTStrmPrintf(pStrm,
938 "%s showmediuminfo %s [disk|dvd|floppy] <uuid|filename>\n"
939 "\n", SEP);
940
941 if (fCategory & USAGE_CREATEMEDIUM)
942 RTStrmPrintf(pStrm,
943 "%s createmedium %s [disk|dvd|floppy] --filename <filename>\n"
944 " [--size <megabytes>|--sizebyte <bytes>]\n"
945 " [--diffparent <uuid>|<filename>\n"
946 " [--format VDI|VMDK|VHD] (default: VDI)\n"
947 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
948 "\n", SEP);
949
950 if (fCategory & USAGE_MODIFYMEDIUM)
951 RTStrmPrintf(pStrm,
952 "%s modifymedium %s [disk|dvd|floppy] <uuid|filename>\n"
953 " [--type normal|writethrough|immutable|shareable|\n"
954 " readonly|multiattach]\n"
955 " [--autoreset on|off]\n"
956 " [--property <name=[value]>]\n"
957 " [--compact]\n"
958 " [--resize <megabytes>|--resizebyte <bytes>]\n"
959 " [--move <path]\n"
960 " [--description <description string>]"
961 "\n", SEP);
962
963 if (fCategory & USAGE_CLONEMEDIUM)
964 RTStrmPrintf(pStrm,
965 "%s clonemedium %s [disk|dvd|floppy] <uuid|inputfile> <uuid|outputfile>\n"
966 " [--format VDI|VMDK|VHD|RAW|<other>]\n"
967 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
968 " [--existing]\n"
969 "\n", SEP);
970
971 if (fCategory & USAGE_MEDIUMPROPERTY)
972 RTStrmPrintf(pStrm,
973 "%s mediumproperty %s [disk|dvd|floppy] set <uuid|filename>\n"
974 " <property> <value>\n"
975 "\n"
976 " [disk|dvd|floppy] get <uuid|filename>\n"
977 " <property>\n"
978 "\n"
979 " [disk|dvd|floppy] delete <uuid|filename>\n"
980 " <property>\n"
981 "\n", SEP);
982
983 if (fCategory & USAGE_ENCRYPTMEDIUM)
984 RTStrmPrintf(pStrm,
985 "%s encryptmedium %s <uuid|filename>\n"
986 " [--newpassword <file>|-]\n"
987 " [--oldpassword <file>|-]\n"
988 " [--cipher <cipher identifier>]\n"
989 " [--newpasswordid <password identifier>]\n"
990 "\n", SEP);
991
992 if (fCategory & USAGE_MEDIUMENCCHKPWD)
993 RTStrmPrintf(pStrm,
994 "%s checkmediumpwd %s <uuid|filename>\n"
995 " <pwd file>|-\n"
996 "\n", SEP);
997
998 if (fCategory & USAGE_CONVERTFROMRAW)
999 RTStrmPrintf(pStrm,
1000 "%s convertfromraw %s <filename> <outputfile>\n"
1001 " [--format VDI|VMDK|VHD]\n"
1002 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1003 " [--uuid <uuid>]\n"
1004 "%s convertfromraw %s stdin <outputfile> <bytes>\n"
1005 " [--format VDI|VMDK|VHD]\n"
1006 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1007 " [--uuid <uuid>]\n"
1008 "\n", SEP, SEP);
1009
1010 if (fCategory & USAGE_GETEXTRADATA)
1011 RTStrmPrintf(pStrm,
1012 "%s getextradata %s global|<uuid|vmname>\n"
1013 " <key>|enumerate\n"
1014 "\n", SEP);
1015
1016 if (fCategory & USAGE_SETEXTRADATA)
1017 RTStrmPrintf(pStrm,
1018 "%s setextradata %s global|<uuid|vmname>\n"
1019 " <key>\n"
1020 " [<value>] (no value deletes key)\n"
1021 "\n", SEP);
1022
1023 if (fCategory & USAGE_SETPROPERTY)
1024 RTStrmPrintf(pStrm,
1025 "%s setproperty %s machinefolder default|<folder> |\n"
1026 " hwvirtexclusive on|off |\n"
1027 " vrdeauthlibrary default|<library> |\n"
1028 " websrvauthlibrary default|null|<library> |\n"
1029 " vrdeextpack null|<library> |\n"
1030 " autostartdbpath null|<folder> |\n"
1031 " loghistorycount <value>\n"
1032 " defaultfrontend default|<name>\n"
1033 " logginglevel <log setting>\n"
1034 "\n", SEP);
1035
1036 if (fCategory & USAGE_USBFILTER_ADD)
1037 RTStrmPrintf(pStrm,
1038 "%s usbfilter %s add <index,0-N>\n"
1039 " --target <uuid|vmname>|global\n"
1040 " --name <string>\n"
1041 " --action ignore|hold (global filters only)\n"
1042 " [--active yes|no] (yes)\n"
1043 " [--vendorid <XXXX>] (null)\n"
1044 " [--productid <XXXX>] (null)\n"
1045 " [--revision <IIFF>] (null)\n"
1046 " [--manufacturer <string>] (null)\n"
1047 " [--product <string>] (null)\n"
1048 " [--remote yes|no] (null, VM filters only)\n"
1049 " [--serialnumber <string>] (null)\n"
1050 " [--maskedinterfaces <XXXXXXXX>]\n"
1051 "\n", SEP);
1052
1053 if (fCategory & USAGE_USBFILTER_MODIFY)
1054 RTStrmPrintf(pStrm,
1055 "%s usbfilter %s modify <index,0-N>\n"
1056 " --target <uuid|vmname>|global\n"
1057 " [--name <string>]\n"
1058 " [--action ignore|hold] (global filters only)\n"
1059 " [--active yes|no]\n"
1060 " [--vendorid <XXXX>|\"\"]\n"
1061 " [--productid <XXXX>|\"\"]\n"
1062 " [--revision <IIFF>|\"\"]\n"
1063 " [--manufacturer <string>|\"\"]\n"
1064 " [--product <string>|\"\"]\n"
1065 " [--remote yes|no] (null, VM filters only)\n"
1066 " [--serialnumber <string>|\"\"]\n"
1067 " [--maskedinterfaces <XXXXXXXX>]\n"
1068 "\n", SEP);
1069
1070 if (fCategory & USAGE_USBFILTER_REMOVE)
1071 RTStrmPrintf(pStrm,
1072 "%s usbfilter %s remove <index,0-N>\n"
1073 " --target <uuid|vmname>|global\n"
1074 "\n", SEP);
1075
1076 if (fCategory & USAGE_SHAREDFOLDER_ADD)
1077 RTStrmPrintf(pStrm,
1078 "%s sharedfolder %s add <uuid|vmname>\n"
1079 " --name <name> --hostpath <hostpath>\n"
1080 " [--transient] [--readonly] [--automount]\n"
1081 "\n", SEP);
1082
1083 if (fCategory & USAGE_SHAREDFOLDER_REMOVE)
1084 RTStrmPrintf(pStrm,
1085 "%s sharedfolder %s remove <uuid|vmname>\n"
1086 " --name <name> [--transient]\n"
1087 "\n", SEP);
1088
1089#ifdef VBOX_WITH_GUEST_PROPS
1090 if (fCategory & USAGE_GUESTPROPERTY)
1091 usageGuestProperty(pStrm, SEP);
1092#endif /* VBOX_WITH_GUEST_PROPS defined */
1093
1094#ifdef VBOX_WITH_GUEST_CONTROL
1095 if (fCategory & USAGE_GUESTCONTROL)
1096 usageGuestControl(pStrm, SEP, fSubCategory);
1097#endif /* VBOX_WITH_GUEST_CONTROL defined */
1098
1099 if (fCategory & USAGE_METRICS)
1100 RTStrmPrintf(pStrm,
1101 "%s metrics %s list [*|host|<vmname> [<metric_list>]]\n"
1102 " (comma-separated)\n\n"
1103 "%s metrics %s setup\n"
1104 " [--period <seconds>] (default: 1)\n"
1105 " [--samples <count>] (default: 1)\n"
1106 " [--list]\n"
1107 " [*|host|<vmname> [<metric_list>]]\n\n"
1108 "%s metrics %s query [*|host|<vmname> [<metric_list>]]\n\n"
1109 "%s metrics %s enable\n"
1110 " [--list]\n"
1111 " [*|host|<vmname> [<metric_list>]]\n\n"
1112 "%s metrics %s disable\n"
1113 " [--list]\n"
1114 " [*|host|<vmname> [<metric_list>]]\n\n"
1115 "%s metrics %s collect\n"
1116 " [--period <seconds>] (default: 1)\n"
1117 " [--samples <count>] (default: 1)\n"
1118 " [--list]\n"
1119 " [--detach]\n"
1120 " [*|host|<vmname> [<metric_list>]]\n"
1121 "\n", SEP, SEP, SEP, SEP, SEP, SEP);
1122
1123#if defined(VBOX_WITH_NAT_SERVICE)
1124 if (fCategory & USAGE_NATNETWORK)
1125 {
1126 RTStrmPrintf(pStrm,
1127 "%s natnetwork %s add --netname <name>\n"
1128 " --network <network>\n"
1129 " [--enable|--disable]\n"
1130 " [--dhcp on|off]\n"
1131 " [--port-forward-4 <rule>]\n"
1132 " [--loopback-4 <rule>]\n"
1133 " [--ipv6 on|off]\n"
1134 " [--port-forward-6 <rule>]\n"
1135 " [--loopback-6 <rule>]\n\n"
1136 "%s natnetwork %s remove --netname <name>\n\n"
1137 "%s natnetwork %s modify --netname <name>\n"
1138 " [--network <network>]\n"
1139 " [--enable|--disable]\n"
1140 " [--dhcp on|off]\n"
1141 " [--port-forward-4 <rule>]\n"
1142 " [--loopback-4 <rule>]\n"
1143 " [--ipv6 on|off]\n"
1144 " [--port-forward-6 <rule>]\n"
1145 " [--loopback-6 <rule>]\n\n"
1146 "%s natnetwork %s start --netname <name>\n\n"
1147 "%s natnetwork %s stop --netname <name>\n\n"
1148 "%s natnetwork %s list [<pattern>]\n"
1149 "\n", SEP, SEP, SEP, SEP, SEP, SEP);
1150
1151
1152 }
1153#endif
1154
1155#if defined(VBOX_WITH_NETFLT)
1156 if (fCategory & USAGE_HOSTONLYIFS)
1157 {
1158 RTStrmPrintf(pStrm,
1159 "%s hostonlyif %s ipconfig <name>\n"
1160 " [--dhcp |\n"
1161 " --ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |\n"
1162 " --ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]\n"
1163# if !defined(RT_OS_SOLARIS) || defined(VBOX_ONLY_DOCS)
1164 " create |\n"
1165 " remove <name>\n"
1166# endif
1167 "\n", SEP);
1168 }
1169#endif
1170
1171 if (fCategory & USAGE_DHCPSERVER)
1172 {
1173 RTStrmPrintf(pStrm,
1174 "%s dhcpserver %s add|modify --netname <network_name> |\n"
1175#if defined(VBOX_WITH_NETFLT)
1176 " --ifname <hostonly_if_name>\n"
1177#endif
1178 " [--ip <ip_address>\n"
1179 " --netmask <network_mask>\n"
1180 " --lowerip <lower_ip>\n"
1181 " --upperip <upper_ip>]\n"
1182 " [--enable | --disable]\n\n"
1183 "%s dhcpserver %s remove --netname <network_name> |\n"
1184#if defined(VBOX_WITH_NETFLT)
1185 " --ifname <hostonly_if_name>\n"
1186#endif
1187 "\n", SEP, SEP);
1188 }
1189
1190 if (fCategory & USAGE_USBDEVSOURCE)
1191 {
1192 RTStrmPrintf(pStrm,
1193 "%s usbdevsource %s add <source name>\n"
1194 " --backend <backend>\n"
1195 " --address <address>\n"
1196 "%s usbdevsource %s remove <source name>\n"
1197 "\n", SEP, SEP);
1198 }
1199
1200#ifndef VBOX_ONLY_DOCS /* Converted to man page, not needed. */
1201 if (fCategory == USAGE_ALL)
1202 {
1203 uint32_t cPendingBlankLines = 0;
1204 for (uint32_t i = 0; i < g_cHelpEntries; i++)
1205 {
1206 PCRTMSGREFENTRY pHelp = g_apHelpEntries[i];
1207 while (cPendingBlankLines-- > 0)
1208 RTStrmPutCh(pStrm, '\n');
1209 RTStrmPrintf(pStrm, " %c%s:\n", RT_C_TO_UPPER(pHelp->pszBrief[0]), pHelp->pszBrief + 1);
1210 cPendingBlankLines = 0;
1211 RTMsgRefEntryPrintStringTable(pStrm, &pHelp->Synopsis, RTMSGREFENTRYSTR_SCOPE_GLOBAL,
1212 &cPendingBlankLines, NULL /*pcLinesWritten*/);
1213 cPendingBlankLines = RT_MAX(cPendingBlankLines, 1);
1214 }
1215 }
1216#endif
1217}
1218
1219/**
1220 * Print a usage synopsis and the syntax error message.
1221 * @returns RTEXITCODE_SYNTAX.
1222 */
1223RTEXITCODE errorSyntax(USAGECATEGORY fCategory, const char *pszFormat, ...)
1224{
1225 va_list args;
1226 showLogo(g_pStdErr); // show logo even if suppressed
1227#ifndef VBOX_ONLY_DOCS
1228 if (g_fInternalMode)
1229 printUsageInternal(fCategory, g_pStdErr);
1230 else
1231 printUsage(fCategory, ~0U, g_pStdErr);
1232#else
1233 RT_NOREF_PV(fCategory);
1234#endif
1235 va_start(args, pszFormat);
1236 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
1237 va_end(args);
1238 return RTEXITCODE_SYNTAX;
1239}
1240
1241/**
1242 * Print a usage synopsis and the syntax error message.
1243 * @returns RTEXITCODE_SYNTAX.
1244 */
1245RTEXITCODE errorSyntaxEx(USAGECATEGORY fCategory, uint32_t fSubCategory, const char *pszFormat, ...)
1246{
1247 va_list args;
1248 showLogo(g_pStdErr); // show logo even if suppressed
1249#ifndef VBOX_ONLY_DOCS
1250 if (g_fInternalMode)
1251 printUsageInternal(fCategory, g_pStdErr);
1252 else
1253 printUsage(fCategory, fSubCategory, g_pStdErr);
1254#else
1255 RT_NOREF2(fCategory, fSubCategory);
1256#endif
1257 va_start(args, pszFormat);
1258 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
1259 va_end(args);
1260 return RTEXITCODE_SYNTAX;
1261}
1262
1263/**
1264 * errorSyntax for RTGetOpt users.
1265 *
1266 * @returns RTEXITCODE_SYNTAX.
1267 *
1268 * @param fCategory The usage category of the command.
1269 * @param fSubCategory The usage sub-category of the command.
1270 * @param rc The RTGetOpt return code.
1271 * @param pValueUnion The value union.
1272 */
1273RTEXITCODE errorGetOptEx(USAGECATEGORY fCategory, uint32_t fSubCategory, int rc, union RTGETOPTUNION const *pValueUnion)
1274{
1275 /*
1276 * Check if it is an unhandled standard option.
1277 */
1278#ifndef VBOX_ONLY_DOCS
1279 if (rc == 'V')
1280 {
1281 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision());
1282 return RTEXITCODE_SUCCESS;
1283 }
1284#endif
1285
1286 if (rc == 'h')
1287 {
1288 showLogo(g_pStdErr);
1289#ifndef VBOX_ONLY_DOCS
1290 if (g_fInternalMode)
1291 printUsageInternal(fCategory, g_pStdOut);
1292 else
1293 printUsage(fCategory, fSubCategory, g_pStdOut);
1294#endif
1295 return RTEXITCODE_SUCCESS;
1296 }
1297
1298 /*
1299 * General failure.
1300 */
1301 showLogo(g_pStdErr); // show logo even if suppressed
1302#ifndef VBOX_ONLY_DOCS
1303 if (g_fInternalMode)
1304 printUsageInternal(fCategory, g_pStdErr);
1305 else
1306 printUsage(fCategory, fSubCategory, g_pStdErr);
1307#else
1308 RT_NOREF2(fCategory, fSubCategory);
1309#endif
1310
1311 if (rc == VINF_GETOPT_NOT_OPTION)
1312 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid parameter '%s'", pValueUnion->psz);
1313 if (rc > 0)
1314 {
1315 if (RT_C_IS_PRINT(rc))
1316 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option -%c", rc);
1317 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option case %i", rc);
1318 }
1319 if (rc == VERR_GETOPT_UNKNOWN_OPTION)
1320 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown option: %s", pValueUnion->psz);
1321 if (rc == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)
1322 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid argument format: %s", pValueUnion->psz);
1323 if (pValueUnion->pDef)
1324 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, rc);
1325 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%Rrs", rc);
1326}
1327
1328/**
1329 * errorSyntax for RTGetOpt users.
1330 *
1331 * @returns RTEXITCODE_SYNTAX.
1332 *
1333 * @param fUsageCategory The usage category of the command.
1334 * @param rc The RTGetOpt return code.
1335 * @param pValueUnion The value union.
1336 */
1337RTEXITCODE errorGetOpt(USAGECATEGORY fCategory, int rc, union RTGETOPTUNION const *pValueUnion)
1338{
1339 return errorGetOptEx(fCategory, ~0U, rc, pValueUnion);
1340}
1341
1342/**
1343 * Print an error message without the syntax stuff.
1344 *
1345 * @returns RTEXITCODE_SYNTAX.
1346 */
1347RTEXITCODE errorArgument(const char *pszFormat, ...)
1348{
1349 va_list args;
1350 va_start(args, pszFormat);
1351 RTMsgErrorV(pszFormat, args);
1352 va_end(args);
1353 return RTEXITCODE_SYNTAX;
1354}
1355
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette