VirtualBox

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

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

VBoxManage: Added support for querying and setting HID types.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.8 KB
Line 
1/* $Id: VBoxManageHelp.cpp 26936 2010-03-02 10:45:01Z 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 " [--hpet on|off]\n"
165 " [--hwvirtex on|off]\n"
166 " [--nestedpaging on|off]\n"
167 " [--vtxvpid on|off]\n"
168 " [--cpuidset <leaf> <eax> <ebx> <ecx> <edx>]\n"
169 " [--cpuidremove <leaf>]\n"
170 " [--cpuidremoveall]\n"
171 " [--cpus <number>]\n"
172 " [--rtcuseutc]\n"
173 " [--monitorcount <number>]\n"
174 " [--accelerate3d <on|off>]\n"
175#ifdef VBOX_WITH_VIDEOHWACCEL
176 " [--accelerate2dvideo <on|off>]\n"
177#endif
178 " [--firmware bios|efi|efi32|efi64]\n"
179 " [--bioslogofadein on|off]\n"
180 " [--bioslogofadeout on|off]\n"
181 " [--bioslogodisplaytime <msec>]\n"
182 " [--bioslogoimagepath <imagepath>]\n"
183 " [--biosbootmenu disabled|menuonly|messageandmenu]\n"
184 " [--biossystemtimeoffset <msec>]\n"
185 " [--biospxedebug on|off]\n"
186 " [--boot<1-4> none|floppy|dvd|disk|net>]\n"
187#if defined(VBOX_WITH_NETFLT)
188 " [--nic<1-N> none|null|nat|bridged|intnet|hostonly]\n"
189#else /* !RT_OS_LINUX && !RT_OS_DARWIN */
190 " [--nic<1-N> none|null|nat|bridged|intnet]\n"
191#endif /* !RT_OS_LINUX && !RT_OS_DARWIN */
192 " [--nictype<1-N> Am79C970A|Am79C973"
193#ifdef VBOX_WITH_E1000
194 "|\n 82540EM|82543GC|82545EM"
195#endif
196#ifdef VBOX_WITH_VIRTIO
197 "|\n virtio"
198#endif /* VBOX_WITH_VIRTIO */
199 "]\n"
200 " [--cableconnected<1-N> on|off]\n"
201 " [--nictrace<1-N> on|off]\n"
202 " [--nictracefile<1-N> <filename>]\n"
203 " [--nicspeed<1-N> <kbps>]\n"
204 " [--bridgeadapter<1-N> none|<devicename>]\n"
205#if defined(VBOX_WITH_NETFLT)
206 " [--hostonlyadapter<1-N> none|<devicename>]\n"
207#endif
208 " [--intnet<1-N> <network name>]\n"
209 " [--natnet<1-N> <network>|default]\n"
210 " [--macaddress<1-N> auto|<mac>]\n"
211 " [--mouse ps2|usb|usbtablet\n"
212 " [--keyboard ps2|usb\n"
213 " [--uart<1-N> off|<I/O base> <IRQ>]\n"
214 " [--uartmode<1-N> disconnected|\n"
215 " server <pipe>|\n"
216 " client <pipe>|\n"
217 " file <file>|\n"
218 " <devicename>]\n"
219 " [--guestmemoryballoon <balloonsize in MB>]\n"
220 " [--gueststatisticsinterval <seconds>]\n"
221 );
222 RTPrintf(" [--audio none|null");
223 if (fWin)
224 {
225#ifdef VBOX_WITH_WINMM
226 RTPrintf( "|winmm|dsound");
227#else
228 RTPrintf( "|dsound");
229#endif
230 }
231 if (fSolaris)
232 {
233 RTPrintf( "|solaudio"
234#ifdef VBOX_WITH_SOLARIS_OSS
235 "|oss"
236#endif
237 );
238 }
239 if (fLinux)
240 {
241 RTPrintf( "|oss"
242#ifdef VBOX_WITH_ALSA
243 "|alsa"
244#endif
245#ifdef VBOX_WITH_PULSE
246 "|pulse"
247#endif
248 );
249 }
250 if (fFreeBSD)
251 {
252 RTPrintf( "|oss"
253#ifdef VBOX_WITH_PULSE
254 "|pulse"
255#endif
256 );
257 }
258 if (fDarwin)
259 {
260 RTPrintf( "|coreaudio");
261 }
262 RTPrintf( "]\n");
263 RTPrintf(" [--audiocontroller ac97|sb16]\n"
264 " [--clipboard disabled|hosttoguest|guesttohost|\n"
265 " bidirectional]\n");
266 if (fVRDP)
267 {
268 RTPrintf(" [--vrdp on|off]\n"
269 " [--vrdpport default|<ports>]\n"
270 " [--vrdpaddress <host>]\n"
271 " [--vrdpauthtype null|external|guest]\n"
272 " [--vrdpmulticon on|off]\n"
273 " [--vrdpreusecon on|off]\n");
274 }
275 RTPrintf(" [--usb on|off]\n"
276 " [--usbehci on|off]\n"
277 " [--snapshotfolder default|<path>]\n"
278 " [--teleporter on|off]\n"
279 " [--teleporterport <port>]\n"
280 " [--teleporteraddress <address|empty>\n"
281 " [--teleporterpassword <password>]\n"
282 " [--hardwareuuid <uuid>]\n"
283 );
284 RTPrintf("\n");
285 }
286
287 if (u64Cmd & USAGE_IMPORTAPPLIANCE)
288 {
289 RTPrintf("VBoxManage import <ovf> [--dry-run|-n] [more options]\n"
290 " (run with -n to have options displayed\n"
291 " for a particular OVF)\n\n");
292 }
293
294 if (u64Cmd & USAGE_EXPORTAPPLIANCE)
295 {
296 RTPrintf("VBoxManage export <machines> --output|-o <ovf>\n"
297 " [--legacy09]\n"
298 " [--vsys <number of virtual system>]\n"
299 " [--product <product name>]\n"
300 " [--producturl <product url>]\n"
301 " [--vendor <vendor name>]\n"
302 " [--vendorurl <vendor url>]\n"
303 " [--version <version info>]\n"
304 " [--eula <license text>]\n"
305 " [--eulafile <filename>]\n"
306 "\n");
307 }
308
309 if (u64Cmd & USAGE_STARTVM)
310 {
311 RTPrintf("VBoxManage startvm <uuid>|<name>\n");
312 RTPrintf(" [--type gui");
313 if (fVBoxSDL)
314 RTPrintf( "|sdl");
315 if (fVRDP)
316 RTPrintf( "|vrdp");
317 RTPrintf( "|headless]\n");
318 RTPrintf("\n");
319 }
320
321 if (u64Cmd & USAGE_CONTROLVM)
322 {
323 RTPrintf("VBoxManage controlvm <uuid>|<name>\n"
324 " pause|resume|reset|poweroff|savestate|\n"
325 " acpipowerbutton|acpisleepbutton|\n"
326 " keyboardputscancode <hex> [<hex> ...]|\n"
327 " injectnmi|\n"
328 " setlinkstate<1-N> on|off |\n"
329#ifdef VBOX_DYNAMIC_NET_ATTACH
330#if defined(VBOX_WITH_NETFLT)
331 " nic<1-N> null|nat|bridged|intnet|hostonly\n"
332 " [<devicename>] |\n"
333#else /* !RT_OS_LINUX && !RT_OS_DARWIN */
334 " nic<1-N> null|nat|bridged|intnet\n"
335 " [<devicename>] |\n"
336#endif /* !RT_OS_LINUX && !RT_OS_DARWIN */
337 " nictrace<1-N> on|off\n"
338 " nictracefile<1-N> <filename>\n"
339#endif /* VBOX_DYNAMIC_NET_ATTACH */
340 " guestmemoryballoon <balloonsize in MB>]\n"
341 " gueststatisticsinterval <seconds>]\n"
342 " usbattach <uuid>|<address> |\n"
343 " usbdetach <uuid>|<address> |\n");
344 if (fVRDP)
345 {
346 RTPrintf(" vrdp on|off |\n");
347 RTPrintf(" vrdpport default|<ports> |\n");
348 }
349 RTPrintf(" setvideomodehint <xres> <yres> <bpp> [display] |\n"
350 " setcredentials <username> <password> <domain>\n"
351 " [--allowlocallogon <yes|no>] |\n"
352 " teleport --host <name> --port <port>\n"
353 " [--maxdowntime <msec>] [--password password]\n"
354 "\n");
355 }
356
357 if (u64Cmd & USAGE_DISCARDSTATE)
358 {
359 RTPrintf("VBoxManage discardstate <uuid>|<name>\n"
360 "\n");
361 }
362
363 if (u64Cmd & USAGE_ADOPTSTATE)
364 {
365 RTPrintf("VBoxManage adoptstate <uuid>|<name> <state_file>\n"
366 "\n");
367 }
368
369 if (u64Cmd & USAGE_SNAPSHOT)
370 {
371 RTPrintf("VBoxManage snapshot <uuid>|<name>\n"
372 " take <name> [--description <desc>] [--pause] |\n"
373 " delete <uuid>|<name> |\n"
374 " restore <uuid>|<name> |\n"
375 " restorecurrent |\n"
376 " edit <uuid>|<name>|--current\n"
377 " [--name <name>]\n"
378 " [--description <desc>] |\n"
379 " showvminfo <uuid>|<name>\n"
380 "\n");
381 }
382
383 if (u64Cmd & USAGE_OPENMEDIUM)
384 {
385 RTPrintf("VBoxManage openmedium disk|dvd|floppy <filename>\n"
386 " [--type normal|immutable|writethrough] (disk only)\n"
387 " [--uuid <uuid>]\n"
388 " [--parentuuid <uuid>] (disk only)\n"
389 "\n");
390 }
391
392 if (u64Cmd & USAGE_CLOSEMEDIUM)
393 {
394 RTPrintf("VBoxManage closemedium disk|dvd|floppy <uuid>|<filename>\n"
395 " [--delete]\n"
396 "\n");
397 }
398
399 if (u64Cmd & USAGE_STORAGEATTACH)
400 {
401 RTPrintf("VBoxManage storageattach <uuid|vmname>\n"
402 " --storagectl <name>\n"
403 " --port <number>\n"
404 " --device <number>\n"
405 " [--type <dvddrive|hdd|fdd>\n"
406 " --medium <none|emptydrive|uuid|filename|host:<drive>>]\n"
407 " [--passthrough <on|off>]\n"
408 " [--forceunmount]\n"
409 "\n");
410 }
411
412 if (u64Cmd & USAGE_STORAGECONTROLLER)
413 {
414 RTPrintf("VBoxManage storagectl <uuid|vmname>\n"
415 " --name <name>\n"
416 " [--add <ide/sata/scsi/floppy/sas>]\n"
417 " [--controller <LsiLogic/BusLogic/IntelAhci/PIIX3/PIIX4/ICH6/I82078/LsiLogicSas>]\n"
418 " [--sataideemulation<1-4> <1-30>]\n"
419 " [--sataportcount <1-30>]\n"
420 " [--remove]\n"
421 "\n");
422 }
423
424 if (u64Cmd & USAGE_SHOWHDINFO)
425 {
426 RTPrintf("VBoxManage showhdinfo <uuid>|<filename>\n"
427 "\n");
428 }
429
430 if (u64Cmd & USAGE_CREATEHD)
431 {
432 RTPrintf("VBoxManage createhd --filename <filename>\n"
433 " --size <megabytes>\n"
434 " [--format VDI|VMDK|VHD] (default: VDI)\n"
435 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
436 " [--type normal|writethrough] (default: normal)\n"
437 " [--comment <comment>]\n"
438 " [--remember]\n"
439 "\n");
440 }
441
442 if (u64Cmd & USAGE_MODIFYHD)
443 {
444 RTPrintf("VBoxManage modifyhd <uuid>|<filename>\n"
445 " [--type normal|writethrough|immutable]\n"
446 " [--autoreset on|off]\n"
447 " [--compact]\n"
448 "\n");
449 }
450
451 if (u64Cmd & USAGE_CLONEHD)
452 {
453 RTPrintf("VBoxManage clonehd <uuid>|<filename> <outputfile>\n"
454 " [--format VDI|VMDK|VHD|RAW|<other>]\n"
455 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
456 " [--type normal|writethrough|immutable]\n"
457 " [--remember] [--existing]\n"
458 "\n");
459 }
460
461 if (u64Cmd & USAGE_CONVERTFROMRAW)
462 {
463 RTPrintf("VBoxManage convertfromraw <filename> <outputfile>\n"
464 " [--format VDI|VMDK|VHD]\n"
465 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
466 "VBoxManage convertfromraw stdin <outputfile> <bytes>\n"
467 " [--format VDI|VMDK|VHD]\n"
468 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
469 "\n");
470 }
471
472 if (u64Cmd & USAGE_ADDISCSIDISK)
473 {
474 RTPrintf("VBoxManage addiscsidisk --server <name>|<ip>\n"
475 " --target <target>\n"
476 " [--port <port>]\n"
477 " [--lun <lun>]\n"
478 " [--encodedlun <lun>]\n"
479 " [--username <username>]\n"
480 " [--password <password>]\n"
481 " [--type normal|writethrough|immutable]\n"
482 " [--intnet]\n"
483 "\n");
484 }
485
486 if (u64Cmd & USAGE_GETEXTRADATA)
487 {
488 RTPrintf("VBoxManage getextradata global|<uuid>|<name>\n"
489 " <key>|enumerate\n"
490 "\n");
491 }
492
493 if (u64Cmd & USAGE_SETEXTRADATA)
494 {
495 RTPrintf("VBoxManage setextradata global|<uuid>|<name>\n"
496 " <key>\n"
497 " [<value>] (no value deletes key)\n"
498 "\n");
499 }
500
501 if (u64Cmd & USAGE_SETPROPERTY)
502 {
503 RTPrintf("VBoxManage setproperty hdfolder default|<folder> |\n"
504 " machinefolder default|<folder> |\n"
505 " vrdpauthlibrary default|<library> |\n"
506 " websrvauthlibrary default|null|<library> |\n"
507 " loghistorycount <value>\n"
508 "\n");
509 }
510
511 if (u64Cmd & USAGE_USBFILTER_ADD)
512 {
513 RTPrintf("VBoxManage usbfilter add <index,0-N>\n"
514 " --target <uuid>|<name>|global\n"
515 " --name <string>\n"
516 " --action ignore|hold (global filters only)\n"
517 " [--active yes|no] (yes)\n"
518 " [--vendorid <XXXX>] (null)\n"
519 " [--productid <XXXX>] (null)\n"
520 " [--revision <IIFF>] (null)\n"
521 " [--manufacturer <string>] (null)\n"
522 " [--product <string>] (null)\n"
523 " [--remote yes|no] (null, VM filters only)\n"
524 " [--serialnumber <string>] (null)\n"
525 " [--maskedinterfaces <XXXXXXXX>]\n"
526 "\n");
527 }
528
529 if (u64Cmd & USAGE_USBFILTER_MODIFY)
530 {
531 RTPrintf("VBoxManage usbfilter modify <index,0-N>\n"
532 " --target <uuid>|<name>|global\n"
533 " [--name <string>]\n"
534 " [--action ignore|hold] (global filters only)\n"
535 " [--active yes|no]\n"
536 " [--vendorid <XXXX>|\"\"]\n"
537 " [--productid <XXXX>|\"\"]\n"
538 " [--revision <IIFF>|\"\"]\n"
539 " [--manufacturer <string>|\"\"]\n"
540 " [--product <string>|\"\"]\n"
541 " [--remote yes|no] (null, VM filters only)\n"
542 " [--serialnumber <string>|\"\"]\n"
543 " [--maskedinterfaces <XXXXXXXX>]\n"
544 "\n");
545 }
546
547 if (u64Cmd & USAGE_USBFILTER_REMOVE)
548 {
549 RTPrintf("VBoxManage usbfilter remove <index,0-N>\n"
550 " --target <uuid>|<name>|global\n"
551 "\n");
552 }
553
554 if (u64Cmd & USAGE_SHAREDFOLDER_ADD)
555 {
556 RTPrintf("VBoxManage sharedfolder add <vmname>|<uuid>\n"
557 " --name <name> --hostpath <hostpath>\n"
558 " [--transient] [--readonly]\n"
559 "\n");
560 }
561
562 if (u64Cmd & USAGE_SHAREDFOLDER_REMOVE)
563 {
564 RTPrintf("VBoxManage sharedfolder remove <vmname>|<uuid>\n"
565 " --name <name> [--transient]\n"
566 "\n");
567 }
568
569 if (u64Cmd & USAGE_VM_STATISTICS)
570 {
571 RTPrintf("VBoxManage vmstatistics <vmname>|<uuid> [--reset]\n"
572 " [--pattern <pattern>] [--descriptions]\n"
573 "\n");
574 }
575
576#ifdef VBOX_WITH_GUEST_PROPS
577 if (u64Cmd & USAGE_GUESTPROPERTY)
578 usageGuestProperty();
579#endif /* VBOX_WITH_GUEST_PROPS defined */
580
581 if (u64Cmd & USAGE_METRICS)
582 {
583 RTPrintf("VBoxManage metrics list [*|host|<vmname> [<metric_list>]]\n"
584 " (comma-separated)\n\n"
585 "VBoxManage metrics setup\n"
586 " [--period <seconds>]\n"
587 " [--samples <count>]\n"
588 " [--list]\n"
589 " [*|host|<vmname> [<metric_list>]]\n\n"
590 "VBoxManage metrics query [*|host|<vmname> [<metric_list>]]\n\n"
591 "VBoxManage metrics collect\n"
592 " [--period <seconds>]\n"
593 " [--samples <count>]\n"
594 " [--list]\n"
595 " [--detach]\n"
596 " [*|host|<vmname> [<metric_list>]]\n"
597 "\n");
598 }
599#if defined(VBOX_WITH_NETFLT)
600 if (u64Cmd & USAGE_HOSTONLYIFS)
601 {
602 RTPrintf("VBoxManage hostonlyif ipconfig <name>\n"
603 " [--dhcp |\n"
604 " --ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |\n"
605 " --ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]\n"
606# if defined(RT_OS_WINDOWS)
607 " create |\n"
608 " remove <name>\n"
609# endif
610 "\n");
611 }
612#endif
613
614 if (u64Cmd & USAGE_DHCPSERVER)
615 {
616 RTPrintf("VBoxManage dhcpserver add|modify --netname <network_name> |\n"
617#if defined(VBOX_WITH_NETFLT)
618 " --ifname <hostonly_if_name>\n"
619#endif
620 " [--ip <ip_address>\n"
621 " --netmask <network_mask>\n"
622 " --lowerip <lower_ip>\n"
623 " --upperip <upper_ip>]\n"
624 " [--enable | --disable]\n\n"
625 "VBoxManage dhcpserver remove --netname <network_name> |\n"
626#if defined(VBOX_WITH_NETFLT)
627 " --ifname <hostonly_if_name>\n"
628#endif
629 "\n");
630 }
631}
632
633/**
634 * Print a usage synopsis and the syntax error message.
635 */
636int errorSyntax(USAGECATEGORY u64Cmd, const char *pszFormat, ...)
637{
638 va_list args;
639 showLogo(); // show logo even if suppressed
640#ifndef VBOX_ONLY_DOCS
641 if (g_fInternalMode)
642 printUsageInternal(u64Cmd);
643 else
644 printUsage(u64Cmd);
645#endif /* !VBOX_ONLY_DOCS */
646 va_start(args, pszFormat);
647 RTPrintf("\n"
648 "Syntax error: %N\n", pszFormat, &args);
649 va_end(args);
650 return 1;
651}
652
653/**
654 * errorSyntax for RTGetOpt users.
655 *
656 * @returns 1.
657 *
658 * @param fUsageCategory The usage category of the command.
659 * @param rc The RTGetOpt return code.
660 * @param pValueUnion The value union.
661 */
662int errorGetOpt(USAGECATEGORY fUsageCategory, int rc, union RTGETOPTUNION const *pValueUnion)
663{
664 showLogo(); // show logo even if suppressed
665#ifndef VBOX_ONLY_DOCS
666 if (g_fInternalMode)
667 printUsageInternal(fUsageCategory);
668 else
669 printUsage(fUsageCategory);
670#endif /* !VBOX_ONLY_DOCS */
671
672 if (rc == VINF_GETOPT_NOT_OPTION)
673 return RTPrintf("error: Invalid parameter '%s'\n", pValueUnion->psz);
674 if (rc > 0)
675 {
676 if (RT_C_IS_PRINT(rc))
677 return RTPrintf("error: Invalid option -%c\n", rc);
678 return RTPrintf("error: Invalid option case %i\n", rc);
679 }
680 if (rc == VERR_GETOPT_UNKNOWN_OPTION)
681 return RTPrintf("error: unknown option: %s\n", pValueUnion->psz);
682 if (pValueUnion->pDef)
683 return RTPrintf("error: %s: %Rrs\n", pValueUnion->pDef->pszLong, rc);
684 return RTPrintf("error: %Rrs\n", rc);
685}
686
687/**
688 * Print an error message without the syntax stuff.
689 */
690int errorArgument(const char *pszFormat, ...)
691{
692 va_list args;
693 va_start(args, pszFormat);
694 RTPrintf("error: %N\n", pszFormat, &args);
695 va_end(args);
696 return 1;
697}
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