VirtualBox

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

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

Main, FE: HPET review feedback

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