VirtualBox

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

Last change on this file since 77887 was 77887, checked in by vboxsync, 5 years ago

manual/VBoxManage: Made the new clonevm build. Again, there must be '=' between an option name and its value. The help-scope in the example section is not needed for commands without sub-commands. Use 'vmname|uuid' rather than just 'vm' as it's easier to grasp when just seeing the command synopsis.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use