VirtualBox

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

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

VBoxManageHelp: removed blank line in file header

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