VirtualBox

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

Last change on this file since 26517 was 26356, checked in by vboxsync, 15 years ago

Document controlvm balloon and stats options

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.6 KB
Line 
1/* $Id: VBoxManageHelp.cpp 26356 2010-02-09 12:15:35Z vboxsync $ */
2/** @file
3 * VBoxManage - help and other message output.
4 */
5
6/*
7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#include <VBox/version.h>
27
28#include <iprt/ctype.h>
29#include <iprt/err.h>
30#include <iprt/getopt.h>
31#include <iprt/stream.h>
32
33#include "VBoxManage.h"
34
35
36
37void showLogo(void)
38{
39 static bool s_fShown; /* show only once */
40
41 if (!s_fShown)
42 {
43 RTPrintf(VBOX_PRODUCT" Command Line Management Interface Version "
44 VBOX_VERSION_STRING "\n"
45 "(C) 2005-" VBOX_C_YEAR " " VBOX_VENDOR "\n"
46 "All rights reserved.\n"
47 "\n");
48 s_fShown = true;
49 }
50}
51
52void printUsage(USAGECATEGORY u64Cmd)
53{
54#ifdef RT_OS_LINUX
55 bool fLinux = true;
56#else
57 bool fLinux = false;
58#endif
59#ifdef RT_OS_WINDOWS
60 bool fWin = true;
61#else
62 bool fWin = false;
63#endif
64#ifdef RT_OS_SOLARIS
65 bool fSolaris = true;
66#else
67 bool fSolaris = false;
68#endif
69#ifdef RT_OS_FREEBSD
70 bool fFreeBSD = true;
71#else
72 bool fFreeBSD = false;
73#endif
74#ifdef RT_OS_DARWIN
75 bool fDarwin = true;
76#else
77 bool fDarwin = false;
78#endif
79#ifdef VBOX_WITH_VRDP
80 bool fVRDP = true;
81#else
82 bool fVRDP = false;
83#endif
84#ifdef VBOX_WITH_VBOXSDL
85 bool fVBoxSDL = true;
86#else
87 bool fVBoxSDL = false;
88#endif
89
90 if (u64Cmd == USAGE_DUMPOPTS)
91 {
92 fLinux = true;
93 fWin = true;
94 fSolaris = true;
95 fFreeBSD = true;
96 fDarwin = true;
97 fVRDP = true;
98 fVBoxSDL = true;
99 u64Cmd = USAGE_ALL;
100 }
101
102 RTPrintf("Usage:\n"
103 "\n");
104
105 if (u64Cmd == USAGE_ALL)
106 {
107 RTPrintf("VBoxManage [-v|--version] print version number and exit\n"
108 "VBoxManage [-q|--nologo] ... suppress the logo\n"
109 "\n");
110 }
111
112 if (u64Cmd & USAGE_LIST)
113 {
114 RTPrintf("VBoxManage list [--long|-l] vms|runningvms|ostypes|hostdvds|hostfloppies|\n"
115#if defined(VBOX_WITH_NETFLT)
116 " bridgedifs|hostonlyifs|dhcpservers|hostinfo|\n"
117#else
118 " bridgedifs|dhcpservers|hostinfo|\n"
119#endif
120 " hostcpuids|hddbackends|hdds|dvds|floppies|\n"
121 " usbhost|usbfilters|systemproperties\n"
122 "\n");
123 }
124
125 if (u64Cmd & USAGE_SHOWVMINFO)
126 {
127 RTPrintf("VBoxManage showvminfo <uuid>|<name> [--details] [--statistics]\n"
128 " [--machinereadable]\n"
129 "\n");
130 }
131
132 if (u64Cmd & USAGE_REGISTERVM)
133 {
134 RTPrintf("VBoxManage registervm <filename>\n"
135 "\n");
136 }
137
138 if (u64Cmd & USAGE_UNREGISTERVM)
139 {
140 RTPrintf("VBoxManage unregistervm <uuid>|<name> [--delete]\n"
141 "\n");
142 }
143
144 if (u64Cmd & USAGE_CREATEVM)
145 {
146 RTPrintf("VBoxManage createvm --name <name>\n"
147 " [--ostype <ostype>]\n"
148 " [--register]\n"
149 " [--basefolder <path> | --settingsfile <path>]\n"
150 " [--uuid <uuid>]\n"
151 "\n");
152 }
153
154 if (u64Cmd & USAGE_MODIFYVM)
155 {
156 RTPrintf("VBoxManage modifyvm <uuid|name>\n"
157 " [--name <name>]\n"
158 " [--ostype <ostype>]\n"
159 " [--memory <memorysize in MB>]\n"
160 " [--vram <vramsize in MB>]\n"
161 " [--acpi on|off]\n"
162 " [--ioapic on|off]\n"
163 " [--pae on|off]\n"
164 " [--hwvirtex on|off]\n"
165 " [--nestedpaging on|off]\n"
166 " [--vtxvpid on|off]\n"
167 " [--cpuidset <leaf> <eax> <ebx> <ecx> <edx>]\n"
168 " [--cpuidremove <leaf>]\n"
169 " [--cpuidremoveall]\n"
170 " [--cpus <number>]\n"
171 " [--rtcuseutc]\n"
172 " [--monitorcount <number>]\n"
173 " [--accelerate3d <on|off>]\n"
174#ifdef VBOX_WITH_VIDEOHWACCEL
175 " [--accelerate2dvideo <on|off>]\n"
176#endif
177 " [--firmware bios|efi|efi32|efi64]\n"
178 " [--bioslogofadein on|off]\n"
179 " [--bioslogofadeout on|off]\n"
180 " [--bioslogodisplaytime <msec>]\n"
181 " [--bioslogoimagepath <imagepath>]\n"
182 " [--biosbootmenu disabled|menuonly|messageandmenu]\n"
183 " [--biossystemtimeoffset <msec>]\n"
184 " [--biospxedebug on|off]\n"
185 " [--boot<1-4> none|floppy|dvd|disk|net>]\n"
186#if defined(VBOX_WITH_NETFLT)
187 " [--nic<1-N> none|null|nat|bridged|intnet|hostonly]\n"
188#else /* !RT_OS_LINUX && !RT_OS_DARWIN */
189 " [--nic<1-N> none|null|nat|bridged|intnet]\n"
190#endif /* !RT_OS_LINUX && !RT_OS_DARWIN */
191 " [--nictype<1-N> Am79C970A|Am79C973"
192#ifdef VBOX_WITH_E1000
193 "|\n 82540EM|82543GC|82545EM"
194#endif
195#ifdef VBOX_WITH_VIRTIO
196 "|\n virtio"
197#endif /* VBOX_WITH_VIRTIO */
198 "]\n"
199 " [--cableconnected<1-N> on|off]\n"
200 " [--nictrace<1-N> on|off]\n"
201 " [--nictracefile<1-N> <filename>]\n"
202 " [--nicspeed<1-N> <kbps>]\n"
203 " [--bridgeadapter<1-N> none|<devicename>]\n"
204#if defined(VBOX_WITH_NETFLT)
205 " [--hostonlyadapter<1-N> none|<devicename>]\n"
206#endif
207 " [--intnet<1-N> <network name>]\n"
208 " [--natnet<1-N> <network>|default]\n"
209 " [--macaddress<1-N> auto|<mac>]\n"
210 " [--uart<1-N> off|<I/O base> <IRQ>]\n"
211 " [--uartmode<1-N> disconnected|\n"
212 " server <pipe>|\n"
213 " client <pipe>|\n"
214 " file <file>|\n"
215 " <devicename>]\n"
216 " [--guestmemoryballoon <balloonsize in MB>]\n"
217 " [--gueststatisticsinterval <seconds>]\n"
218 );
219 RTPrintf(" [--audio none|null");
220 if (fWin)
221 {
222#ifdef VBOX_WITH_WINMM
223 RTPrintf( "|winmm|dsound");
224#else
225 RTPrintf( "|dsound");
226#endif
227 }
228 if (fSolaris)
229 {
230 RTPrintf( "|solaudio"
231#ifdef VBOX_WITH_SOLARIS_OSS
232 "|oss"
233#endif
234 );
235 }
236 if (fLinux)
237 {
238 RTPrintf( "|oss"
239#ifdef VBOX_WITH_ALSA
240 "|alsa"
241#endif
242#ifdef VBOX_WITH_PULSE
243 "|pulse"
244#endif
245 );
246 }
247 if (fFreeBSD)
248 {
249 RTPrintf( "|oss"
250#ifdef VBOX_WITH_PULSE
251 "|pulse"
252#endif
253 );
254 }
255 if (fDarwin)
256 {
257 RTPrintf( "|coreaudio");
258 }
259 RTPrintf( "]\n");
260 RTPrintf(" [--audiocontroller ac97|sb16]\n"
261 " [--clipboard disabled|hosttoguest|guesttohost|\n"
262 " bidirectional]\n");
263 if (fVRDP)
264 {
265 RTPrintf(" [--vrdp on|off]\n"
266 " [--vrdpport default|<ports>]\n"
267 " [--vrdpaddress <host>]\n"
268 " [--vrdpauthtype null|external|guest]\n"
269 " [--vrdpmulticon on|off]\n"
270 " [--vrdpreusecon on|off]\n");
271 }
272 RTPrintf(" [--usb on|off]\n"
273 " [--usbehci on|off]\n"
274 " [--snapshotfolder default|<path>]\n"
275 " [--teleporter on|off]\n"
276 " [--teleporterport <port>]\n"
277 " [--teleporteraddress <address|empty>\n"
278 " [--teleporterpassword <password>]\n"
279 " [--hardwareuuid <uuid>]\n"
280 );
281 RTPrintf("\n");
282 }
283
284 if (u64Cmd & USAGE_IMPORTAPPLIANCE)
285 {
286 RTPrintf("VBoxManage import <ovf> [--dry-run|-n] [more options]\n"
287 " (run with -n to have options displayed\n"
288 " for a particular OVF)\n\n");
289 }
290
291 if (u64Cmd & USAGE_EXPORTAPPLIANCE)
292 {
293 RTPrintf("VBoxManage export <machines> --output|-o <ovf>\n"
294 " [--legacy09]\n"
295 " [--vsys <number of virtual system>]\n"
296 " [--product <product name>]\n"
297 " [--producturl <product url>]\n"
298 " [--vendor <vendor name>]\n"
299 " [--vendorurl <vendor url>]\n"
300 " [--version <version info>]\n"
301 " [--eula <license text>]\n"
302 " [--eulafile <filename>]\n"
303 "\n");
304 }
305
306 if (u64Cmd & USAGE_STARTVM)
307 {
308 RTPrintf("VBoxManage startvm <uuid>|<name>\n");
309 RTPrintf(" [--type gui");
310 if (fVBoxSDL)
311 RTPrintf( "|sdl");
312 if (fVRDP)
313 RTPrintf( "|vrdp");
314 RTPrintf( "|headless]\n");
315 RTPrintf("\n");
316 }
317
318 if (u64Cmd & USAGE_CONTROLVM)
319 {
320 RTPrintf("VBoxManage controlvm <uuid>|<name>\n"
321 " pause|resume|reset|poweroff|savestate|\n"
322 " acpipowerbutton|acpisleepbutton|\n"
323 " keyboardputscancode <hex> [<hex> ...]|\n"
324 " injectnmi|\n"
325 " setlinkstate<1-N> on|off |\n"
326#ifdef VBOX_DYNAMIC_NET_ATTACH
327#if defined(VBOX_WITH_NETFLT)
328 " nic<1-N> null|nat|bridged|intnet|hostonly\n"
329 " [<devicename>] |\n"
330#else /* !RT_OS_LINUX && !RT_OS_DARWIN */
331 " nic<1-N> null|nat|bridged|intnet\n"
332 " [<devicename>] |\n"
333#endif /* !RT_OS_LINUX && !RT_OS_DARWIN */
334 " nictrace<1-N> on|off\n"
335 " nictracefile<1-N> <filename>\n"
336#endif /* VBOX_DYNAMIC_NET_ATTACH */
337 " guestmemoryballoon <balloonsize in MB>]\n"
338 " gueststatisticsinterval <seconds>]\n"
339 " usbattach <uuid>|<address> |\n"
340 " usbdetach <uuid>|<address> |\n");
341 if (fVRDP)
342 {
343 RTPrintf(" vrdp on|off |\n");
344 RTPrintf(" vrdpport default|<ports> |\n");
345 }
346 RTPrintf(" setvideomodehint <xres> <yres> <bpp> [display] |\n"
347 " setcredentials <username> <password> <domain>\n"
348 " [--allowlocallogon <yes|no>] |\n"
349 " teleport --host <name> --port <port>\n"
350 " [--maxdowntime <msec>] [--password password]\n"
351 "\n");
352 }
353
354 if (u64Cmd & USAGE_DISCARDSTATE)
355 {
356 RTPrintf("VBoxManage discardstate <uuid>|<name>\n"
357 "\n");
358 }
359
360 if (u64Cmd & USAGE_ADOPTSTATE)
361 {
362 RTPrintf("VBoxManage adoptstate <uuid>|<name> <state_file>\n"
363 "\n");
364 }
365
366 if (u64Cmd & USAGE_SNAPSHOT)
367 {
368 RTPrintf("VBoxManage snapshot <uuid>|<name>\n"
369 " take <name> [--description <desc>] [--pause] |\n"
370 " delete <uuid>|<name> |\n"
371 " restore <uuid>|<name> |\n"
372 " restorecurrent |\n"
373 " edit <uuid>|<name>|--current\n"
374 " [--name <name>]\n"
375 " [--description <desc>] |\n"
376 " showvminfo <uuid>|<name>\n"
377 "\n");
378 }
379
380 if (u64Cmd & USAGE_OPENMEDIUM)
381 {
382 RTPrintf("VBoxManage openmedium disk|dvd|floppy <filename>\n"
383 " [--type normal|immutable|writethrough] (disk only)\n"
384 " [--uuid <uuid>]\n"
385 " [--parentuuid <uuid>] (disk only)\n"
386 "\n");
387 }
388
389 if (u64Cmd & USAGE_CLOSEMEDIUM)
390 {
391 RTPrintf("VBoxManage closemedium disk|dvd|floppy <uuid>|<filename>\n"
392 " [--delete]\n"
393 "\n");
394 }
395
396 if (u64Cmd & USAGE_STORAGEATTACH)
397 {
398 RTPrintf("VBoxManage storageattach <uuid|vmname>\n"
399 " --storagectl <name>\n"
400 " --port <number>\n"
401 " --device <number>\n"
402 " [--type <dvddrive|hdd|fdd>\n"
403 " --medium <none|emptydrive|uuid|filename|host:<drive>>]\n"
404 " [--passthrough <on|off>]\n"
405 " [--forceunmount]\n"
406 "\n");
407 }
408
409 if (u64Cmd & USAGE_STORAGECONTROLLER)
410 {
411 RTPrintf("VBoxManage storagectl <uuid|vmname>\n"
412 " --name <name>\n"
413 " [--add <ide/sata/scsi/floppy/sas>]\n"
414 " [--controller <LsiLogic/BusLogic/IntelAhci/PIIX3/PIIX4/ICH6/I82078/LsiLogicSas>]\n"
415 " [--sataideemulation<1-4> <1-30>]\n"
416 " [--sataportcount <1-30>]\n"
417 " [--remove]\n"
418 "\n");
419 }
420
421 if (u64Cmd & USAGE_SHOWHDINFO)
422 {
423 RTPrintf("VBoxManage showhdinfo <uuid>|<filename>\n"
424 "\n");
425 }
426
427 if (u64Cmd & USAGE_CREATEHD)
428 {
429 RTPrintf("VBoxManage createhd --filename <filename>\n"
430 " --size <megabytes>\n"
431 " [--format VDI|VMDK|VHD] (default: VDI)\n"
432 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
433 " [--type normal|writethrough] (default: normal)\n"
434 " [--comment <comment>]\n"
435 " [--remember]\n"
436 "\n");
437 }
438
439 if (u64Cmd & USAGE_MODIFYHD)
440 {
441 RTPrintf("VBoxManage modifyhd <uuid>|<filename>\n"
442 " [--type normal|writethrough|immutable]\n"
443 " [--autoreset on|off]\n"
444 " [--compact]\n"
445 "\n");
446 }
447
448 if (u64Cmd & USAGE_CLONEHD)
449 {
450 RTPrintf("VBoxManage clonehd <uuid>|<filename> <outputfile>\n"
451 " [--format VDI|VMDK|VHD|RAW|<other>]\n"
452 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
453 " [--type normal|writethrough|immutable]\n"
454 " [--remember] [--existing]\n"
455 "\n");
456 }
457
458 if (u64Cmd & USAGE_CONVERTFROMRAW)
459 {
460 RTPrintf("VBoxManage convertfromraw <filename> <outputfile>\n"
461 " [--format VDI|VMDK|VHD]\n"
462 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
463 "VBoxManage convertfromraw stdin <outputfile> <bytes>\n"
464 " [--format VDI|VMDK|VHD]\n"
465 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
466 "\n");
467 }
468
469 if (u64Cmd & USAGE_ADDISCSIDISK)
470 {
471 RTPrintf("VBoxManage addiscsidisk --server <name>|<ip>\n"
472 " --target <target>\n"
473 " [--port <port>]\n"
474 " [--lun <lun>]\n"
475 " [--encodedlun <lun>]\n"
476 " [--username <username>]\n"
477 " [--password <password>]\n"
478 " [--type normal|writethrough|immutable]\n"
479 " [--intnet]\n"
480 "\n");
481 }
482
483 if (u64Cmd & USAGE_GETEXTRADATA)
484 {
485 RTPrintf("VBoxManage getextradata global|<uuid>|<name>\n"
486 " <key>|enumerate\n"
487 "\n");
488 }
489
490 if (u64Cmd & USAGE_SETEXTRADATA)
491 {
492 RTPrintf("VBoxManage setextradata global|<uuid>|<name>\n"
493 " <key>\n"
494 " [<value>] (no value deletes key)\n"
495 "\n");
496 }
497
498 if (u64Cmd & USAGE_SETPROPERTY)
499 {
500 RTPrintf("VBoxManage setproperty hdfolder default|<folder> |\n"
501 " machinefolder default|<folder> |\n"
502 " vrdpauthlibrary default|<library> |\n"
503 " websrvauthlibrary default|null|<library> |\n"
504 " loghistorycount <value>\n"
505 "\n");
506 }
507
508 if (u64Cmd & USAGE_USBFILTER_ADD)
509 {
510 RTPrintf("VBoxManage usbfilter add <index,0-N>\n"
511 " --target <uuid>|<name>|global\n"
512 " --name <string>\n"
513 " --action ignore|hold (global filters only)\n"
514 " [--active yes|no] (yes)\n"
515 " [--vendorid <XXXX>] (null)\n"
516 " [--productid <XXXX>] (null)\n"
517 " [--revision <IIFF>] (null)\n"
518 " [--manufacturer <string>] (null)\n"
519 " [--product <string>] (null)\n"
520 " [--remote yes|no] (null, VM filters only)\n"
521 " [--serialnumber <string>] (null)\n"
522 " [--maskedinterfaces <XXXXXXXX>]\n"
523 "\n");
524 }
525
526 if (u64Cmd & USAGE_USBFILTER_MODIFY)
527 {
528 RTPrintf("VBoxManage usbfilter modify <index,0-N>\n"
529 " --target <uuid>|<name>|global\n"
530 " [--name <string>]\n"
531 " [--action ignore|hold] (global filters only)\n"
532 " [--active yes|no]\n"
533 " [--vendorid <XXXX>|\"\"]\n"
534 " [--productid <XXXX>|\"\"]\n"
535 " [--revision <IIFF>|\"\"]\n"
536 " [--manufacturer <string>|\"\"]\n"
537 " [--product <string>|\"\"]\n"
538 " [--remote yes|no] (null, VM filters only)\n"
539 " [--serialnumber <string>|\"\"]\n"
540 " [--maskedinterfaces <XXXXXXXX>]\n"
541 "\n");
542 }
543
544 if (u64Cmd & USAGE_USBFILTER_REMOVE)
545 {
546 RTPrintf("VBoxManage usbfilter remove <index,0-N>\n"
547 " --target <uuid>|<name>|global\n"
548 "\n");
549 }
550
551 if (u64Cmd & USAGE_SHAREDFOLDER_ADD)
552 {
553 RTPrintf("VBoxManage sharedfolder add <vmname>|<uuid>\n"
554 " --name <name> --hostpath <hostpath>\n"
555 " [--transient] [--readonly]\n"
556 "\n");
557 }
558
559 if (u64Cmd & USAGE_SHAREDFOLDER_REMOVE)
560 {
561 RTPrintf("VBoxManage sharedfolder remove <vmname>|<uuid>\n"
562 " --name <name> [--transient]\n"
563 "\n");
564 }
565
566 if (u64Cmd & USAGE_VM_STATISTICS)
567 {
568 RTPrintf("VBoxManage vmstatistics <vmname>|<uuid> [--reset]\n"
569 " [--pattern <pattern>] [--descriptions]\n"
570 "\n");
571 }
572
573#ifdef VBOX_WITH_GUEST_PROPS
574 if (u64Cmd & USAGE_GUESTPROPERTY)
575 usageGuestProperty();
576#endif /* VBOX_WITH_GUEST_PROPS defined */
577
578 if (u64Cmd & USAGE_METRICS)
579 {
580 RTPrintf("VBoxManage metrics list [*|host|<vmname> [<metric_list>]]\n"
581 " (comma-separated)\n\n"
582 "VBoxManage metrics setup\n"
583 " [--period <seconds>]\n"
584 " [--samples <count>]\n"
585 " [--list]\n"
586 " [*|host|<vmname> [<metric_list>]]\n\n"
587 "VBoxManage metrics query [*|host|<vmname> [<metric_list>]]\n\n"
588 "VBoxManage metrics collect\n"
589 " [--period <seconds>]\n"
590 " [--samples <count>]\n"
591 " [--list]\n"
592 " [--detach]\n"
593 " [*|host|<vmname> [<metric_list>]]\n"
594 "\n");
595 }
596#if defined(VBOX_WITH_NETFLT)
597 if (u64Cmd & USAGE_HOSTONLYIFS)
598 {
599 RTPrintf("VBoxManage hostonlyif ipconfig <name>\n"
600 " [--dhcp |\n"
601 " --ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |\n"
602 " --ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]\n"
603# if defined(RT_OS_WINDOWS)
604 " create |\n"
605 " remove <name>\n"
606# endif
607 "\n");
608 }
609#endif
610
611 if (u64Cmd & USAGE_DHCPSERVER)
612 {
613 RTPrintf("VBoxManage dhcpserver add|modify --netname <network_name> |\n"
614#if defined(VBOX_WITH_NETFLT)
615 " --ifname <hostonly_if_name>\n"
616#endif
617 " [--ip <ip_address>\n"
618 " --netmask <network_mask>\n"
619 " --lowerip <lower_ip>\n"
620 " --upperip <upper_ip>]\n"
621 " [--enable | --disable]\n\n"
622 "VBoxManage dhcpserver remove --netname <network_name> |\n"
623#if defined(VBOX_WITH_NETFLT)
624 " --ifname <hostonly_if_name>\n"
625#endif
626 "\n");
627 }
628}
629
630/**
631 * Print a usage synopsis and the syntax error message.
632 */
633int errorSyntax(USAGECATEGORY u64Cmd, const char *pszFormat, ...)
634{
635 va_list args;
636 showLogo(); // show logo even if suppressed
637#ifndef VBOX_ONLY_DOCS
638 if (g_fInternalMode)
639 printUsageInternal(u64Cmd);
640 else
641 printUsage(u64Cmd);
642#endif /* !VBOX_ONLY_DOCS */
643 va_start(args, pszFormat);
644 RTPrintf("\n"
645 "Syntax error: %N\n", pszFormat, &args);
646 va_end(args);
647 return 1;
648}
649
650/**
651 * errorSyntax for RTGetOpt users.
652 *
653 * @returns 1.
654 *
655 * @param fUsageCategory The usage category of the command.
656 * @param rc The RTGetOpt return code.
657 * @param pValueUnion The value union.
658 */
659int errorGetOpt(USAGECATEGORY fUsageCategory, int rc, union RTGETOPTUNION const *pValueUnion)
660{
661 showLogo(); // show logo even if suppressed
662#ifndef VBOX_ONLY_DOCS
663 if (g_fInternalMode)
664 printUsageInternal(fUsageCategory);
665 else
666 printUsage(fUsageCategory);
667#endif /* !VBOX_ONLY_DOCS */
668
669 if (rc == VINF_GETOPT_NOT_OPTION)
670 return RTPrintf("error: Invalid parameter '%s'\n", pValueUnion->psz);
671 if (rc > 0)
672 {
673 if (RT_C_IS_PRINT(rc))
674 return RTPrintf("error: Invalid option -%c\n", rc);
675 return RTPrintf("error: Invalid option case %i\n", rc);
676 }
677 if (rc == VERR_GETOPT_UNKNOWN_OPTION)
678 return RTPrintf("error: unknown option: %s\n", pValueUnion->psz);
679 if (pValueUnion->pDef)
680 return RTPrintf("error: %s: %Rrs\n", pValueUnion->pDef->pszLong, rc);
681 return RTPrintf("error: %Rrs\n", rc);
682}
683
684/**
685 * Print an error message without the syntax stuff.
686 */
687int errorArgument(const char *pszFormat, ...)
688{
689 va_list args;
690 va_start(args, pszFormat);
691 RTPrintf("error: %N\n", pszFormat, &args);
692 va_end(args);
693 return 1;
694}
695
Note: See TracBrowser for help on using the repository browser.

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