1 | /* $Id: VBoxManageHelp.cpp 76906 2019-01-21 06:32:55Z 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/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
|
---|
47 | enum HELP_CMD_VBOXMANAGE g_enmCurCommand = HELP_CMD_VBOXMANAGE_INVALID;
|
---|
48 | /** The scope maskt for the current subcommand. */
|
---|
49 | uint64_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 | */
|
---|
58 | void 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 | */
|
---|
73 | void 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 | */
|
---|
90 | static 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 | */
|
---|
123 | void 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 | */
|
---|
137 | static 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 | */
|
---|
162 | void 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 | */
|
---|
173 | RTEXITCODE 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 | */
|
---|
190 | RTEXITCODE 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 | */
|
---|
217 | RTEXITCODE 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 | */
|
---|
248 | RTEXITCODE 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 | */
|
---|
279 | static 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 | */
|
---|
312 | RTEXITCODE 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 |
|
---|
350 | void 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 |
|
---|
368 | void 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|cloudproviders|\n"
|
---|
452 | " cloudprofiles\n"
|
---|
453 | "\n", SEP);
|
---|
454 |
|
---|
455 | if (fCategory & USAGE_SHOWVMINFO)
|
---|
456 | RTStrmPrintf(pStrm,
|
---|
457 | "%s showvminfo %s <uuid|vmname> [--details]\n"
|
---|
458 | " [--machinereadable]\n"
|
---|
459 | "%s showvminfo %s <uuid|vmname> --log <idx>\n"
|
---|
460 | "\n", SEP, SEP);
|
---|
461 |
|
---|
462 | if (fCategory & USAGE_REGISTERVM)
|
---|
463 | RTStrmPrintf(pStrm,
|
---|
464 | "%s registervm %s <filename>\n"
|
---|
465 | "\n", SEP);
|
---|
466 |
|
---|
467 | if (fCategory & USAGE_UNREGISTERVM)
|
---|
468 | RTStrmPrintf(pStrm,
|
---|
469 | "%s unregistervm %s <uuid|vmname> [--delete]\n"
|
---|
470 | "\n", SEP);
|
---|
471 |
|
---|
472 | if (fCategory & USAGE_CREATEVM)
|
---|
473 | RTStrmPrintf(pStrm,
|
---|
474 | "%s createvm %s --name <name>\n"
|
---|
475 | " [--groups <group>, ...]\n"
|
---|
476 | " [--ostype <ostype>]\n"
|
---|
477 | " [--register]\n"
|
---|
478 | " [--basefolder <path>]\n"
|
---|
479 | " [--uuid <uuid>]\n"
|
---|
480 | " [--default]\n"
|
---|
481 | "\n", SEP);
|
---|
482 |
|
---|
483 | if (fCategory & USAGE_MODIFYVM)
|
---|
484 | {
|
---|
485 | RTStrmPrintf(pStrm,
|
---|
486 | "%s modifyvm %s <uuid|vmname>\n"
|
---|
487 | " [--name <name>]\n"
|
---|
488 | " [--groups <group>, ...]\n"
|
---|
489 | " [--description <desc>]\n"
|
---|
490 | " [--ostype <ostype>]\n"
|
---|
491 | " [--iconfile <filename>]\n"
|
---|
492 | " [--memory <memorysize in MB>]\n"
|
---|
493 | " [--pagefusion on|off]\n"
|
---|
494 | " [--vram <vramsize in MB>]\n"
|
---|
495 | " [--acpi on|off]\n"
|
---|
496 | #ifdef VBOX_WITH_PCI_PASSTHROUGH
|
---|
497 | " [--pciattach 03:04.0]\n"
|
---|
498 | " [--pciattach 03:04.0@02:01.0]\n"
|
---|
499 | " [--pcidetach 03:04.0]\n"
|
---|
500 | #endif
|
---|
501 | " [--ioapic on|off]\n"
|
---|
502 | " [--hpet on|off]\n"
|
---|
503 | " [--triplefaultreset on|off]\n"
|
---|
504 | " [--apic on|off]\n"
|
---|
505 | " [--x2apic on|off]\n"
|
---|
506 | " [--paravirtprovider none|default|legacy|minimal|\n"
|
---|
507 | " hyperv|kvm]\n"
|
---|
508 | " [--paravirtdebug <key=value> [,<key=value> ...]]\n"
|
---|
509 | " [--hwvirtex on|off]\n"
|
---|
510 | " [--nestedpaging on|off]\n"
|
---|
511 | " [--largepages on|off]\n"
|
---|
512 | " [--vtxvpid on|off]\n"
|
---|
513 | " [--vtxux on|off]\n"
|
---|
514 | " [--pae on|off]\n"
|
---|
515 | " [--longmode on|off]\n"
|
---|
516 | " [--ibpb-on-vm-exit on|off]\n"
|
---|
517 | " [--ibpb-on-vm-entry on|off]\n"
|
---|
518 | " [--spec-ctrl on|off]\n"
|
---|
519 | " [--l1d-flush-on-sched on|off]\n"
|
---|
520 | " [--l1d-flush-on-vm-entry on|off]\n"
|
---|
521 | " [--nested-hw-virt on|off]\n"
|
---|
522 | " [--cpu-profile \"host|Intel 80[86|286|386]\"]\n"
|
---|
523 | " [--cpuid-portability-level <0..3>\n"
|
---|
524 | " [--cpuid-set <leaf[:subleaf]> <eax> <ebx> <ecx> <edx>]\n"
|
---|
525 | " [--cpuid-remove <leaf[:subleaf]>]\n"
|
---|
526 | " [--cpuidremoveall]\n"
|
---|
527 | " [--hardwareuuid <uuid>]\n"
|
---|
528 | " [--cpus <number>]\n"
|
---|
529 | " [--cpuhotplug on|off]\n"
|
---|
530 | " [--plugcpu <id>]\n"
|
---|
531 | " [--unplugcpu <id>]\n"
|
---|
532 | " [--cpuexecutioncap <1-100>]\n"
|
---|
533 | " [--rtcuseutc on|off]\n"
|
---|
534 | #ifdef VBOX_WITH_VMSVGA
|
---|
535 | " [--graphicscontroller none|vboxvga|vmsvga|vboxsvga]\n"
|
---|
536 | #else
|
---|
537 | " [--graphicscontroller none|vboxvga]\n"
|
---|
538 | #endif
|
---|
539 | " [--monitorcount <number>]\n"
|
---|
540 | " [--accelerate3d on|off]\n"
|
---|
541 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
542 | " [--accelerate2dvideo on|off]\n"
|
---|
543 | #endif
|
---|
544 | " [--firmware bios|efi|efi32|efi64]\n"
|
---|
545 | " [--chipset ich9|piix3]\n"
|
---|
546 | " [--bioslogofadein on|off]\n"
|
---|
547 | " [--bioslogofadeout on|off]\n"
|
---|
548 | " [--bioslogodisplaytime <msec>]\n"
|
---|
549 | " [--bioslogoimagepath <imagepath>]\n"
|
---|
550 | " [--biosbootmenu disabled|menuonly|messageandmenu]\n"
|
---|
551 | " [--biosapic disabled|apic|x2apic]\n"
|
---|
552 | " [--biossystemtimeoffset <msec>]\n"
|
---|
553 | " [--biospxedebug on|off]\n"
|
---|
554 | " [--boot<1-4> none|floppy|dvd|disk|net>]\n"
|
---|
555 | " [--nic<1-N> none|null|nat|bridged|intnet"
|
---|
556 | #if defined(VBOX_WITH_NETFLT)
|
---|
557 | "|hostonly"
|
---|
558 | #endif
|
---|
559 | "|\n"
|
---|
560 | " generic|natnetwork"
|
---|
561 | "]\n"
|
---|
562 | " [--nictype<1-N> Am79C970A|Am79C973"
|
---|
563 | #ifdef VBOX_WITH_E1000
|
---|
564 | "|\n 82540EM|82543GC|82545EM"
|
---|
565 | #endif
|
---|
566 | #ifdef VBOX_WITH_VIRTIO
|
---|
567 | "|\n virtio"
|
---|
568 | #endif /* VBOX_WITH_VIRTIO */
|
---|
569 | "]\n"
|
---|
570 | " [--cableconnected<1-N> on|off]\n"
|
---|
571 | " [--nictrace<1-N> on|off]\n"
|
---|
572 | " [--nictracefile<1-N> <filename>]\n"
|
---|
573 | " [--nicproperty<1-N> name=[value]]\n"
|
---|
574 | " [--nicspeed<1-N> <kbps>]\n"
|
---|
575 | " [--nicbootprio<1-N> <priority>]\n"
|
---|
576 | " [--nicpromisc<1-N> deny|allow-vms|allow-all]\n"
|
---|
577 | " [--nicbandwidthgroup<1-N> none|<name>]\n"
|
---|
578 | " [--bridgeadapter<1-N> none|<devicename>]\n"
|
---|
579 | #if defined(VBOX_WITH_NETFLT)
|
---|
580 | " [--hostonlyadapter<1-N> none|<devicename>]\n"
|
---|
581 | #endif
|
---|
582 | " [--intnet<1-N> <network name>]\n"
|
---|
583 | " [--nat-network<1-N> <network name>]\n"
|
---|
584 | " [--nicgenericdrv<1-N> <driver>\n"
|
---|
585 | " [--natnet<1-N> <network>|default]\n"
|
---|
586 | " [--natsettings<1-N> [<mtu>],[<socksnd>],\n"
|
---|
587 | " [<sockrcv>],[<tcpsnd>],\n"
|
---|
588 | " [<tcprcv>]]\n"
|
---|
589 | " [--natpf<1-N> [<rulename>],tcp|udp,[<hostip>],\n"
|
---|
590 | " <hostport>,[<guestip>],<guestport>]\n"
|
---|
591 | " [--natpf<1-N> delete <rulename>]\n"
|
---|
592 | " [--nattftpprefix<1-N> <prefix>]\n"
|
---|
593 | " [--nattftpfile<1-N> <file>]\n"
|
---|
594 | " [--nattftpserver<1-N> <ip>]\n"
|
---|
595 | " [--natbindip<1-N> <ip>\n"
|
---|
596 | " [--natdnspassdomain<1-N> on|off]\n"
|
---|
597 | " [--natdnsproxy<1-N> on|off]\n"
|
---|
598 | " [--natdnshostresolver<1-N> on|off]\n"
|
---|
599 | " [--nataliasmode<1-N> default|[log],[proxyonly],\n"
|
---|
600 | " [sameports]]\n"
|
---|
601 | " [--macaddress<1-N> auto|<mac>]\n"
|
---|
602 | " [--mouse ps2|usb|usbtablet|usbmultitouch]\n"
|
---|
603 | " [--keyboard ps2|usb\n"
|
---|
604 | " [--uart<1-N> off|<I/O base> <IRQ>]\n"
|
---|
605 | " [--uartmode<1-N> disconnected|\n"
|
---|
606 | " server <pipe>|\n"
|
---|
607 | " client <pipe>|\n"
|
---|
608 | " tcpserver <port>|\n"
|
---|
609 | " tcpclient <hostname:port>|\n"
|
---|
610 | " file <file>|\n"
|
---|
611 | " <devicename>]\n"
|
---|
612 | " [--uarttype<1-N> 16450|16550A|16750\n"
|
---|
613 | #if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
|
---|
614 | " [--lpt<1-N> off|<I/O base> <IRQ>]\n"
|
---|
615 | " [--lptmode<1-N> <devicename>]\n"
|
---|
616 | #endif
|
---|
617 | " [--guestmemoryballoon <balloonsize in MB>]\n"
|
---|
618 | " [--audio none|null", SEP);
|
---|
619 | if (fWin)
|
---|
620 | {
|
---|
621 | #ifdef VBOX_WITH_WINMM
|
---|
622 | RTStrmPrintf(pStrm, "|winmm|dsound");
|
---|
623 | #else
|
---|
624 | RTStrmPrintf(pStrm, "|dsound");
|
---|
625 | #endif
|
---|
626 | }
|
---|
627 | if (fLinux || fSolaris)
|
---|
628 | {
|
---|
629 | RTStrmPrintf(pStrm, ""
|
---|
630 | #ifdef VBOX_WITH_AUDIO_OSS
|
---|
631 | "|oss"
|
---|
632 | #endif
|
---|
633 | #ifdef VBOX_WITH_AUDIO_ALSA
|
---|
634 | "|alsa"
|
---|
635 | #endif
|
---|
636 | #ifdef VBOX_WITH_AUDIO_PULSE
|
---|
637 | "|pulse"
|
---|
638 | #endif
|
---|
639 | );
|
---|
640 | }
|
---|
641 | if (fFreeBSD)
|
---|
642 | {
|
---|
643 | #ifdef VBOX_WITH_AUDIO_OSS
|
---|
644 | /* Get the line break sorted when dumping all option variants. */
|
---|
645 | if (fDumpOpts)
|
---|
646 | {
|
---|
647 | RTStrmPrintf(pStrm, "|\n"
|
---|
648 | " oss");
|
---|
649 | }
|
---|
650 | else
|
---|
651 | RTStrmPrintf(pStrm, "|oss");
|
---|
652 | #endif
|
---|
653 | #ifdef VBOX_WITH_AUDIO_PULSE
|
---|
654 | RTStrmPrintf(pStrm, "|pulse");
|
---|
655 | #endif
|
---|
656 | }
|
---|
657 | if (fDarwin)
|
---|
658 | {
|
---|
659 | RTStrmPrintf(pStrm, "|coreaudio");
|
---|
660 | }
|
---|
661 | RTStrmPrintf(pStrm, "]\n");
|
---|
662 | RTStrmPrintf(pStrm,
|
---|
663 | " [--audioin on|off]\n"
|
---|
664 | " [--audioout on|off]\n"
|
---|
665 | " [--audiocontroller ac97|hda|sb16]\n"
|
---|
666 | " [--audiocodec stac9700|ad1980|stac9221|sb16]\n"
|
---|
667 | " [--clipboard disabled|hosttoguest|guesttohost|\n"
|
---|
668 | " bidirectional]\n"
|
---|
669 | " [--draganddrop disabled|hosttoguest|guesttohost|\n"
|
---|
670 | " bidirectional]\n");
|
---|
671 | RTStrmPrintf(pStrm,
|
---|
672 | " [--vrde on|off]\n"
|
---|
673 | " [--vrdeextpack default|<name>\n"
|
---|
674 | " [--vrdeproperty <name=[value]>]\n"
|
---|
675 | " [--vrdeport <hostport>]\n"
|
---|
676 | " [--vrdeaddress <hostip>]\n"
|
---|
677 | " [--vrdeauthtype null|external|guest]\n"
|
---|
678 | " [--vrdeauthlibrary default|<name>\n"
|
---|
679 | " [--vrdemulticon on|off]\n"
|
---|
680 | " [--vrdereusecon on|off]\n"
|
---|
681 | " [--vrdevideochannel on|off]\n"
|
---|
682 | " [--vrdevideochannelquality <percent>]\n");
|
---|
683 | RTStrmPrintf(pStrm,
|
---|
684 | " [--usbohci on|off]\n"
|
---|
685 | " [--usbehci on|off]\n"
|
---|
686 | " [--usbxhci on|off]\n"
|
---|
687 | " [--usbrename <oldname> <newname>]\n"
|
---|
688 | " [--snapshotfolder default|<path>]\n"
|
---|
689 | " [--teleporter on|off]\n"
|
---|
690 | " [--teleporterport <port>]\n"
|
---|
691 | " [--teleporteraddress <address|empty>\n"
|
---|
692 | " [--teleporterpassword <password>]\n"
|
---|
693 | " [--teleporterpasswordfile <file>|stdin]\n"
|
---|
694 | " [--tracing-enabled on|off]\n"
|
---|
695 | " [--tracing-config <config-string>]\n"
|
---|
696 | " [--tracing-allow-vm-access on|off]\n"
|
---|
697 | #if 0
|
---|
698 | " [--iocache on|off]\n"
|
---|
699 | " [--iocachesize <I/O cache size in MB>]\n"
|
---|
700 | #endif
|
---|
701 | #if 0
|
---|
702 | " [--faulttolerance master|standby]\n"
|
---|
703 | " [--faulttoleranceaddress <name>]\n"
|
---|
704 | " [--faulttoleranceport <port>]\n"
|
---|
705 | " [--faulttolerancesyncinterval <msec>]\n"
|
---|
706 | " [--faulttolerancepassword <password>]\n"
|
---|
707 | #endif
|
---|
708 | #ifdef VBOX_WITH_USB_CARDREADER
|
---|
709 | " [--usbcardreader on|off]\n"
|
---|
710 | #endif
|
---|
711 | " [--autostart-enabled on|off]\n"
|
---|
712 | " [--autostart-delay <seconds>]\n"
|
---|
713 | #if 0
|
---|
714 | " [--autostop-type disabled|savestate|poweroff|\n"
|
---|
715 | " acpishutdown]\n"
|
---|
716 | #endif
|
---|
717 | #ifdef VBOX_WITH_RECORDING
|
---|
718 | " [--recording on|off]\n"
|
---|
719 | " [--recording screens all|<screen ID> [<screen ID> ...]]\n"
|
---|
720 | " [--recording filename <filename>]\n"
|
---|
721 | " [--recording videores <width> <height>]\n"
|
---|
722 | " [--recording videorate <rate>]\n"
|
---|
723 | " [--recording videofps <fps>]\n"
|
---|
724 | " [--recording maxtime <s>]\n"
|
---|
725 | " [--recording maxfilesize <MB>]\n"
|
---|
726 | " [--recording opts <key=value> [,<key=value> ...]]\n"
|
---|
727 | #endif
|
---|
728 | " [--defaultfrontend default|<name>]\n"
|
---|
729 | "\n");
|
---|
730 | }
|
---|
731 |
|
---|
732 | if (fCategory & USAGE_CLONEVM)
|
---|
733 | RTStrmPrintf(pStrm,
|
---|
734 | "%s clonevm %s <uuid|vmname>\n"
|
---|
735 | " [--snapshot <uuid>|<name>]\n"
|
---|
736 | " [--mode machine|machineandchildren|all]\n"
|
---|
737 | " [--options link|keepallmacs|keepnatmacs|\n"
|
---|
738 | " keepdisknames|keephwuuids]\n"
|
---|
739 | " [--name <name>]\n"
|
---|
740 | " [--groups <group>, ...]\n"
|
---|
741 | " [--basefolder <basefolder>]\n"
|
---|
742 | " [--uuid <uuid>]\n"
|
---|
743 | " [--register]\n"
|
---|
744 | "\n", SEP);
|
---|
745 |
|
---|
746 | if (fCategory & USAGE_MOVEVM)
|
---|
747 | RTStrmPrintf(pStrm,
|
---|
748 | "%s movevm %s <uuid|vmname>\n"
|
---|
749 | " --type basic\n"
|
---|
750 | " [--folder <path>]\n"
|
---|
751 | "\n", SEP);
|
---|
752 |
|
---|
753 | if (fCategory & USAGE_IMPORTAPPLIANCE)
|
---|
754 | RTStrmPrintf(pStrm,
|
---|
755 | "%s import %s <ovfname/ovaname>\n"
|
---|
756 | " [--dry-run|-n]\n"
|
---|
757 | " [--options keepallmacs|keepnatmacs|importtovdi]\n"
|
---|
758 | " [more options]\n"
|
---|
759 | " (run with -n to have options displayed\n"
|
---|
760 | " for a particular OVF)\n\n", SEP);
|
---|
761 |
|
---|
762 | if (fCategory & USAGE_EXPORTAPPLIANCE)
|
---|
763 | RTStrmPrintf(pStrm,
|
---|
764 | "%s export %s <machines> --output|-o <name>.<ovf/ova/tar.gz>\n"
|
---|
765 | " [--legacy09|--ovf09|--ovf10|--ovf20|--opc10]\n"
|
---|
766 | " [--manifest]\n"
|
---|
767 | " [--iso]\n"
|
---|
768 | " [--options manifest|iso|nomacs|nomacsbutnat]\n"
|
---|
769 | " [--vsys <number of virtual system>]\n"
|
---|
770 | " [--vmname <name>]\n"
|
---|
771 | " [--product <product name>]\n"
|
---|
772 | " [--producturl <product url>]\n"
|
---|
773 | " [--vendor <vendor name>]\n"
|
---|
774 | " [--vendorurl <vendor url>]\n"
|
---|
775 | " [--version <version info>]\n"
|
---|
776 | " [--description <description info>]\n"
|
---|
777 | " [--eula <license text>]\n"
|
---|
778 | " [--eulafile <filename>]\n"
|
---|
779 | " [--cloud <number of virtual system>]\n"
|
---|
780 | " [--vmname <name>]\n"
|
---|
781 | " [--cloudprofile <cloud profile name>]\n"
|
---|
782 | " [--cloudshape <shape>]\n"
|
---|
783 | " [--clouddomain <domain>]\n"
|
---|
784 | " [--clouddisksize <disk size in GB>]\n"
|
---|
785 | " [--cloudbucket <bucket name>]\n"
|
---|
786 | " [--cloudocivcn <OCI vcn id>]\n"
|
---|
787 | " [--cloudocisubnet <OCI subnet id>]\n"
|
---|
788 | " [--cloudkeepobject <true/false>]\n"
|
---|
789 | " [--cloudlaunchinstance <true/false>]\n"
|
---|
790 | " [--cloudpublicip <true/false>]\n"
|
---|
791 | "\n", SEP);
|
---|
792 |
|
---|
793 | if (fCategory & USAGE_STARTVM)
|
---|
794 | {
|
---|
795 | RTStrmPrintf(pStrm,
|
---|
796 | "%s startvm %s <uuid|vmname>...\n"
|
---|
797 | " [--type gui", SEP);
|
---|
798 | if (fVBoxSDL)
|
---|
799 | RTStrmPrintf(pStrm, "|sdl");
|
---|
800 | RTStrmPrintf(pStrm, "|headless|separate]\n");
|
---|
801 | RTStrmPrintf(pStrm,
|
---|
802 | " [-E|--putenv <NAME>[=<VALUE>]]\n"
|
---|
803 | "\n");
|
---|
804 | }
|
---|
805 |
|
---|
806 | if (fCategory & USAGE_CONTROLVM)
|
---|
807 | {
|
---|
808 | RTStrmPrintf(pStrm,
|
---|
809 | "%s controlvm %s <uuid|vmname>\n"
|
---|
810 | " pause|resume|reset|poweroff|savestate|\n"
|
---|
811 | " acpipowerbutton|acpisleepbutton|\n"
|
---|
812 | " keyboardputscancode <hex> [<hex> ...]|\n"
|
---|
813 | " keyboardputstring <string1> [<string2> ...]|\n"
|
---|
814 | " keyboardputfile <filename>|\n"
|
---|
815 | " setlinkstate<1-N> on|off |\n"
|
---|
816 | #if defined(VBOX_WITH_NETFLT)
|
---|
817 | " nic<1-N> null|nat|bridged|intnet|hostonly|generic|\n"
|
---|
818 | " natnetwork [<devicename>] |\n"
|
---|
819 | #else /* !VBOX_WITH_NETFLT */
|
---|
820 | " nic<1-N> null|nat|bridged|intnet|generic|natnetwork\n"
|
---|
821 | " [<devicename>] |\n"
|
---|
822 | #endif /* !VBOX_WITH_NETFLT */
|
---|
823 | " nictrace<1-N> on|off |\n"
|
---|
824 | " nictracefile<1-N> <filename> |\n"
|
---|
825 | " nicproperty<1-N> name=[value] |\n"
|
---|
826 | " nicpromisc<1-N> deny|allow-vms|allow-all |\n"
|
---|
827 | " natpf<1-N> [<rulename>],tcp|udp,[<hostip>],\n"
|
---|
828 | " <hostport>,[<guestip>],<guestport> |\n"
|
---|
829 | " natpf<1-N> delete <rulename> |\n"
|
---|
830 | " guestmemoryballoon <balloonsize in MB> |\n"
|
---|
831 | " usbattach <uuid>|<address>\n"
|
---|
832 | " [--capturefile <filename>] |\n"
|
---|
833 | " usbdetach <uuid>|<address> |\n"
|
---|
834 | " audioin on|off |\n"
|
---|
835 | " audioout on|off |\n"
|
---|
836 | " clipboard disabled|hosttoguest|guesttohost|\n"
|
---|
837 | " bidirectional |\n"
|
---|
838 | " draganddrop disabled|hosttoguest|guesttohost|\n"
|
---|
839 | " bidirectional |\n"
|
---|
840 | " vrde on|off |\n"
|
---|
841 | " vrdeport <port> |\n"
|
---|
842 | " vrdeproperty <name=[value]> |\n"
|
---|
843 | " vrdevideochannelquality <percent> |\n"
|
---|
844 | " setvideomodehint <xres> <yres> <bpp>\n"
|
---|
845 | " [[<display>] [<enabled:yes|no> |\n"
|
---|
846 | " [<xorigin> <yorigin>]]] |\n"
|
---|
847 | " setscreenlayout <display> on|primary <xorigin> <yorigin> <xres> <yres> <bpp> | off\n"
|
---|
848 | " screenshotpng <file> [display] |\n"
|
---|
849 | #ifdef VBOX_WITH_RECORDING
|
---|
850 | " recording on|off |\n"
|
---|
851 | " recording screens all|none|<screen>,[<screen>...] |\n"
|
---|
852 | " recording filename <file> |\n"
|
---|
853 | " recording videores <width>x<height> |\n"
|
---|
854 | " recording videorate <rate> |\n"
|
---|
855 | " recording videofps <fps> |\n"
|
---|
856 | " recording maxtime <s> |\n"
|
---|
857 | " recording maxfilesize <MB> |\n"
|
---|
858 | #endif /* VBOX_WITH_RECORDING */
|
---|
859 | " setcredentials <username>\n"
|
---|
860 | " --passwordfile <file> | <password>\n"
|
---|
861 | " <domain>\n"
|
---|
862 | " [--allowlocallogon <yes|no>] |\n"
|
---|
863 | " teleport --host <name> --port <port>\n"
|
---|
864 | " [--maxdowntime <msec>]\n"
|
---|
865 | " [--passwordfile <file> |\n"
|
---|
866 | " --password <password>] |\n"
|
---|
867 | " plugcpu <id> |\n"
|
---|
868 | " unplugcpu <id> |\n"
|
---|
869 | " cpuexecutioncap <1-100>\n"
|
---|
870 | " webcam <attach [path [settings]]> | <detach [path]> | <list>\n"
|
---|
871 | " addencpassword <id>\n"
|
---|
872 | " <password file>|-\n"
|
---|
873 | " [--removeonsuspend <yes|no>]\n"
|
---|
874 | " removeencpassword <id>\n"
|
---|
875 | " removeallencpasswords\n"
|
---|
876 | " changeuartmode<1-N> disconnected|\n"
|
---|
877 | " server <pipe>|\n"
|
---|
878 | " client <pipe>|\n"
|
---|
879 | " tcpserver <port>|\n"
|
---|
880 | " tcpclient <hostname:port>|\n"
|
---|
881 | " file <file>|\n"
|
---|
882 | " <devicename>]\n"
|
---|
883 | "\n", SEP);
|
---|
884 | }
|
---|
885 |
|
---|
886 | if (fCategory & USAGE_DISCARDSTATE)
|
---|
887 | RTStrmPrintf(pStrm,
|
---|
888 | "%s discardstate %s <uuid|vmname>\n"
|
---|
889 | "\n", SEP);
|
---|
890 |
|
---|
891 | if (fCategory & USAGE_ADOPTSTATE)
|
---|
892 | RTStrmPrintf(pStrm,
|
---|
893 | "%s adoptstate %s <uuid|vmname> <state_file>\n"
|
---|
894 | "\n", SEP);
|
---|
895 |
|
---|
896 | if (fCategory & USAGE_SNAPSHOT)
|
---|
897 | RTStrmPrintf(pStrm,
|
---|
898 | "%s snapshot %s <uuid|vmname>\n"
|
---|
899 | " take <name> [--description <desc>] [--live]\n"
|
---|
900 | " [--uniquename Number,Timestamp,Space,Force] |\n"
|
---|
901 | " delete <uuid|snapname> |\n"
|
---|
902 | " restore <uuid|snapname> |\n"
|
---|
903 | " restorecurrent |\n"
|
---|
904 | " edit <uuid|snapname>|--current\n"
|
---|
905 | " [--name <name>]\n"
|
---|
906 | " [--description <desc>] |\n"
|
---|
907 | " list [--details|--machinereadable] |\n"
|
---|
908 | " showvminfo <uuid|snapname>\n"
|
---|
909 | "\n", SEP);
|
---|
910 |
|
---|
911 | if (fCategory & USAGE_CLOSEMEDIUM)
|
---|
912 | RTStrmPrintf(pStrm,
|
---|
913 | "%s closemedium %s [disk|dvd|floppy] <uuid|filename>\n"
|
---|
914 | " [--delete]\n"
|
---|
915 | "\n", SEP);
|
---|
916 |
|
---|
917 | if (fCategory & USAGE_STORAGEATTACH)
|
---|
918 | RTStrmPrintf(pStrm,
|
---|
919 | "%s storageattach %s <uuid|vmname>\n"
|
---|
920 | " --storagectl <name>\n"
|
---|
921 | " [--port <number>]\n"
|
---|
922 | " [--device <number>]\n"
|
---|
923 | " [--type dvddrive|hdd|fdd]\n"
|
---|
924 | " [--medium none|emptydrive|additions|\n"
|
---|
925 | " <uuid|filename>|host:<drive>|iscsi]\n"
|
---|
926 | " [--mtype normal|writethrough|immutable|shareable|\n"
|
---|
927 | " readonly|multiattach]\n"
|
---|
928 | " [--comment <text>]\n"
|
---|
929 | " [--setuuid <uuid>]\n"
|
---|
930 | " [--setparentuuid <uuid>]\n"
|
---|
931 | " [--passthrough on|off]\n"
|
---|
932 | " [--tempeject on|off]\n"
|
---|
933 | " [--nonrotational on|off]\n"
|
---|
934 | " [--discard on|off]\n"
|
---|
935 | " [--hotpluggable on|off]\n"
|
---|
936 | " [--bandwidthgroup <name>]\n"
|
---|
937 | " [--forceunmount]\n"
|
---|
938 | " [--server <name>|<ip>]\n"
|
---|
939 | " [--target <target>]\n"
|
---|
940 | " [--tport <port>]\n"
|
---|
941 | " [--lun <lun>]\n"
|
---|
942 | " [--encodedlun <lun>]\n"
|
---|
943 | " [--username <username>]\n"
|
---|
944 | " [--password <password>]\n"
|
---|
945 | " [--passwordfile <file>]\n"
|
---|
946 | " [--initiator <initiator>]\n"
|
---|
947 | " [--intnet]\n"
|
---|
948 | "\n", SEP);
|
---|
949 |
|
---|
950 | if (fCategory & USAGE_STORAGECONTROLLER)
|
---|
951 | RTStrmPrintf(pStrm,
|
---|
952 | "%s storagectl %s <uuid|vmname>\n"
|
---|
953 | " --name <name>\n"
|
---|
954 | " [--add ide|sata|scsi|floppy|sas|usb|pcie]\n"
|
---|
955 | " [--controller LSILogic|LSILogicSAS|BusLogic|\n"
|
---|
956 | " IntelAHCI|PIIX3|PIIX4|ICH6|I82078|\n"
|
---|
957 | " [ USB|NVMe]\n"
|
---|
958 | " [--portcount <1-n>]\n"
|
---|
959 | " [--hostiocache on|off]\n"
|
---|
960 | " [--bootable on|off]\n"
|
---|
961 | " [--rename <name>]\n"
|
---|
962 | " [--remove]\n"
|
---|
963 | "\n", SEP);
|
---|
964 |
|
---|
965 | if (fCategory & USAGE_BANDWIDTHCONTROL)
|
---|
966 | RTStrmPrintf(pStrm,
|
---|
967 | "%s bandwidthctl %s <uuid|vmname>\n"
|
---|
968 | " add <name> --type disk|network\n"
|
---|
969 | " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
|
---|
970 | " set <name>\n"
|
---|
971 | " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
|
---|
972 | " remove <name> |\n"
|
---|
973 | " list [--machinereadable]\n"
|
---|
974 | " (limit units: k=kilobit, m=megabit, g=gigabit,\n"
|
---|
975 | " K=kilobyte, M=megabyte, G=gigabyte)\n"
|
---|
976 | "\n", SEP);
|
---|
977 |
|
---|
978 | if (fCategory & USAGE_SHOWMEDIUMINFO)
|
---|
979 | RTStrmPrintf(pStrm,
|
---|
980 | "%s showmediuminfo %s [disk|dvd|floppy] <uuid|filename>\n"
|
---|
981 | "\n", SEP);
|
---|
982 |
|
---|
983 | if (fCategory & USAGE_CREATEMEDIUM)
|
---|
984 | RTStrmPrintf(pStrm,
|
---|
985 | "%s createmedium %s [disk|dvd|floppy] --filename <filename>\n"
|
---|
986 | " [--size <megabytes>|--sizebyte <bytes>]\n"
|
---|
987 | " [--diffparent <uuid>|<filename>\n"
|
---|
988 | " [--format VDI|VMDK|VHD] (default: VDI)\n"
|
---|
989 | " [--variant Standard,Fixed,Split2G,Stream,ESX,\n"
|
---|
990 | " Formatted]\n"
|
---|
991 | "\n", SEP);
|
---|
992 |
|
---|
993 | if (fCategory & USAGE_MODIFYMEDIUM)
|
---|
994 | RTStrmPrintf(pStrm,
|
---|
995 | "%s modifymedium %s [disk|dvd|floppy] <uuid|filename>\n"
|
---|
996 | " [--type normal|writethrough|immutable|shareable|\n"
|
---|
997 | " readonly|multiattach]\n"
|
---|
998 | " [--autoreset on|off]\n"
|
---|
999 | " [--property <name=[value]>]\n"
|
---|
1000 | " [--compact]\n"
|
---|
1001 | " [--resize <megabytes>|--resizebyte <bytes>]\n"
|
---|
1002 | " [--move <path>]\n"
|
---|
1003 | " [--setlocation <path>]\n"
|
---|
1004 | " [--description <description string>]"
|
---|
1005 | "\n", SEP);
|
---|
1006 |
|
---|
1007 | if (fCategory & USAGE_CLONEMEDIUM)
|
---|
1008 | RTStrmPrintf(pStrm,
|
---|
1009 | "%s clonemedium %s [disk|dvd|floppy] <uuid|inputfile> <uuid|outputfile>\n"
|
---|
1010 | " [--format VDI|VMDK|VHD|RAW|<other>]\n"
|
---|
1011 | " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
|
---|
1012 | " [--existing]\n"
|
---|
1013 | "\n", SEP);
|
---|
1014 |
|
---|
1015 | if (fCategory & USAGE_MEDIUMPROPERTY)
|
---|
1016 | RTStrmPrintf(pStrm,
|
---|
1017 | "%s mediumproperty %s [disk|dvd|floppy] set <uuid|filename>\n"
|
---|
1018 | " <property> <value>\n"
|
---|
1019 | "\n"
|
---|
1020 | " [disk|dvd|floppy] get <uuid|filename>\n"
|
---|
1021 | " <property>\n"
|
---|
1022 | "\n"
|
---|
1023 | " [disk|dvd|floppy] delete <uuid|filename>\n"
|
---|
1024 | " <property>\n"
|
---|
1025 | "\n", SEP);
|
---|
1026 |
|
---|
1027 | if (fCategory & USAGE_ENCRYPTMEDIUM)
|
---|
1028 | RTStrmPrintf(pStrm,
|
---|
1029 | "%s encryptmedium %s <uuid|filename>\n"
|
---|
1030 | " [--newpassword <file>|-]\n"
|
---|
1031 | " [--oldpassword <file>|-]\n"
|
---|
1032 | " [--cipher <cipher identifier>]\n"
|
---|
1033 | " [--newpasswordid <password identifier>]\n"
|
---|
1034 | "\n", SEP);
|
---|
1035 |
|
---|
1036 | if (fCategory & USAGE_MEDIUMENCCHKPWD)
|
---|
1037 | RTStrmPrintf(pStrm,
|
---|
1038 | "%s checkmediumpwd %s <uuid|filename>\n"
|
---|
1039 | " <pwd file>|-\n"
|
---|
1040 | "\n", SEP);
|
---|
1041 |
|
---|
1042 | if (fCategory & USAGE_CONVERTFROMRAW)
|
---|
1043 | RTStrmPrintf(pStrm,
|
---|
1044 | "%s convertfromraw %s <filename> <outputfile>\n"
|
---|
1045 | " [--format VDI|VMDK|VHD]\n"
|
---|
1046 | " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
|
---|
1047 | " [--uuid <uuid>]\n"
|
---|
1048 | "%s convertfromraw %s stdin <outputfile> <bytes>\n"
|
---|
1049 | " [--format VDI|VMDK|VHD]\n"
|
---|
1050 | " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
|
---|
1051 | " [--uuid <uuid>]\n"
|
---|
1052 | "\n", SEP, SEP);
|
---|
1053 |
|
---|
1054 | if (fCategory & USAGE_GETEXTRADATA)
|
---|
1055 | RTStrmPrintf(pStrm,
|
---|
1056 | "%s getextradata %s global|<uuid|vmname>\n"
|
---|
1057 | " <key>|[enumerate]\n"
|
---|
1058 | "\n", SEP);
|
---|
1059 |
|
---|
1060 | if (fCategory & USAGE_SETEXTRADATA)
|
---|
1061 | RTStrmPrintf(pStrm,
|
---|
1062 | "%s setextradata %s global|<uuid|vmname>\n"
|
---|
1063 | " <key>\n"
|
---|
1064 | " [<value>] (no value deletes key)\n"
|
---|
1065 | "\n", SEP);
|
---|
1066 |
|
---|
1067 | if (fCategory & USAGE_SETPROPERTY)
|
---|
1068 | RTStrmPrintf(pStrm,
|
---|
1069 | "%s setproperty %s machinefolder default|<folder> |\n"
|
---|
1070 | " hwvirtexclusive on|off |\n"
|
---|
1071 | " vrdeauthlibrary default|<library> |\n"
|
---|
1072 | " websrvauthlibrary default|null|<library> |\n"
|
---|
1073 | " vrdeextpack null|<library> |\n"
|
---|
1074 | " autostartdbpath null|<folder> |\n"
|
---|
1075 | " loghistorycount <value>\n"
|
---|
1076 | " defaultfrontend default|<name>\n"
|
---|
1077 | " logginglevel <log setting>\n"
|
---|
1078 | " proxymode system|noproxy|manual\n"
|
---|
1079 | " proxyurl <url>\n"
|
---|
1080 | "\n", SEP);
|
---|
1081 |
|
---|
1082 | if (fCategory & USAGE_USBFILTER_ADD)
|
---|
1083 | RTStrmPrintf(pStrm,
|
---|
1084 | "%s usbfilter %s add <index,0-N>\n"
|
---|
1085 | " --target <uuid|vmname>|global\n"
|
---|
1086 | " --name <string>\n"
|
---|
1087 | " --action ignore|hold (global filters only)\n"
|
---|
1088 | " [--active yes|no] (yes)\n"
|
---|
1089 | " [--vendorid <XXXX>] (null)\n"
|
---|
1090 | " [--productid <XXXX>] (null)\n"
|
---|
1091 | " [--revision <IIFF>] (null)\n"
|
---|
1092 | " [--manufacturer <string>] (null)\n"
|
---|
1093 | " [--product <string>] (null)\n"
|
---|
1094 | " [--remote yes|no] (null, VM filters only)\n"
|
---|
1095 | " [--serialnumber <string>] (null)\n"
|
---|
1096 | " [--maskedinterfaces <XXXXXXXX>]\n"
|
---|
1097 | "\n", SEP);
|
---|
1098 |
|
---|
1099 | if (fCategory & USAGE_USBFILTER_MODIFY)
|
---|
1100 | RTStrmPrintf(pStrm,
|
---|
1101 | "%s usbfilter %s modify <index,0-N>\n"
|
---|
1102 | " --target <uuid|vmname>|global\n"
|
---|
1103 | " [--name <string>]\n"
|
---|
1104 | " [--action ignore|hold] (global filters only)\n"
|
---|
1105 | " [--active yes|no]\n"
|
---|
1106 | " [--vendorid <XXXX>|\"\"]\n"
|
---|
1107 | " [--productid <XXXX>|\"\"]\n"
|
---|
1108 | " [--revision <IIFF>|\"\"]\n"
|
---|
1109 | " [--manufacturer <string>|\"\"]\n"
|
---|
1110 | " [--product <string>|\"\"]\n"
|
---|
1111 | " [--remote yes|no] (null, VM filters only)\n"
|
---|
1112 | " [--serialnumber <string>|\"\"]\n"
|
---|
1113 | " [--maskedinterfaces <XXXXXXXX>]\n"
|
---|
1114 | "\n", SEP);
|
---|
1115 |
|
---|
1116 | if (fCategory & USAGE_USBFILTER_REMOVE)
|
---|
1117 | RTStrmPrintf(pStrm,
|
---|
1118 | "%s usbfilter %s remove <index,0-N>\n"
|
---|
1119 | " --target <uuid|vmname>|global\n"
|
---|
1120 | "\n", SEP);
|
---|
1121 |
|
---|
1122 | if (fCategory & USAGE_SHAREDFOLDER_ADD)
|
---|
1123 | RTStrmPrintf(pStrm,
|
---|
1124 | "%s sharedfolder %s add <uuid|vmname>\n"
|
---|
1125 | " --name <name> --hostpath <hostpath>\n"
|
---|
1126 | " [--transient] [--readonly] [--automount]\n"
|
---|
1127 | "\n", SEP);
|
---|
1128 |
|
---|
1129 | if (fCategory & USAGE_SHAREDFOLDER_REMOVE)
|
---|
1130 | RTStrmPrintf(pStrm,
|
---|
1131 | "%s sharedfolder %s remove <uuid|vmname>\n"
|
---|
1132 | " --name <name> [--transient]\n"
|
---|
1133 | "\n", SEP);
|
---|
1134 |
|
---|
1135 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
1136 | if (fCategory & USAGE_GUESTPROPERTY)
|
---|
1137 | usageGuestProperty(pStrm, SEP);
|
---|
1138 | #endif /* VBOX_WITH_GUEST_PROPS defined */
|
---|
1139 |
|
---|
1140 | #ifdef VBOX_WITH_GUEST_CONTROL
|
---|
1141 | if (fCategory & USAGE_GUESTCONTROL)
|
---|
1142 | usageGuestControl(pStrm, SEP, fSubCategory);
|
---|
1143 | #endif /* VBOX_WITH_GUEST_CONTROL defined */
|
---|
1144 |
|
---|
1145 | if (fCategory & USAGE_METRICS)
|
---|
1146 | RTStrmPrintf(pStrm,
|
---|
1147 | "%s metrics %s list [*|host|<vmname> [<metric_list>]]\n"
|
---|
1148 | " (comma-separated)\n\n"
|
---|
1149 | "%s metrics %s setup\n"
|
---|
1150 | " [--period <seconds>] (default: 1)\n"
|
---|
1151 | " [--samples <count>] (default: 1)\n"
|
---|
1152 | " [--list]\n"
|
---|
1153 | " [*|host|<vmname> [<metric_list>]]\n\n"
|
---|
1154 | "%s metrics %s query [*|host|<vmname> [<metric_list>]]\n\n"
|
---|
1155 | "%s metrics %s enable\n"
|
---|
1156 | " [--list]\n"
|
---|
1157 | " [*|host|<vmname> [<metric_list>]]\n\n"
|
---|
1158 | "%s metrics %s disable\n"
|
---|
1159 | " [--list]\n"
|
---|
1160 | " [*|host|<vmname> [<metric_list>]]\n\n"
|
---|
1161 | "%s metrics %s collect\n"
|
---|
1162 | " [--period <seconds>] (default: 1)\n"
|
---|
1163 | " [--samples <count>] (default: 1)\n"
|
---|
1164 | " [--list]\n"
|
---|
1165 | " [--detach]\n"
|
---|
1166 | " [*|host|<vmname> [<metric_list>]]\n"
|
---|
1167 | "\n", SEP, SEP, SEP, SEP, SEP, SEP);
|
---|
1168 |
|
---|
1169 | #if defined(VBOX_WITH_NAT_SERVICE)
|
---|
1170 | if (fCategory & USAGE_NATNETWORK)
|
---|
1171 | {
|
---|
1172 | RTStrmPrintf(pStrm,
|
---|
1173 | "%s natnetwork %s add --netname <name>\n"
|
---|
1174 | " --network <network>\n"
|
---|
1175 | " [--enable|--disable]\n"
|
---|
1176 | " [--dhcp on|off]\n"
|
---|
1177 | " [--port-forward-4 <rule>]\n"
|
---|
1178 | " [--loopback-4 <rule>]\n"
|
---|
1179 | " [--ipv6 on|off]\n"
|
---|
1180 | " [--port-forward-6 <rule>]\n"
|
---|
1181 | " [--loopback-6 <rule>]\n\n"
|
---|
1182 | "%s natnetwork %s remove --netname <name>\n\n"
|
---|
1183 | "%s natnetwork %s modify --netname <name>\n"
|
---|
1184 | " [--network <network>]\n"
|
---|
1185 | " [--enable|--disable]\n"
|
---|
1186 | " [--dhcp on|off]\n"
|
---|
1187 | " [--port-forward-4 <rule>]\n"
|
---|
1188 | " [--loopback-4 <rule>]\n"
|
---|
1189 | " [--ipv6 on|off]\n"
|
---|
1190 | " [--port-forward-6 <rule>]\n"
|
---|
1191 | " [--loopback-6 <rule>]\n\n"
|
---|
1192 | "%s natnetwork %s start --netname <name>\n\n"
|
---|
1193 | "%s natnetwork %s stop --netname <name>\n\n"
|
---|
1194 | "%s natnetwork %s list [<pattern>]\n"
|
---|
1195 | "\n", SEP, SEP, SEP, SEP, SEP, SEP);
|
---|
1196 |
|
---|
1197 |
|
---|
1198 | }
|
---|
1199 | #endif
|
---|
1200 |
|
---|
1201 | #if defined(VBOX_WITH_NETFLT)
|
---|
1202 | if (fCategory & USAGE_HOSTONLYIFS)
|
---|
1203 | {
|
---|
1204 | RTStrmPrintf(pStrm,
|
---|
1205 | "%s hostonlyif %s ipconfig <name>\n"
|
---|
1206 | " [--dhcp |\n"
|
---|
1207 | " --ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |\n"
|
---|
1208 | " --ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]\n"
|
---|
1209 | # if !defined(RT_OS_SOLARIS) || defined(VBOX_ONLY_DOCS)
|
---|
1210 | " create |\n"
|
---|
1211 | " remove <name>\n"
|
---|
1212 | # endif
|
---|
1213 | "\n", SEP);
|
---|
1214 | }
|
---|
1215 | #endif
|
---|
1216 |
|
---|
1217 | if (fCategory & USAGE_DHCPSERVER)
|
---|
1218 | {
|
---|
1219 | RTStrmPrintf(pStrm,
|
---|
1220 | "%s dhcpserver %s add|modify --netname <network_name> |\n"
|
---|
1221 | #if defined(VBOX_WITH_NETFLT)
|
---|
1222 | " --ifname <hostonly_if_name>\n"
|
---|
1223 | #endif
|
---|
1224 | " [--ip <ip_address>\n"
|
---|
1225 | " --netmask <network_mask>\n"
|
---|
1226 | " --lowerip <lower_ip>\n"
|
---|
1227 | " --upperip <upper_ip>]\n"
|
---|
1228 | " [--enable | --disable]\n"
|
---|
1229 | " [--options [--vm <name> --nic <1-N>]\n"
|
---|
1230 | " --id <number> [--value <string> | --remove]]\n"
|
---|
1231 | " (multiple options allowed after --options)\n\n"
|
---|
1232 | "%s dhcpserver %s remove --netname <network_name> |\n"
|
---|
1233 | #if defined(VBOX_WITH_NETFLT)
|
---|
1234 | " --ifname <hostonly_if_name>\n"
|
---|
1235 | #endif
|
---|
1236 | "\n", SEP, SEP);
|
---|
1237 | }
|
---|
1238 |
|
---|
1239 | if (fCategory & USAGE_USBDEVSOURCE)
|
---|
1240 | {
|
---|
1241 | RTStrmPrintf(pStrm,
|
---|
1242 | "%s usbdevsource %s add <source name>\n"
|
---|
1243 | " --backend <backend>\n"
|
---|
1244 | " --address <address>\n"
|
---|
1245 | "%s usbdevsource %s remove <source name>\n"
|
---|
1246 | "\n", SEP, SEP);
|
---|
1247 | }
|
---|
1248 |
|
---|
1249 | #ifndef VBOX_ONLY_DOCS /* Converted to man page, not needed. */
|
---|
1250 | if (fCategory == USAGE_ALL)
|
---|
1251 | {
|
---|
1252 | uint32_t cPendingBlankLines = 0;
|
---|
1253 | for (uint32_t i = 0; i < g_cHelpEntries; i++)
|
---|
1254 | {
|
---|
1255 | PCRTMSGREFENTRY pHelp = g_apHelpEntries[i];
|
---|
1256 | while (cPendingBlankLines-- > 0)
|
---|
1257 | RTStrmPutCh(pStrm, '\n');
|
---|
1258 | RTStrmPrintf(pStrm, " %c%s:\n", RT_C_TO_UPPER(pHelp->pszBrief[0]), pHelp->pszBrief + 1);
|
---|
1259 | cPendingBlankLines = 0;
|
---|
1260 | RTMsgRefEntryPrintStringTable(pStrm, &pHelp->Synopsis, RTMSGREFENTRYSTR_SCOPE_GLOBAL,
|
---|
1261 | &cPendingBlankLines, NULL /*pcLinesWritten*/);
|
---|
1262 | cPendingBlankLines = RT_MAX(cPendingBlankLines, 1);
|
---|
1263 | }
|
---|
1264 | }
|
---|
1265 | #endif
|
---|
1266 | }
|
---|
1267 |
|
---|
1268 | /**
|
---|
1269 | * Print a usage synopsis and the syntax error message.
|
---|
1270 | * @returns RTEXITCODE_SYNTAX.
|
---|
1271 | */
|
---|
1272 | RTEXITCODE errorSyntax(USAGECATEGORY fCategory, const char *pszFormat, ...)
|
---|
1273 | {
|
---|
1274 | va_list args;
|
---|
1275 | showLogo(g_pStdErr); // show logo even if suppressed
|
---|
1276 | #ifndef VBOX_ONLY_DOCS
|
---|
1277 | if (g_fInternalMode)
|
---|
1278 | printUsageInternal(fCategory, g_pStdErr);
|
---|
1279 | else
|
---|
1280 | printUsage(fCategory, ~0U, g_pStdErr);
|
---|
1281 | #else
|
---|
1282 | RT_NOREF_PV(fCategory);
|
---|
1283 | #endif
|
---|
1284 | va_start(args, pszFormat);
|
---|
1285 | RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
|
---|
1286 | va_end(args);
|
---|
1287 | return RTEXITCODE_SYNTAX;
|
---|
1288 | }
|
---|
1289 |
|
---|
1290 | /**
|
---|
1291 | * Print a usage synopsis and the syntax error message.
|
---|
1292 | * @returns RTEXITCODE_SYNTAX.
|
---|
1293 | */
|
---|
1294 | RTEXITCODE errorSyntaxEx(USAGECATEGORY fCategory, uint32_t fSubCategory, const char *pszFormat, ...)
|
---|
1295 | {
|
---|
1296 | va_list args;
|
---|
1297 | showLogo(g_pStdErr); // show logo even if suppressed
|
---|
1298 | #ifndef VBOX_ONLY_DOCS
|
---|
1299 | if (g_fInternalMode)
|
---|
1300 | printUsageInternal(fCategory, g_pStdErr);
|
---|
1301 | else
|
---|
1302 | printUsage(fCategory, fSubCategory, g_pStdErr);
|
---|
1303 | #else
|
---|
1304 | RT_NOREF2(fCategory, fSubCategory);
|
---|
1305 | #endif
|
---|
1306 | va_start(args, pszFormat);
|
---|
1307 | RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
|
---|
1308 | va_end(args);
|
---|
1309 | return RTEXITCODE_SYNTAX;
|
---|
1310 | }
|
---|
1311 |
|
---|
1312 | /**
|
---|
1313 | * errorSyntax for RTGetOpt users.
|
---|
1314 | *
|
---|
1315 | * @returns RTEXITCODE_SYNTAX.
|
---|
1316 | *
|
---|
1317 | * @param fCategory The usage category of the command.
|
---|
1318 | * @param fSubCategory The usage sub-category of the command.
|
---|
1319 | * @param rc The RTGetOpt return code.
|
---|
1320 | * @param pValueUnion The value union.
|
---|
1321 | */
|
---|
1322 | RTEXITCODE errorGetOptEx(USAGECATEGORY fCategory, uint32_t fSubCategory, int rc, union RTGETOPTUNION const *pValueUnion)
|
---|
1323 | {
|
---|
1324 | /*
|
---|
1325 | * Check if it is an unhandled standard option.
|
---|
1326 | */
|
---|
1327 | #ifndef VBOX_ONLY_DOCS
|
---|
1328 | if (rc == 'V')
|
---|
1329 | {
|
---|
1330 | RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision());
|
---|
1331 | return RTEXITCODE_SUCCESS;
|
---|
1332 | }
|
---|
1333 | #endif
|
---|
1334 |
|
---|
1335 | if (rc == 'h')
|
---|
1336 | {
|
---|
1337 | showLogo(g_pStdErr);
|
---|
1338 | #ifndef VBOX_ONLY_DOCS
|
---|
1339 | if (g_fInternalMode)
|
---|
1340 | printUsageInternal(fCategory, g_pStdOut);
|
---|
1341 | else
|
---|
1342 | printUsage(fCategory, fSubCategory, g_pStdOut);
|
---|
1343 | #endif
|
---|
1344 | return RTEXITCODE_SUCCESS;
|
---|
1345 | }
|
---|
1346 |
|
---|
1347 | /*
|
---|
1348 | * General failure.
|
---|
1349 | */
|
---|
1350 | showLogo(g_pStdErr); // show logo even if suppressed
|
---|
1351 | #ifndef VBOX_ONLY_DOCS
|
---|
1352 | if (g_fInternalMode)
|
---|
1353 | printUsageInternal(fCategory, g_pStdErr);
|
---|
1354 | else
|
---|
1355 | printUsage(fCategory, fSubCategory, g_pStdErr);
|
---|
1356 | #else
|
---|
1357 | RT_NOREF2(fCategory, fSubCategory);
|
---|
1358 | #endif
|
---|
1359 |
|
---|
1360 | if (rc == VINF_GETOPT_NOT_OPTION)
|
---|
1361 | return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid parameter '%s'", pValueUnion->psz);
|
---|
1362 | if (rc > 0)
|
---|
1363 | {
|
---|
1364 | if (RT_C_IS_PRINT(rc))
|
---|
1365 | return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option -%c", rc);
|
---|
1366 | return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option case %i", rc);
|
---|
1367 | }
|
---|
1368 | if (rc == VERR_GETOPT_UNKNOWN_OPTION)
|
---|
1369 | return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown option: %s", pValueUnion->psz);
|
---|
1370 | if (rc == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)
|
---|
1371 | return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid argument format: %s", pValueUnion->psz);
|
---|
1372 | if (pValueUnion->pDef)
|
---|
1373 | return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, rc);
|
---|
1374 | return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%Rrs", rc);
|
---|
1375 | }
|
---|
1376 |
|
---|
1377 | /**
|
---|
1378 | * errorSyntax for RTGetOpt users.
|
---|
1379 | *
|
---|
1380 | * @returns RTEXITCODE_SYNTAX.
|
---|
1381 | *
|
---|
1382 | * @param fUsageCategory The usage category of the command.
|
---|
1383 | * @param rc The RTGetOpt return code.
|
---|
1384 | * @param pValueUnion The value union.
|
---|
1385 | */
|
---|
1386 | RTEXITCODE errorGetOpt(USAGECATEGORY fCategory, int rc, union RTGETOPTUNION const *pValueUnion)
|
---|
1387 | {
|
---|
1388 | return errorGetOptEx(fCategory, ~0U, rc, pValueUnion);
|
---|
1389 | }
|
---|
1390 |
|
---|
1391 | /**
|
---|
1392 | * Print an error message without the syntax stuff.
|
---|
1393 | *
|
---|
1394 | * @returns RTEXITCODE_SYNTAX.
|
---|
1395 | */
|
---|
1396 | RTEXITCODE errorArgument(const char *pszFormat, ...)
|
---|
1397 | {
|
---|
1398 | va_list args;
|
---|
1399 | va_start(args, pszFormat);
|
---|
1400 | RTMsgErrorV(pszFormat, args);
|
---|
1401 | va_end(args);
|
---|
1402 | return RTEXITCODE_SYNTAX;
|
---|
1403 | }
|
---|
1404 |
|
---|