VirtualBox

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

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

VBoxManage snapshot: Use manpage help text (option parsing needs cleaning up!).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 67.6 KB
Line 
1/* $Id: VBoxManageHelp.cpp 77801 2019-03-19 17:44:40Z 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_CLONEVM || enmCommand == USAGE_S_ALL)
737 RTStrmPrintf(pStrm,
738 "%s clonevm %s <uuid|vmname>\n"
739 " [--snapshot <uuid>|<name>]\n"
740 " [--mode machine|machineandchildren|all]\n"
741 " [--options link|keepallmacs|keepnatmacs|\n"
742 " keepdisknames|keephwuuids]\n"
743 " [--name <name>]\n"
744 " [--groups <group>, ...]\n"
745 " [--basefolder <basefolder>]\n"
746 " [--uuid <uuid>]\n"
747 " [--register]\n"
748 "\n", SEP);
749
750 if (enmCommand == USAGE_MOVEVM || enmCommand == USAGE_S_ALL)
751 RTStrmPrintf(pStrm,
752 "%s movevm %s <uuid|vmname>\n"
753 " --type basic\n"
754 " [--folder <path>]\n"
755 "\n", SEP);
756
757 if (enmCommand == USAGE_IMPORTAPPLIANCE || enmCommand == USAGE_S_ALL)
758 RTStrmPrintf(pStrm,
759 "%s import %s <ovfname/ovaname>\n"
760 " [--dry-run|-n]\n"
761 " [--options keepallmacs|keepnatmacs|importtovdi]\n"
762 " [more options]\n"
763 " (run with -n to have options displayed\n"
764 " for a particular OVF)\n\n", SEP);
765
766 if (enmCommand == USAGE_EXPORTAPPLIANCE || enmCommand == USAGE_S_ALL)
767 RTStrmPrintf(pStrm,
768 "%s export %s <machines> --output|-o <name>.<ovf/ova/tar.gz>\n"
769 " [--legacy09|--ovf09|--ovf10|--ovf20|--opc10]\n"
770 " [--manifest]\n"
771 " [--iso]\n"
772 " [--options manifest|iso|nomacs|nomacsbutnat]\n"
773 " [--vsys <number of virtual system>]\n"
774 " [--vmname <name>]\n"
775 " [--product <product name>]\n"
776 " [--producturl <product url>]\n"
777 " [--vendor <vendor name>]\n"
778 " [--vendorurl <vendor url>]\n"
779 " [--version <version info>]\n"
780 " [--description <description info>]\n"
781 " [--eula <license text>]\n"
782 " [--eulafile <filename>]\n"
783 " [--cloud <number of virtual system>]\n"
784 " [--vmname <name>]\n"
785 " [--cloudprofile <cloud profile name>]\n"
786 " [--cloudshape <shape>]\n"
787 " [--clouddomain <domain>]\n"
788 " [--clouddisksize <disk size in GB>]\n"
789 " [--cloudbucket <bucket name>]\n"
790 " [--cloudocivcn <OCI vcn id>]\n"
791 " [--cloudocisubnet <OCI subnet id>]\n"
792 " [--cloudkeepobject <true/false>]\n"
793 " [--cloudlaunchinstance <true/false>]\n"
794 " [--cloudpublicip <true/false>]\n"
795 "\n", SEP);
796
797 if (enmCommand == USAGE_STARTVM || enmCommand == USAGE_S_ALL)
798 {
799 RTStrmPrintf(pStrm,
800 "%s startvm %s <uuid|vmname>...\n"
801 " [--type gui", SEP);
802 if (fVBoxSDL)
803 RTStrmPrintf(pStrm, "|sdl");
804 RTStrmPrintf(pStrm, "|headless|separate]\n");
805 RTStrmPrintf(pStrm,
806 " [-E|--putenv <NAME>[=<VALUE>]]\n"
807 "\n");
808 }
809
810 if (enmCommand == USAGE_CONTROLVM || enmCommand == USAGE_S_ALL)
811 {
812 RTStrmPrintf(pStrm,
813 "%s controlvm %s <uuid|vmname>\n"
814 " pause|resume|reset|poweroff|savestate|\n"
815 " acpipowerbutton|acpisleepbutton|\n"
816 " keyboardputscancode <hex> [<hex> ...]|\n"
817 " keyboardputstring <string1> [<string2> ...]|\n"
818 " keyboardputfile <filename>|\n"
819 " setlinkstate<1-N> on|off |\n"
820#if defined(VBOX_WITH_NETFLT)
821 " nic<1-N> null|nat|bridged|intnet|hostonly|generic|\n"
822 " natnetwork [<devicename>] |\n"
823#else /* !VBOX_WITH_NETFLT */
824 " nic<1-N> null|nat|bridged|intnet|generic|natnetwork\n"
825 " [<devicename>] |\n"
826#endif /* !VBOX_WITH_NETFLT */
827 " nictrace<1-N> on|off |\n"
828 " nictracefile<1-N> <filename> |\n"
829 " nicproperty<1-N> name=[value] |\n"
830 " nicpromisc<1-N> deny|allow-vms|allow-all |\n"
831 " natpf<1-N> [<rulename>],tcp|udp,[<hostip>],\n"
832 " <hostport>,[<guestip>],<guestport> |\n"
833 " natpf<1-N> delete <rulename> |\n"
834 " guestmemoryballoon <balloonsize in MB> |\n"
835 " usbattach <uuid>|<address>\n"
836 " [--capturefile <filename>] |\n"
837 " usbdetach <uuid>|<address> |\n"
838 " audioin on|off |\n"
839 " audioout on|off |\n"
840 " clipboard disabled|hosttoguest|guesttohost|\n"
841 " bidirectional |\n"
842 " draganddrop disabled|hosttoguest|guesttohost|\n"
843 " bidirectional |\n"
844 " vrde on|off |\n"
845 " vrdeport <port> |\n"
846 " vrdeproperty <name=[value]> |\n"
847 " vrdevideochannelquality <percent> |\n"
848 " setvideomodehint <xres> <yres> <bpp>\n"
849 " [[<display>] [<enabled:yes|no> |\n"
850 " [<xorigin> <yorigin>]]] |\n"
851 " setscreenlayout <display> on|primary <xorigin> <yorigin> <xres> <yres> <bpp> | off\n"
852 " screenshotpng <file> [display] |\n"
853#ifdef VBOX_WITH_RECORDING
854 " recording on|off |\n"
855 " recording screens all|none|<screen>,[<screen>...] |\n"
856 " recording filename <file> |\n"
857 " recording videores <width>x<height> |\n"
858 " recording videorate <rate> |\n"
859 " recording videofps <fps> |\n"
860 " recording maxtime <s> |\n"
861 " recording maxfilesize <MB> |\n"
862#endif /* VBOX_WITH_RECORDING */
863 " setcredentials <username>\n"
864 " --passwordfile <file> | <password>\n"
865 " <domain>\n"
866 " [--allowlocallogon <yes|no>] |\n"
867 " teleport --host <name> --port <port>\n"
868 " [--maxdowntime <msec>]\n"
869 " [--passwordfile <file> |\n"
870 " --password <password>] |\n"
871 " plugcpu <id> |\n"
872 " unplugcpu <id> |\n"
873 " cpuexecutioncap <1-100>\n"
874 " webcam <attach [path [settings]]> | <detach [path]> | <list>\n"
875 " addencpassword <id>\n"
876 " <password file>|-\n"
877 " [--removeonsuspend <yes|no>]\n"
878 " removeencpassword <id>\n"
879 " removeallencpasswords\n"
880 " changeuartmode<1-N> disconnected|\n"
881 " server <pipe>|\n"
882 " client <pipe>|\n"
883 " tcpserver <port>|\n"
884 " tcpclient <hostname:port>|\n"
885 " file <file>|\n"
886 " <devicename>]\n"
887 "\n", SEP);
888 }
889
890 if (enmCommand == USAGE_DISCARDSTATE || enmCommand == USAGE_S_ALL)
891 RTStrmPrintf(pStrm,
892 "%s discardstate %s <uuid|vmname>\n"
893 "\n", SEP);
894
895 if (enmCommand == USAGE_ADOPTSTATE || enmCommand == USAGE_S_ALL)
896 RTStrmPrintf(pStrm,
897 "%s adoptstate %s <uuid|vmname> <state_file>\n"
898 "\n", SEP);
899
900 if (enmCommand == USAGE_CLOSEMEDIUM || enmCommand == USAGE_S_ALL)
901 RTStrmPrintf(pStrm,
902 "%s closemedium %s [disk|dvd|floppy] <uuid|filename>\n"
903 " [--delete]\n"
904 "\n", SEP);
905
906 if (enmCommand == USAGE_STORAGEATTACH || enmCommand == USAGE_S_ALL)
907 RTStrmPrintf(pStrm,
908 "%s storageattach %s <uuid|vmname>\n"
909 " --storagectl <name>\n"
910 " [--port <number>]\n"
911 " [--device <number>]\n"
912 " [--type dvddrive|hdd|fdd]\n"
913 " [--medium none|emptydrive|additions|\n"
914 " <uuid|filename>|host:<drive>|iscsi]\n"
915 " [--mtype normal|writethrough|immutable|shareable|\n"
916 " readonly|multiattach]\n"
917 " [--comment <text>]\n"
918 " [--setuuid <uuid>]\n"
919 " [--setparentuuid <uuid>]\n"
920 " [--passthrough on|off]\n"
921 " [--tempeject on|off]\n"
922 " [--nonrotational on|off]\n"
923 " [--discard on|off]\n"
924 " [--hotpluggable on|off]\n"
925 " [--bandwidthgroup <name>]\n"
926 " [--forceunmount]\n"
927 " [--server <name>|<ip>]\n"
928 " [--target <target>]\n"
929 " [--tport <port>]\n"
930 " [--lun <lun>]\n"
931 " [--encodedlun <lun>]\n"
932 " [--username <username>]\n"
933 " [--password <password>]\n"
934 " [--passwordfile <file>]\n"
935 " [--initiator <initiator>]\n"
936 " [--intnet]\n"
937 "\n", SEP);
938
939 if (enmCommand == USAGE_STORAGECONTROLLER || enmCommand == USAGE_S_ALL)
940 RTStrmPrintf(pStrm,
941 "%s storagectl %s <uuid|vmname>\n"
942 " --name <name>\n"
943 " [--add ide|sata|scsi|floppy|sas|usb|pcie]\n"
944 " [--controller LSILogic|LSILogicSAS|BusLogic|\n"
945 " IntelAHCI|PIIX3|PIIX4|ICH6|I82078|\n"
946 " [ USB|NVMe]\n"
947 " [--portcount <1-n>]\n"
948 " [--hostiocache on|off]\n"
949 " [--bootable on|off]\n"
950 " [--rename <name>]\n"
951 " [--remove]\n"
952 "\n", SEP);
953
954 if (enmCommand == USAGE_BANDWIDTHCONTROL || enmCommand == USAGE_S_ALL)
955 RTStrmPrintf(pStrm,
956 "%s bandwidthctl %s <uuid|vmname>\n"
957 " add <name> --type disk|network\n"
958 " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
959 " set <name>\n"
960 " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
961 " remove <name> |\n"
962 " list [--machinereadable]\n"
963 " (limit units: k=kilobit, m=megabit, g=gigabit,\n"
964 " K=kilobyte, M=megabyte, G=gigabyte)\n"
965 "\n", SEP);
966
967 if (enmCommand == USAGE_SHOWMEDIUMINFO || enmCommand == USAGE_S_ALL)
968 RTStrmPrintf(pStrm,
969 "%s showmediuminfo %s [disk|dvd|floppy] <uuid|filename>\n"
970 "\n", SEP);
971
972 if (enmCommand == USAGE_CREATEMEDIUM || enmCommand == USAGE_S_ALL)
973 RTStrmPrintf(pStrm,
974 "%s createmedium %s [disk|dvd|floppy] --filename <filename>\n"
975 " [--size <megabytes>|--sizebyte <bytes>]\n"
976 " [--diffparent <uuid>|<filename>\n"
977 " [--format VDI|VMDK|VHD] (default: VDI)\n"
978 " [--variant Standard,Fixed,Split2G,Stream,ESX,\n"
979 " Formatted]\n"
980 " [[--property <name>=<value>] --property <name>=<value]...\n"
981 "\n", SEP);
982
983 if (enmCommand == USAGE_MODIFYMEDIUM || enmCommand == USAGE_S_ALL)
984 RTStrmPrintf(pStrm,
985 "%s modifymedium %s [disk|dvd|floppy] <uuid|filename>\n"
986 " [--type normal|writethrough|immutable|shareable|\n"
987 " readonly|multiattach]\n"
988 " [--autoreset on|off]\n"
989 " [--property <name=[value]>]\n"
990 " [--compact]\n"
991 " [--resize <megabytes>|--resizebyte <bytes>]\n"
992 " [--move <path>]\n"
993 " [--setlocation <path>]\n"
994 " [--description <description string>]"
995 "\n", SEP);
996
997 if (enmCommand == USAGE_CLONEMEDIUM || enmCommand == USAGE_S_ALL)
998 RTStrmPrintf(pStrm,
999 "%s clonemedium %s [disk|dvd|floppy] <uuid|inputfile> <uuid|outputfile>\n"
1000 " [--format VDI|VMDK|VHD|RAW|<other>]\n"
1001 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1002 " [--existing]\n"
1003 "\n", SEP);
1004
1005 if (enmCommand == USAGE_MEDIUMPROPERTY || enmCommand == USAGE_S_ALL)
1006 RTStrmPrintf(pStrm,
1007 "%s mediumproperty %s [disk|dvd|floppy] set <uuid|filename>\n"
1008 " <property> <value>\n"
1009 "\n"
1010 " [disk|dvd|floppy] get <uuid|filename>\n"
1011 " <property>\n"
1012 "\n"
1013 " [disk|dvd|floppy] delete <uuid|filename>\n"
1014 " <property>\n"
1015 "\n", SEP);
1016
1017 if (enmCommand == USAGE_ENCRYPTMEDIUM || enmCommand == USAGE_S_ALL)
1018 RTStrmPrintf(pStrm,
1019 "%s encryptmedium %s <uuid|filename>\n"
1020 " [--newpassword <file>|-]\n"
1021 " [--oldpassword <file>|-]\n"
1022 " [--cipher <cipher identifier>]\n"
1023 " [--newpasswordid <password identifier>]\n"
1024 "\n", SEP);
1025
1026 if (enmCommand == USAGE_MEDIUMENCCHKPWD || enmCommand == USAGE_S_ALL)
1027 RTStrmPrintf(pStrm,
1028 "%s checkmediumpwd %s <uuid|filename>\n"
1029 " <pwd file>|-\n"
1030 "\n", SEP);
1031
1032 if (enmCommand == USAGE_CONVERTFROMRAW || enmCommand == USAGE_S_ALL)
1033 RTStrmPrintf(pStrm,
1034 "%s convertfromraw %s <filename> <outputfile>\n"
1035 " [--format VDI|VMDK|VHD]\n"
1036 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1037 " [--uuid <uuid>]\n"
1038 "%s convertfromraw %s stdin <outputfile> <bytes>\n"
1039 " [--format VDI|VMDK|VHD]\n"
1040 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1041 " [--uuid <uuid>]\n"
1042 "\n", SEP, SEP);
1043
1044 if (enmCommand == USAGE_GETEXTRADATA || enmCommand == USAGE_S_ALL)
1045 RTStrmPrintf(pStrm,
1046 "%s getextradata %s global|<uuid|vmname>\n"
1047 " <key>|[enumerate]\n"
1048 "\n", SEP);
1049
1050 if (enmCommand == USAGE_SETEXTRADATA || enmCommand == USAGE_S_ALL)
1051 RTStrmPrintf(pStrm,
1052 "%s setextradata %s global|<uuid|vmname>\n"
1053 " <key>\n"
1054 " [<value>] (no value deletes key)\n"
1055 "\n", SEP);
1056
1057 if (enmCommand == USAGE_SETPROPERTY || enmCommand == USAGE_S_ALL)
1058 RTStrmPrintf(pStrm,
1059 "%s setproperty %s machinefolder default|<folder> |\n"
1060 " hwvirtexclusive on|off |\n"
1061 " vrdeauthlibrary default|<library> |\n"
1062 " websrvauthlibrary default|null|<library> |\n"
1063 " vrdeextpack null|<library> |\n"
1064 " autostartdbpath null|<folder> |\n"
1065 " loghistorycount <value>\n"
1066 " defaultfrontend default|<name>\n"
1067 " logginglevel <log setting>\n"
1068 " proxymode system|noproxy|manual\n"
1069 " proxyurl <url>\n"
1070 "\n", SEP);
1071
1072 if (enmCommand == USAGE_USBFILTER || enmCommand == USAGE_S_ALL)
1073 {
1074 if (fSubcommandScope & HELP_SCOPE_USBFILTER_ADD)
1075 RTStrmPrintf(pStrm,
1076 "%s usbfilter %s add <index,0-N>\n"
1077 " --target <uuid|vmname>|global\n"
1078 " --name <string>\n"
1079 " --action ignore|hold (global filters only)\n"
1080 " [--active yes|no] (yes)\n"
1081 " [--vendorid <XXXX>] (null)\n"
1082 " [--productid <XXXX>] (null)\n"
1083 " [--revision <IIFF>] (null)\n"
1084 " [--manufacturer <string>] (null)\n"
1085 " [--product <string>] (null)\n"
1086 " [--remote yes|no] (null, VM filters only)\n"
1087 " [--serialnumber <string>] (null)\n"
1088 " [--maskedinterfaces <XXXXXXXX>]\n"
1089 "\n", SEP);
1090
1091 if (fSubcommandScope & HELP_SCOPE_USBFILTER_MODIFY)
1092 RTStrmPrintf(pStrm,
1093 "%s usbfilter %s modify <index,0-N>\n"
1094 " --target <uuid|vmname>|global\n"
1095 " [--name <string>]\n"
1096 " [--action ignore|hold] (global filters only)\n"
1097 " [--active yes|no]\n"
1098 " [--vendorid <XXXX>|\"\"]\n"
1099 " [--productid <XXXX>|\"\"]\n"
1100 " [--revision <IIFF>|\"\"]\n"
1101 " [--manufacturer <string>|\"\"]\n"
1102 " [--product <string>|\"\"]\n"
1103 " [--remote yes|no] (null, VM filters only)\n"
1104 " [--serialnumber <string>|\"\"]\n"
1105 " [--maskedinterfaces <XXXXXXXX>]\n"
1106 "\n", SEP);
1107
1108 if (fSubcommandScope & HELP_SCOPE_USBFILTER_REMOVE)
1109 RTStrmPrintf(pStrm,
1110 "%s usbfilter %s remove <index,0-N>\n"
1111 " --target <uuid|vmname>|global\n"
1112 "\n", SEP);
1113 }
1114
1115 if (enmCommand == USAGE_SHAREDFOLDER || enmCommand == USAGE_S_ALL)
1116 {
1117 if (fSubcommandScope & HELP_SCOPE_SHAREDFOLDER_ADD)
1118 RTStrmPrintf(pStrm,
1119 "%s sharedfolder %s add <uuid|vmname>\n"
1120 " --name <name> --hostpath <hostpath>\n"
1121 " [--transient] [--readonly] [--automount]\n"
1122 "\n", SEP);
1123
1124 if (fSubcommandScope & HELP_SCOPE_SHAREDFOLDER_REMOVE)
1125 RTStrmPrintf(pStrm,
1126 "%s sharedfolder %s remove <uuid|vmname>\n"
1127 " --name <name> [--transient]\n"
1128 "\n", SEP);
1129 }
1130
1131#ifdef VBOX_WITH_GUEST_PROPS
1132 if (enmCommand == USAGE_GUESTPROPERTY || enmCommand == USAGE_S_ALL)
1133 usageGuestProperty(pStrm, SEP);
1134#endif /* VBOX_WITH_GUEST_PROPS defined */
1135
1136#ifdef VBOX_WITH_GUEST_CONTROL
1137 if (enmCommand == USAGE_GUESTCONTROL || enmCommand == USAGE_S_ALL)
1138 usageGuestControl(pStrm, SEP, fSubcommandScope);
1139#endif /* VBOX_WITH_GUEST_CONTROL defined */
1140
1141 if (enmCommand == USAGE_METRICS || enmCommand == USAGE_S_ALL)
1142 RTStrmPrintf(pStrm,
1143 "%s metrics %s list [*|host|<vmname> [<metric_list>]]\n"
1144 " (comma-separated)\n\n"
1145 "%s metrics %s setup\n"
1146 " [--period <seconds>] (default: 1)\n"
1147 " [--samples <count>] (default: 1)\n"
1148 " [--list]\n"
1149 " [*|host|<vmname> [<metric_list>]]\n\n"
1150 "%s metrics %s query [*|host|<vmname> [<metric_list>]]\n\n"
1151 "%s metrics %s enable\n"
1152 " [--list]\n"
1153 " [*|host|<vmname> [<metric_list>]]\n\n"
1154 "%s metrics %s disable\n"
1155 " [--list]\n"
1156 " [*|host|<vmname> [<metric_list>]]\n\n"
1157 "%s metrics %s collect\n"
1158 " [--period <seconds>] (default: 1)\n"
1159 " [--samples <count>] (default: 1)\n"
1160 " [--list]\n"
1161 " [--detach]\n"
1162 " [*|host|<vmname> [<metric_list>]]\n"
1163 "\n", SEP, SEP, SEP, SEP, SEP, SEP);
1164
1165#if defined(VBOX_WITH_NAT_SERVICE)
1166 if (enmCommand == USAGE_NATNETWORK || enmCommand == USAGE_S_ALL)
1167 {
1168 RTStrmPrintf(pStrm,
1169 "%s natnetwork %s add --netname <name>\n"
1170 " --network <network>\n"
1171 " [--enable|--disable]\n"
1172 " [--dhcp on|off]\n"
1173 " [--port-forward-4 <rule>]\n"
1174 " [--loopback-4 <rule>]\n"
1175 " [--ipv6 on|off]\n"
1176 " [--port-forward-6 <rule>]\n"
1177 " [--loopback-6 <rule>]\n\n"
1178 "%s natnetwork %s remove --netname <name>\n\n"
1179 "%s natnetwork %s modify --netname <name>\n"
1180 " [--network <network>]\n"
1181 " [--enable|--disable]\n"
1182 " [--dhcp on|off]\n"
1183 " [--port-forward-4 <rule>]\n"
1184 " [--loopback-4 <rule>]\n"
1185 " [--ipv6 on|off]\n"
1186 " [--port-forward-6 <rule>]\n"
1187 " [--loopback-6 <rule>]\n\n"
1188 "%s natnetwork %s start --netname <name>\n\n"
1189 "%s natnetwork %s stop --netname <name>\n\n"
1190 "%s natnetwork %s list [<pattern>]\n"
1191 "\n", SEP, SEP, SEP, SEP, SEP, SEP);
1192
1193
1194 }
1195#endif
1196
1197#if defined(VBOX_WITH_NETFLT)
1198 if (enmCommand == USAGE_HOSTONLYIFS || enmCommand == USAGE_S_ALL)
1199 {
1200 RTStrmPrintf(pStrm,
1201 "%s hostonlyif %s ipconfig <name>\n"
1202 " [--dhcp |\n"
1203 " --ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |\n"
1204 " --ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]\n"
1205# if !defined(RT_OS_SOLARIS) || defined(VBOX_ONLY_DOCS)
1206 " create |\n"
1207 " remove <name>\n"
1208# endif
1209 "\n", SEP);
1210 }
1211#endif
1212
1213 if (enmCommand == USAGE_DHCPSERVER || enmCommand == USAGE_S_ALL)
1214 {
1215 RTStrmPrintf(pStrm,
1216 "%s dhcpserver %s add|modify --netname <network_name> |\n"
1217#if defined(VBOX_WITH_NETFLT)
1218 " --ifname <hostonly_if_name>\n"
1219#endif
1220 " [--ip <ip_address>\n"
1221 " --netmask <network_mask>\n"
1222 " --lowerip <lower_ip>\n"
1223 " --upperip <upper_ip>]\n"
1224 " [--enable | --disable]\n"
1225 " [--options [--vm <name> --nic <1-N>]\n"
1226 " --id <number> [--value <string> | --remove]]\n"
1227 " (multiple options allowed after --options)\n\n"
1228 "%s dhcpserver %s remove --netname <network_name> |\n"
1229#if defined(VBOX_WITH_NETFLT)
1230 " --ifname <hostonly_if_name>\n"
1231#endif
1232 "\n", SEP, SEP);
1233 }
1234
1235 if (enmCommand == USAGE_USBDEVSOURCE || enmCommand == USAGE_S_ALL)
1236 {
1237 RTStrmPrintf(pStrm,
1238 "%s usbdevsource %s add <source name>\n"
1239 " --backend <backend>\n"
1240 " --address <address>\n"
1241 "%s usbdevsource %s remove <source name>\n"
1242 "\n", SEP, SEP);
1243 }
1244
1245#ifndef VBOX_ONLY_DOCS /* Converted to man page, not needed. */
1246 if (enmCommand == USAGE_S_ALL)
1247 {
1248 uint32_t cPendingBlankLines = 0;
1249 for (uint32_t i = 0; i < g_cHelpEntries; i++)
1250 {
1251 PCRTMSGREFENTRY pHelp = g_apHelpEntries[i];
1252 while (cPendingBlankLines-- > 0)
1253 RTStrmPutCh(pStrm, '\n');
1254 RTStrmPrintf(pStrm, " %c%s:\n", RT_C_TO_UPPER(pHelp->pszBrief[0]), pHelp->pszBrief + 1);
1255 cPendingBlankLines = 0;
1256 RTMsgRefEntryPrintStringTable(pStrm, &pHelp->Synopsis, RTMSGREFENTRYSTR_SCOPE_GLOBAL,
1257 &cPendingBlankLines, NULL /*pcLinesWritten*/);
1258 cPendingBlankLines = RT_MAX(cPendingBlankLines, 1);
1259 }
1260 }
1261#endif
1262}
1263
1264/**
1265 * Print a usage synopsis and the syntax error message.
1266 * @returns RTEXITCODE_SYNTAX.
1267 */
1268RTEXITCODE errorSyntax(USAGECATEGORY enmCommand, const char *pszFormat, ...)
1269{
1270 va_list args;
1271 showLogo(g_pStdErr); // show logo even if suppressed
1272#ifndef VBOX_ONLY_DOCS
1273 if (g_fInternalMode)
1274 printUsageInternal(enmCommand, g_pStdErr);
1275 else
1276 printUsage(enmCommand, RTMSGREFENTRYSTR_SCOPE_GLOBAL, g_pStdErr);
1277#else
1278 RT_NOREF_PV(enmCommand);
1279#endif
1280 va_start(args, pszFormat);
1281 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
1282 va_end(args);
1283 return RTEXITCODE_SYNTAX;
1284}
1285
1286/**
1287 * Print a usage synopsis and the syntax error message.
1288 * @returns RTEXITCODE_SYNTAX.
1289 */
1290RTEXITCODE errorSyntaxEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, const char *pszFormat, ...)
1291{
1292 va_list args;
1293 showLogo(g_pStdErr); // show logo even if suppressed
1294#ifndef VBOX_ONLY_DOCS
1295 if (g_fInternalMode)
1296 printUsageInternal(enmCommand, g_pStdErr);
1297 else
1298 printUsage(enmCommand, fSubcommandScope, g_pStdErr);
1299#else
1300 RT_NOREF2(enmCommand, fSubcommandScope);
1301#endif
1302 va_start(args, pszFormat);
1303 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
1304 va_end(args);
1305 return RTEXITCODE_SYNTAX;
1306}
1307
1308/**
1309 * errorSyntax for RTGetOpt users.
1310 *
1311 * @returns RTEXITCODE_SYNTAX.
1312 *
1313 * @param enmCommand The command.
1314 * @param fSubcommandScope The subcommand scope, REFENTRYSTR_SCOPE_GLOBAL
1315 * for all.
1316 * @param rc The RTGetOpt return code.
1317 * @param pValueUnion The value union.
1318 */
1319RTEXITCODE errorGetOptEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, int rc, union RTGETOPTUNION const *pValueUnion)
1320{
1321 /*
1322 * Check if it is an unhandled standard option.
1323 */
1324#ifndef VBOX_ONLY_DOCS
1325 if (rc == 'V')
1326 {
1327 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision());
1328 return RTEXITCODE_SUCCESS;
1329 }
1330#endif
1331
1332 if (rc == 'h')
1333 {
1334 showLogo(g_pStdErr);
1335#ifndef VBOX_ONLY_DOCS
1336 if (g_fInternalMode)
1337 printUsageInternal(enmCommand, g_pStdOut);
1338 else
1339 printUsage(enmCommand, fSubcommandScope, g_pStdOut);
1340#endif
1341 return RTEXITCODE_SUCCESS;
1342 }
1343
1344 /*
1345 * General failure.
1346 */
1347 showLogo(g_pStdErr); // show logo even if suppressed
1348#ifndef VBOX_ONLY_DOCS
1349 if (g_fInternalMode)
1350 printUsageInternal(enmCommand, g_pStdErr);
1351 else
1352 printUsage(enmCommand, fSubcommandScope, g_pStdErr);
1353#else
1354 RT_NOREF2(enmCommand, fSubcommandScope);
1355#endif
1356
1357 if (rc == VINF_GETOPT_NOT_OPTION)
1358 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid parameter '%s'", pValueUnion->psz);
1359 if (rc > 0)
1360 {
1361 if (RT_C_IS_PRINT(rc))
1362 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option -%c", rc);
1363 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option case %i", rc);
1364 }
1365 if (rc == VERR_GETOPT_UNKNOWN_OPTION)
1366 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown option: %s", pValueUnion->psz);
1367 if (rc == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)
1368 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid argument format: %s", pValueUnion->psz);
1369 if (pValueUnion->pDef)
1370 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, rc);
1371 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%Rrs", rc);
1372}
1373
1374/**
1375 * errorSyntax for RTGetOpt users.
1376 *
1377 * @returns RTEXITCODE_SYNTAX.
1378 *
1379 * @param enmCommand The command.
1380 * @param rc The RTGetOpt return code.
1381 * @param pValueUnion The value union.
1382 */
1383RTEXITCODE errorGetOpt(USAGECATEGORY enmCommand, int rc, union RTGETOPTUNION const *pValueUnion)
1384{
1385 return errorGetOptEx(enmCommand, RTMSGREFENTRYSTR_SCOPE_GLOBAL, rc, pValueUnion);
1386}
1387
1388/**
1389 * Print an error message without the syntax stuff.
1390 *
1391 * @returns RTEXITCODE_SYNTAX.
1392 */
1393RTEXITCODE errorArgument(const char *pszFormat, ...)
1394{
1395 va_list args;
1396 va_start(args, pszFormat);
1397 RTMsgErrorV(pszFormat, args);
1398 va_end(args);
1399 return RTEXITCODE_SYNTAX;
1400}
1401
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use